Can sapphire framework handle edits?

It's a similar concept to what discord-akairo used to have back in the days like your command would be executed if a user edited their message to a command trigger
Solution:
I think some other frameworks fully obfuscate the reply layer but Sapphire doesn't because that then makes assumptions about how you would reply. For example message replies cannot be ephemeral, interaction replies can be. So rather than making assumptions and wrappers for all the different layers we just ask users to implement their own logic. There simply will never be a one size fits all.
Jump to solution
5 Replies
Favna
Favna14mo ago
Yes, install and register @sapphire/plugin-editable-comands and use it's send method to send messages. That said, chat input commands can inherently never be edited so keep that in mind. Like Discord we also implore everyone to leverage the power of chat input commands.
xenofic
xenofic14mo ago
Ok thanks a lot another question does it also support hybrid commands so i don't really have to use all the methods seperately and if we can't is there any way i can extend the structure inheretently
Favna
Favna14mo ago
Sapphire support hybrid commands yes if that's what you're asking. Just implement both messageRun and chatInputRun and separate the duplicate logic to your own method which you call from both. very rough example:
import { send } from '@sapphire/plugin-editable-commands';

// other command stuff

public async messageRun(message: Message) {
const data = parseStuffOrSomething(message);
return send(data);
}

public async chatInputRun(interaction: ChatInputInteraction) {
const data = parseStuffOrSomething(interaction);
return interaction.reply(data);
}

private parseStuffOrSomething(messageOrInteraction: Message | ChatInputInteraction) {
// do stuff
return something;
}
import { send } from '@sapphire/plugin-editable-commands';

// other command stuff

public async messageRun(message: Message) {
const data = parseStuffOrSomething(message);
return send(data);
}

public async chatInputRun(interaction: ChatInputInteraction) {
const data = parseStuffOrSomething(interaction);
return interaction.reply(data);
}

private parseStuffOrSomething(messageOrInteraction: Message | ChatInputInteraction) {
// do stuff
return something;
}
Solution
Favna
Favna14mo ago
I think some other frameworks fully obfuscate the reply layer but Sapphire doesn't because that then makes assumptions about how you would reply. For example message replies cannot be ephemeral, interaction replies can be. So rather than making assumptions and wrappers for all the different layers we just ask users to implement their own logic. There simply will never be a one size fits all.
xenofic
xenofic14mo ago
Thanks i appreciate for the example ❤️