-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
123 lines (104 loc) · 4.66 KB
/
bot.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import discord
import responses
from discord import app_commands
from discord.ext import commands
import logging
import em
import creds
guild=discord.Object(id=creds.id)
application_id = creds.application_id
TOKEN = creds.TOKEN
intents = discord.Intents.all()
logger=logging.getLogger("bot")
#fun commands Ping and Pong
class MyGroup(app_commands.Group):
@app_commands.command()
async def ping(self,interaction:discord.Interaction):
await interaction.response.send_message(f"pong")
@app_commands.command()
async def pong(self,interaction:discord.Interaction):
await interaction.response.send_message(f"ping")
#Commands so that people can register for a tournament rn only 3v3 focused
class help(app_commands.Group):
@app_commands.command()
async def register(self,interaction: discord.Interaction,query:str):
await interaction.response.defer()
uid=interaction.user.id
val = em.reg(uid) #runs the register command and returns a value
await interaction.followup.send(val,ephemeral=True) #waits for em for more than 3 seconds and ephemeral will make it a only you can see message
#commands for helpline either for tourney or queries or reporting
class tourney(app_commands.Group):
@app_commands.command()
async def register(self,interaction: discord.Interaction,teammate1:str,teammate2:str,sub:str,coach:str):
await interaction.response.defer()
uid=interaction.user.id
val = em.reg(uid)
await interaction.followup.send(val,ephemeral=True)
@app_commands.command()
async def derigester(self,interaction: discord.Interaction,teammate1:str,teammate2:str,sub:str,coach:str):
await interaction.response.defer()
uid=interaction.user.id
val = em.reg(uid)
await interaction.followup.send(val,ephemeral=True)
#commands for an admin so he can create a tournament and modify details or publish the tourney screen or seeding
class tourney(app_commands.Group):
@app_commands.command()
async def register(self,interaction: discord.Interaction,teammate1:str,teammate2:str,sub:str,coach:str):
await interaction.response.defer()
uid=interaction.user.id
val = em.reg(uid)
await interaction.followup.send(val,ephemeral=True)
#commands for visualizing the tournament and update or delete the visualization
class visualize(app_commands.Group):
@app_commands.command()
async def tourney_display(self,interaction: discord.Interaction):
pass
@app_commands.command()
async def tourney_refresh(self,interaction: discord.Interaction):
pass
@app_commands.command()
async def tourney_remove(self,interaction: discord.Interaction):
pass
class signup(app_commands.Group):
@app_commands.command()
async def register(self,interaction: discord.Interaction,email:str):
await interaction.response.defer()
uid=interaction.user.id
val = em.reg(uid,email)
await interaction.followup.send(val,ephemeral=True)
@app_commands.command()
async def verify(self,interaction: discord.Interaction,otp:str):
await interaction.response.defer()
uid=interaction.user.id
va = em.verify(uid,otp)
await interaction.followup.send(va,ephemeral=True)
@app_commands.command()
async def change_email(self,interaction: discord.Interaction,email:str):
await interaction.response.defer()
uid=interaction.user.id
v=em.ce(uid,email)
await interaction.followup.send(v,ephemeral=True)
@app_commands.command()
async def resend_otp(self,interaction: discord.Interaction):
await interaction.response.defer()
uid=interaction.user.id
v=em.rotp(uid)
await interaction.followup.send(v,ephemeral=True)
def run_discord_bot():
bot = commands.Bot(command_prefix="!",intents=intents)
@bot.event
async def on_ready():
logger.info(f"User: {bot.user} (ID: {bot.user.id})")
mygroup=MyGroup(name="greetings",description="Welcomes users")
bot.tree.add_command(mygroup)
sign=signup(name="signup",description="Register to participate in tournaments") #create signup commands
bot.tree.add_command(sign) #adding it to the command list
bot.tree.copy_global_to(guild=guild)
await bot.tree.sync(guild=guild)
@bot.tree.command(description="Ask FAQ's", name="ask")
async def ask(interaction: discord.Interaction, query:str):
await interaction.response.defer()
answer_text = responses.handle_response(query)
await interaction.followup.send(answer_text)
bot.run(TOKEN,root_logger=True)
#implementing new changes