This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
92 lines (74 loc) · 3.22 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import os, asyncio, discord, random, string, db
from discord.ext import commands
from dotenv import load_dotenv
# Get .env variable
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
# Check db
os.system("./script/check_db.sh")
# Setup cmd Prefix
bot = commands.Bot(command_prefix='!')
def get_token():
return ''.join(random.choice(string.ascii_letters) for x in range(32))
# Set custom status
@bot.event
async def on_ready():
print(f'{bot.user} has connected to Discord!')
activity = discord.Game(name="be in BETA", type=4)
await bot.change_presence(activity=activity)
# MANAGE CMD
@bot.command(name='team', help=" !team @captain @player1 @player2 ")
async def register_team(ctx):
await ctx.send("https://tenor.com/view/bug-fix-fixing-bugs-in-your-code-bugs-code-sinking-gif-17779185")
"""
CMD : !profile
USAGE : !profile IG_nickname highest_rank "Your bio"
DESCRIPTION : Register your self on our system
"""
@bot.command(name='profile', help="!profile IG_nickname highest_rank \"Your bio\" Create your profile")
async def profile(ctx, nickname, rank, bio):
if(db.is_player_register(ctx.author.id)):
token = get_token()
await db.new_player(ctx, token, nickname, rank, bio)
await ctx.send(f"Welcome aboard :smile:, here is a recap of your identity. if there is an error you can use `!update`\n**Nickname :** `{nickname}`\n**Highest rank : **`{rank}`\n**Bio : **`{bio}`")
await ctx.author.create_dm()
await ctx.author.dm_channel.send(
f'Hey {ctx.author.name}, here is your recovery token account keep it private :smile:\n**TOKEN: **`{token}`')
else:
await ctx.send("You are already register, please do !update :smile:")
"""
CMD : !info
USAGE : !info @someone
DESCRIPTION : Get player information
"""
@bot.command(name='info', help="!info @someone")
async def info(ctx, user):
user = user.replace("<@!", "")
user = user.replace(">", "")
if(not db.is_player_register(user)):
data = db.show_player(user)
await ctx.send("**Nickname :** `" + data[0] + "` \n**Highest rank : **`"+ data[1] + "`\n**Bio : **`" + data[2] + "`")
else:
await ctx.send("This player is not register")
"""
CMD : !update
USAGE : !update token IG_nickname highest_rank "Your bio"
DESCRIPTION : Update your player profile
"""
@bot.command(name='update', help="!update token IG_nickname highest_rank \"Your bio\" Update your profile")
async def update_profile(ctx, token, nickname, rank, bio ): #
if(not db.is_player_register(ctx.author.id)):
new_token = get_token()
db_token = db.show_token(ctx.author.id)
if(db_token[0] == token):
await db.update_player(ctx, new_token, nickname, rank, bio)
await ctx.author.create_dm()
await ctx.author.dm_channel.send(
f'Hey {ctx.author.name}, here is your recovery token account keep it private :smile:\n**TOKEN: **`{new_token}`')
await ctx.send(f"Done :smile:\n**Nickname :** `{nickname}`\n**Highest rank : **`{rank}`\n**Bio : **`{bio}`\nYou can check with !info @{ctx.author} !")
else:
await ctx.send("**ERROR** Bad token")
else:
await ctx.send("You are not register")
# Run bot
bot.run(TOKEN)