done
This commit is contained in:
@@ -2,7 +2,4 @@
|
|||||||
AruaBot is a economy discord bot!
|
AruaBot is a economy discord bot!
|
||||||
|
|
||||||
|
|
||||||
# Installation
|
run `python3 main.py`
|
||||||
run `python3 install.py` (Windows not supported yet)
|
|
||||||
|
|
||||||
then run `python3 run.py`
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
from aura import *
|
|
||||||
from config import *
|
|
||||||
import discord
|
|
||||||
from discord import app_commands
|
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
aura = Aura()
|
|
||||||
client = discord.Client(intents=discord.Intents.all())
|
|
||||||
# bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
|
||||||
tree = app_commands.CommandTree(client)
|
|
||||||
|
|
||||||
@client.event
|
|
||||||
async def on_ready():
|
|
||||||
print(client.user)
|
|
||||||
for guild in client.guilds:
|
|
||||||
async for member in guild.fetch_members(limit=None):
|
|
||||||
user = aura.get(str(member.id))
|
|
||||||
if user==None:
|
|
||||||
aura.add(str(member.id))
|
|
||||||
print(await tree.sync())
|
|
||||||
|
|
||||||
@client.event
|
|
||||||
async def on_message(msg: discord.Message):
|
|
||||||
user = aura.get(str(msg.author.id))
|
|
||||||
user.balance += 3
|
|
||||||
aura.update(user)
|
|
||||||
|
|
||||||
@client.event
|
|
||||||
async def on_member_join(member: discord.Member):
|
|
||||||
user = aura.get(str(member.id))
|
|
||||||
if not user:
|
|
||||||
user = aura.add(str(member.id))
|
|
||||||
if USE_INVITE_SERVER:
|
|
||||||
member.send(embed=discord.Embed(color=member.color, title='✨ Welcome to ORUS! ✨', description=f'**Aura: {user.balance}\nInvite URL: {INVITE_SERVER_URL+member.id}\nShare this Invite URL to get 120+ aura per person**'))
|
|
||||||
|
|
||||||
@tree.command(name='aura', description='Check the amount of aura a member has')
|
|
||||||
async def get_aura(interaction: discord.Interaction, member: discord.Member = None):
|
|
||||||
if member == None:
|
|
||||||
member = interaction.user
|
|
||||||
user = aura.get(str(member.id))
|
|
||||||
embed = discord.Embed(color=member.color, title=f'{member.name}\'s Aura', description=user.to_md())
|
|
||||||
await interaction.response.send_message(embed=embed)
|
|
||||||
|
|
||||||
@tree.command(name='send', description='Send aura to a member')
|
|
||||||
async def send(interaction: discord.Interaction, to: discord.Member, amount: int, reason: str = ""):
|
|
||||||
user = aura.get(str(interaction.user.id))
|
|
||||||
user_to = aura.get(str(to.id))
|
|
||||||
if amount < 0:
|
|
||||||
amount = -amount
|
|
||||||
for r in interaction.user.roles:
|
|
||||||
if r.id in PUNISH_ROLES:
|
|
||||||
if user_to.balance >= amount:
|
|
||||||
user_to.balance -= amount
|
|
||||||
user.balance += 10
|
|
||||||
await to.send(embed=discord.Embed(
|
|
||||||
color=interaction.user.color,
|
|
||||||
title="Punished!",
|
|
||||||
description=f'**By: {interaction.user.name}\nAmount: {amount}\nReason: {reason}**'
|
|
||||||
))
|
|
||||||
await interaction.response.send_message(f'Punished! You gained 10+ aura!', ephemeral=True)
|
|
||||||
else:
|
|
||||||
await interaction.response.send_message(f'Cannot punish. {to.name} only has {user_to.balance} aura!', ephemeral=True)
|
|
||||||
return
|
|
||||||
if user.balance >= 10:
|
|
||||||
user.balance -= 10
|
|
||||||
await interaction.response.send_message(f'Cannot punish. You are not a developer.{" -10 aura!" if user.balance>=10 else""}', ephemeral=True)
|
|
||||||
aura.update(user)
|
|
||||||
aura.update(user_to)
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
if user.balance >= amount:
|
|
||||||
user.balance -= amount
|
|
||||||
user_to.balance += amount
|
|
||||||
await to.send(embed=discord.Embed(
|
|
||||||
color=interaction.user.color,
|
|
||||||
title="Aura received!",
|
|
||||||
description=f'**From: {interaction.user.name}\nAmount: {amount}**'
|
|
||||||
))
|
|
||||||
await interaction.response.send_message(f'Sent! You now have {user.balance} aura!', ephemeral=True)
|
|
||||||
aura.update(user)
|
|
||||||
aura.update(user_to)
|
|
||||||
else:
|
|
||||||
await interaction.response.send_message(f'Cannot send. You only have {user.balance} aura!', ephemeral=True)
|
|
||||||
|
|
||||||
client.run(BOT_TOKEN)
|
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
BOT_TOKEN=os.environ['BOT_TOKEN']
|
BOT_TOKEN=os.environ['BOT_TOKEN']
|
||||||
USE_INVITE_SERVER=os.environ['USE_INVITE']=='true'
|
USE_INVITE_SERVER=os.environ['USE_INVITE']=='true'
|
||||||
INVITE_SERVER_URL='127.0.0.1'
|
|
||||||
INVITE_SERVER_PORT=os.environ['PORT']
|
|
||||||
INVITE=os.environ['INVITE']
|
|
||||||
PUNISH_ROLES=(1279588925257683014,)
|
PUNISH_ROLES=(1279588925257683014,)
|
||||||
REDIS_URL=os.environ['REDIS_URL']
|
REDIS_URL=os.environ['REDIS_URL']
|
||||||
REDIS_USER=os.environ['REDIS_USER']
|
REDIS_USER=os.environ['REDIS_USER']
|
||||||
|
|||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
from os import system as cmd, name
|
|
||||||
|
|
||||||
if name != 'nt':
|
|
||||||
print('initializing environment')
|
|
||||||
cmd('python3 -m venv .venv')
|
|
||||||
print('installing discord.py')
|
|
||||||
cmd('./.venv/bin/pip3 install discord.py')
|
|
||||||
cmd('./.venv/bin/pip3 install Flask')
|
|
||||||
# token = input('Bot Token>')
|
|
||||||
# invite = input('Permanent Invite Link>')
|
|
||||||
# with open('config.py', 'w') as f:
|
|
||||||
# f.write(f"BOT_TOKEN='{token}'\nINVITE='{invite}'")
|
|
||||||
with open('aura.json', 'w') as f1:
|
|
||||||
f1.write('{}')
|
|
||||||
else:
|
|
||||||
print('installer currently does not support windows')
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
from aura import *
|
|
||||||
from config import *
|
|
||||||
from flask import Flask, redirect
|
|
||||||
|
|
||||||
aura = Aura()
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
def root():
|
|
||||||
return "ok"
|
|
||||||
|
|
||||||
@app.route('/<id>')
|
|
||||||
def invite(id):
|
|
||||||
user = aura.get(str(id))
|
|
||||||
if user:
|
|
||||||
user.balance+=120
|
|
||||||
aura.update(user)
|
|
||||||
return redirect(INVITE, code=302)
|
|
||||||
|
|
||||||
app.run('0.0.0.0', INVITE_SERVER_PORT)
|
|
||||||
@@ -1,16 +1,85 @@
|
|||||||
import os
|
from aura import *
|
||||||
env = os.environ.copy()
|
|
||||||
from config import *
|
from config import *
|
||||||
from subprocess import run as run_start
|
import discord
|
||||||
from threading import Thread
|
from discord import app_commands
|
||||||
import time
|
from discord.ext import commands
|
||||||
|
|
||||||
run = lambda a: run_start(a, env=env)
|
aura = Aura()
|
||||||
t1 = Thread(target=run, args=(['gunicorn', 'invite_sys:app'],))
|
client = discord.Client(intents=discord.Intents.all())
|
||||||
t2 = Thread(target=run, args=(['python3', 'bot.py'],))
|
# bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
||||||
t1.daemon = True
|
tree = app_commands.CommandTree(client)
|
||||||
t2.daemon = True
|
|
||||||
if USE_INVITE_SERVER:t1.start()
|
@client.event
|
||||||
t2.start()
|
async def on_ready():
|
||||||
while 1:
|
print(client.user)
|
||||||
time.sleep(.5)
|
for guild in client.guilds:
|
||||||
|
async for member in guild.fetch_members(limit=None):
|
||||||
|
user = aura.get(str(member.id))
|
||||||
|
if user==None:
|
||||||
|
aura.add(str(member.id))
|
||||||
|
print(await tree.sync())
|
||||||
|
|
||||||
|
@client.event
|
||||||
|
async def on_message(msg: discord.Message):
|
||||||
|
user = aura.get(str(msg.author.id))
|
||||||
|
user.balance += 3
|
||||||
|
aura.update(user)
|
||||||
|
|
||||||
|
@client.event
|
||||||
|
async def on_member_join(member: discord.Member):
|
||||||
|
user = aura.get(str(member.id))
|
||||||
|
if not user:
|
||||||
|
user = aura.add(str(member.id))
|
||||||
|
if USE_INVITE_SERVER:
|
||||||
|
member.send(embed=discord.Embed(color=member.color, title='✨ Welcome to ORUS! ✨', description=f'**Aura: {user.balance}\nInvite URL: {INVITE_SERVER_URL+member.id}\nShare this Invite URL to get 120+ aura per person**'))
|
||||||
|
|
||||||
|
@tree.command(name='aura', description='Check the amount of aura a member has')
|
||||||
|
async def get_aura(interaction: discord.Interaction, member: discord.Member = None):
|
||||||
|
if member == None:
|
||||||
|
member = interaction.user
|
||||||
|
user = aura.get(str(member.id))
|
||||||
|
embed = discord.Embed(color=member.color, title=f'{member.name}\'s Aura', description=user.to_md())
|
||||||
|
await interaction.response.send_message(embed=embed)
|
||||||
|
|
||||||
|
@tree.command(name='send', description='Send aura to a member')
|
||||||
|
async def send(interaction: discord.Interaction, to: discord.Member, amount: int, reason: str = ""):
|
||||||
|
user = aura.get(str(interaction.user.id))
|
||||||
|
user_to = aura.get(str(to.id))
|
||||||
|
if amount < 0:
|
||||||
|
amount = -amount
|
||||||
|
for r in interaction.user.roles:
|
||||||
|
if r.id in PUNISH_ROLES:
|
||||||
|
if user_to.balance >= amount:
|
||||||
|
user_to.balance -= amount
|
||||||
|
user.balance += 10
|
||||||
|
await to.send(embed=discord.Embed(
|
||||||
|
color=interaction.user.color,
|
||||||
|
title="Punished!",
|
||||||
|
description=f'**By: {interaction.user.name}\nAmount: {amount}\nReason: {reason}**'
|
||||||
|
))
|
||||||
|
await interaction.response.send_message(f'Punished! You gained 10+ aura!', ephemeral=True)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(f'Cannot punish. {to.name} only has {user_to.balance} aura!', ephemeral=True)
|
||||||
|
return
|
||||||
|
if user.balance >= 10:
|
||||||
|
user.balance -= 10
|
||||||
|
await interaction.response.send_message(f'Cannot punish. You are not a developer.{" -10 aura!" if user.balance>=10 else""}', ephemeral=True)
|
||||||
|
aura.update(user)
|
||||||
|
aura.update(user_to)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if user.balance >= amount:
|
||||||
|
user.balance -= amount
|
||||||
|
user_to.balance += amount
|
||||||
|
await to.send(embed=discord.Embed(
|
||||||
|
color=interaction.user.color,
|
||||||
|
title="Aura received!",
|
||||||
|
description=f'**From: {interaction.user.name}\nAmount: {amount}**'
|
||||||
|
))
|
||||||
|
await interaction.response.send_message(f'Sent! You now have {user.balance} aura!', ephemeral=True)
|
||||||
|
aura.update(user)
|
||||||
|
aura.update(user_to)
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(f'Cannot send. You only have {user.balance} aura!', ephemeral=True)
|
||||||
|
|
||||||
|
client.run(BOT_TOKEN)
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
Flask
|
|
||||||
discord.py
|
discord.py
|
||||||
redis
|
redis
|
||||||
gunicorn
|
|
||||||
Reference in New Issue
Block a user