Add a new command - ArthurBoddaert/Discord-Bot GitHub Wiki

With a 'cog' file

cogs documentation

  1. Create a new python file in the 'cogs' folder
  2. Here is a template of cog file
import discord as discord
from discord.ext import commands

class MyCog(commands.Cog):
	def __init__(self, bot):
		self.bot=bot

	@commands.command()
	async def ping(self, ctx):
		return await ctx.send('ping')

def setup(bot):
	bot.add_cog(MyCog(bot))
  1. In order to link your new cog to the bot, all you have to do is to add bot.load_extension('cogs.nameOfTheCogFile') to the 'bot.py' file

In the 'bot.py' file

If you want to create a new command directly in the 'bot.py' file, here is an example of what you have to do:

@bot.command()
async def ping(ctx):
	return await ctx.send('ping')