#Dedicated files for commands but not as a cog structure

1 messages · Page 1 of 1 (latest)

sharp elbow
#

I'm kinda a noob in programming but I like to be organized nontheless so im wondering how I can have seperate files for each command within a "cmds" folder and then have them called in the main.py file. I think its something with extensions but i simply dont really know how to make use of the documentation without a specific example or template. And it cant be a cog stucture because im trying to create some context menu apps which dont work in cogs. (So im currently converting my cog based bot with slash commands to be able to use context menus aswell as slash commands)

Hope someone can just give me a little example of what to put in the main.py file aswell as how to structure the dedicated file.

buoyant phoenix
#

cogs can use context menu and slash commands just fine, though?

sharp elbow
#

do they?

buoyant phoenix
#

yes

sharp elbow
#

When i tried to setup one within a cog it gave me an error that context menus cant be run from within cogs

#

Or is that a disnake "feature"

#

Cos i havent been using disnake before now

buoyant phoenix
#

I can't really say anything about other libs as I haven't used any aside from disnake but I'm 99% certain it just works with disnake

#

you should just be able to define a commands.user_command or commands.message_command in a cog in the same way as you would define a slash command

sharp elbow
#

do i just setup the context menu via the @bot.user_command decorator (i think it was that)?

#

ah okay

#

well, gonna try that then

buoyant phoenix
#

commands. instead of bot. inside cogs

sharp elbow
#

ive just been using discord.ext and app_commands, does disnake work with these side by side?

buoyant phoenix
#

disnake has it all built in

#

just use disnake's stuff to guarantee it works

#

There's a high chance that extensions made for libs other than disnake don't work with disnake

sharp elbow
#

Do i just replace anyx discord.ext with disnake.ext and so on or is it not that simple? LUL

buoyant phoenix
#

that's most of it

#

there should be a migration guide in our guide iirc