-
Notifications
You must be signed in to change notification settings - Fork 1
COGS
Ted edited this page Apr 25, 2023
·
13 revisions
To keep a common shape for all cogs, it is best to organize the imports properly. We suggest you to take inspiration from this.
- ππ«π§ππ₯π‘ππ ππ π£π’π₯π§
-
- ππ’π§.ππ¦π¦ππ¦π§ππ‘π§ ππ π£π’π₯π§π¦
- Handlers
- Services
- Settings
- ππ’π§ππ¦π¦ππ¦π§ππ‘π§ ππ’π§
- ππππ’π‘
- Init
- Commands
- Events
- Handlers
- Services
- Settings
# ππ¨π§ππ’π₯:
# ππ«π§ππ₯π‘ππ ππ π£π’π₯π§
# -
# ππ’π§.ππ¦π¦ππ¦π§ππ‘π§ ππ π£π’π₯π§π¦
# -
# ππ’π§ππ¦π¦ππ¦π§ππ‘π§ ππ’π§
# -
# ππππ’π‘
# -- ππ©ππ‘π§π¦
- ππ¨π§π’ππ’π π£πππ§π
- ππ’π π ππ‘ππ¦
class Example(commands.Cog):
def __init__(self, bot):
self.bot = bot
# ππ©ππ‘π§π¦
# Event on Ready
@commands.Cog.listener()
async def on_ready(self):
await eventOnReady.onReady()
# ππ¨π§π’ππ’π π£πππ§π
# Autocomplete for example
async def getExample(ctx: discord.AutocompleteContext):
return []
# ππ’π π ππ‘ππ¦
# Commands groups
groupExample = discordCommands.SlashCommandGroup(init.cogName, "Example description")
groupSub = groupLevelSystem.create_subgroup("subExample", "Exemple sub description")
# Verify if the bot has the prerequisites permissions
@groupExample .command(name="requirements", description="Check the prerequisites permissions of the addon.")
async def cmdPermissions(self, ctx: commands.Context):
await DiscordLogger.info(ctx, init.cogName, ctx.author.name + " has used the requirements command.", str(ctx.command))
await commandRequirements.checkRequirements(ctx)
def setup(bot):
if debug: Logger.debug("Example")
handlerDatabaseInit.databaseInit()
bot.add_cog(Example(bot))