A repository containing the DevSoc discord server's python bot.
Originally Created by @emiipo Previously maintained/updated by @petelampy
Maintained/updated by @devj4y
To add a command either do it in general.py
or make a new cog(class with its own listeners and commands):
@commands.command #Register the command with the bot.
async def command(self, ctx, arg): #Define the command name.
await ctx.send(arg) #Execute the command. In this case we send the argument passed back to the user.
- A command must always have at least one parameter, ctx, which is the Context as the first one.
- The command is triggered using
prefix+command
. The current prefix is.
so the command would be.command
.
- Make a new file or a class in
commands.py
- If making a new file don't forget this import:
from discord.ext import commands
- Set up the cog, make sure it has init:
class Cog_Name: #Setup the cog.
def __init__(self, bot):
self.bot = bot #If you don't have this the commands won't work as they won't be able to get ctx(context).
- Write your commands the same way as in
general.py
- Don't forget to add this at the end:
def setup(bot):
bot.add_cog(Cog_Name(bot))
More on commands: here
The documentation for the API can be found here