Splitting Subcommand functions to multiple files

I have a command that has quite a few subcommands. I was wondering if there was any way to directly place a function in the messageRun chatInputRun entries so I could split the Subcommands into their own files/classes as the main command file is roughly 2.5k lines at the moment. I know I could just have each method inside of the class then call the other classes/files inside of it (which is what I'm currently doing), just wanted to see if there was a cleaner way. Is this possible?
subcommands: [
{
name: 'link',
messageRun: <function from other class here>
chatInputRun: <function from other class here>,
preconditions: ['AgeCheck'],
subcommands: [
{
name: 'link',
messageRun: <function from other class here>
chatInputRun: <function from other class here>,
preconditions: ['AgeCheck'],
what I'm currently doing:
subcommands: [
{
name: 'link',
messageRun: 'messageLink',
chatInputRun: 'chatInputLink',
preconditions: ['AgeCheck'],
....

public async messageLink(message: Message, args: Args) {
return message.channel.send(await Link.accountLink(message, args));
}

public async chatInputList(interaction: Subcommand.ChatInputCommandInteraction) {
return interaction.reply(await Link.accountLink(interaction, interaction.options))
}
subcommands: [
{
name: 'link',
messageRun: 'messageLink',
chatInputRun: 'chatInputLink',
preconditions: ['AgeCheck'],
....

public async messageLink(message: Message, args: Args) {
return message.channel.send(await Link.accountLink(message, args));
}

public async chatInputList(interaction: Subcommand.ChatInputCommandInteraction) {
return interaction.reply(await Link.accountLink(interaction, interaction.options))
}
Solution:
You can use https://github.com/sawa-ko/neko-plugins/tree/main/packages/subcommands-advanced, it is not supported in the default plugin.
Jump to solution
1 Reply
Solution
Favna
Favna9mo ago
You can use https://github.com/sawa-ko/neko-plugins/tree/main/packages/subcommands-advanced, it is not supported in the default plugin.
Want results from more Discord servers?
Add your server