Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1.85 KB

README.md

File metadata and controls

49 lines (39 loc) · 1.85 KB

DevSoc Discord Bot

A repository containing the DevSoc discord server's python bot.

Originally Created by @emiipo Previously maintained/updated by @petelampy

Maintained/updated by @devj4y

Adding a command

To add a command either do it in general.py or make a new cog(class with its own listeners and commands):

Adding it in commands.py:

@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.

Making a new cog:

  • 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

API Documentation

The documentation for the API can be found here

Requirements