Skip to content

Instantly share code, notes, and snippets.

@Vexs
Created May 27, 2019 06:43
Show Gist options
  • Save Vexs/367e7140a7a09c1160357f9007506198 to your computer and use it in GitHub Desktop.
Save Vexs/367e7140a7a09c1160357f9007506198 to your computer and use it in GitHub Desktop.
Short cog example
from discord.ext import commands
#cogs must now subclass commands.Cog
class MyCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
#listeners now must have a decorator
@commands.Cog.listener()
async def on_message(self, message):
print(message.content)
@commands.command()
async def echo(self, ctx, *, message):
await ctx.send(message)
#this is technically part of extensions
def setup(bot):
bot.add_cog(MyCog(bot))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment