Is there anyway using Subcommand plugin with Slash command

Seem like chatInputRun is not exist on SubCommand
11 Replies
Favna
Favna2y ago
because you're not supposed to implement it SubCommand implements chatInputRun and overriding it disables the subcommand parsing you're supposed to only implement the subcommands
log(n)
log(n)2y ago
why not use slash command builders?
MRDGH2821
MRDGH28212y ago
Builders would consume more memory. So I'm avoiding builders wherever possible.
log(n)
log(n)2y ago
What sort of environment are you running in where a class instance that would get GC'd takes a significant amount memory vs the object it returns? If you're trying to run code in like.. 50MiB of memory I could understand that, but I truely doubt that (+ JS wouldn't be the best choice)
HellCatVN
HellCatVN2y ago
This solve my question
Favna
Favna2y ago
Adding to this if the validation checks are a concern they can be disabled, but even then shapeshift is blazingly fast anyway.
MRDGH2821
MRDGH28212y ago
Uhh this is gonna go out of scope of this question. I have put my 3 bots in a their own docker container. Hosted on VM of 1 vCPU & 2GB RAM. As for why no builders (in general, not just slash command builders) - Builders would ultimately return an JS/JSON object, so why not directly define JS/JSON object myself? Builders are good for beginners, but now I'm making 3.x.x/4.x.x version of my bot, so I would definitely use some optimizations here & there - Makes that part of code portable across library & language
log(n)
log(n)2y ago
My bots use builders and run in a container with 1 vCPU and 256 MiB RAM. That's not really a huge bottleneck unless your bot is large. Builders make your code more readable and can add validation checks and better strict typing. The optimization of using builders is likely not noticable. Builders exist in almost every language, and most have even better ways of doing this directly in the type system, like Rust:
#[poise::command(slash_command)]
/// Command description
fn command_name(#[description = "Arg description"] arg_name: ArgType) -> Result<(), anyhow::Error> {
// ...
}
#[poise::command(slash_command)]
/// Command description
fn command_name(#[description = "Arg description"] arg_name: ArgType) -> Result<(), anyhow::Error> {
// ...
}
Sean
Sean2y ago
Builders also make your code easier to maintain, as it abstracts changes made by discord away from you and to the libary (discord.js, in this case)
Want results from more Discord servers?
Add your server