Add comments on the code and add a simple slash commands

This commit is contained in:
Stefano Assenzo 2023-01-25 16:00:49 +00:00 committed by GitHub
parent d07dbac7f5
commit f58b8a06c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -24,6 +24,7 @@ async def on_ready():
print('We have logged in as {0.user}'.format(bot))
bot.loop.create_task(orario())
# Search on MongoDB the subject and send a message on Discord if the subject is found
@tasks.loop(seconds=1)
async def orario():
documents = collection.find()
@ -37,4 +38,8 @@ async def orario():
channel = bot.get_channel(1063753802638954519)
await channel.send(f"Day: {day}, Hour school: {i}, Subject found: {subject['Subject']} at index: {i}")
@bot.slash_command(name="first_slash", guild_ids=['1063753799874912337']) #Add the guild ids in which the slash command will appear. If it should be in all, remove the argument, but note that it will take some time (up to an hour) to register the command if it's for all guilds.
async def first_slash(ctx):
await ctx.respond("You executed the slash command!")
bot.run(DISCORD_TOKEN)