I'm coming from Nextcord where we have cogs, but here I'm confused. What if I want one command per class? Do I have to register them all manually?
Here's what I'm doing now: I have a Bot class that has:
var slash = discord.UseSlashCommands(); slash.RegisterCommands<DiscordCommand>();
Then in my DiscordCommand class I have a few Tasks with \[SlashCommand\] attributes.
Ideally I would want to make a new class for every command, and have that class inherit from a BaseCommand class that auto registers itself somehow. Is there a way to do that?
Thanks in advance.
There is a relatively easy way of doing this so that you don't need 100 lines of
slash.RegisterCommand<t>()in your code. In this example we will assume you have the word "Command" in all class names that contain a command, and that all of your commands are in the namespaceProject.Commands.Instead of doing this:
We are going to loop through all the classes of the namespace
Project.Commandsand register these through the loop.