feat: support of buttons

This commit is contained in:
Mylloon 2023-01-16 10:17:32 +01:00
parent 0299770ec1
commit eb741f409a
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 17 additions and 1 deletions

View file

@ -1,4 +1,4 @@
import { Client, Interaction, InteractionType } from 'discord.js';
import { Client, ComponentType, Interaction, InteractionType } from 'discord.js';
import { getLocale } from '../../utils/locales';
/** https://discord.js.org/#/docs/discord.js/main/class/Client?scrollTo=e-interactionCreate */
@ -29,6 +29,21 @@ export default (interaction: Interaction, client: Client) => {
return modal.interaction(interaction, client);
}
case InteractionType.MessageComponent:
if (interaction.componentType == ComponentType.Button) {
const button = client.buttons.list.get(interaction.customId);
if (!button) {
return interaction.reply({
content: loc.get('e_interacreate_no_button'),
});
}
return interaction;
}
// Handle only buttons for now
throw RangeError;
default:
break;
}

View file

@ -1,6 +1,7 @@
{
"e_interacreate_no_command": "Désolé, la commande n'existe plus...",
"e_interacreate_no_modal": "Désolé, le modèle n'existe plus...",
"e_interacreate_no_button": "Désolé, le bouton n'existe plus...",
"c_ping_name": "Ping",
"c_ping_desc": "Pong!",