3 Commits

5 changed files with 42 additions and 10 deletions

14
package-lock.json generated
View File

@@ -9,7 +9,7 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"discord.js": "^14.24.1",
"discord.js": "^14.24.2",
"dotenv": "^17.2.2"
},
"devDependencies": {
@@ -177,9 +177,9 @@
}
},
"node_modules/@types/node": {
"version": "24.9.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz",
"integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==",
"version": "24.9.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.2.tgz",
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
"license": "MIT",
"dependencies": {
"undici-types": "~7.16.0"
@@ -214,9 +214,9 @@
]
},
"node_modules/discord.js": {
"version": "14.24.1",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.24.1.tgz",
"integrity": "sha512-LzL+MTGxB9mBwD8FjvkMwcIL4UtgG04e713U3+euqPCvOphhoVEoPpUNTvBPw4iJOas2uiuuh3JcveYSxIn8Tg==",
"version": "14.24.2",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.24.2.tgz",
"integrity": "sha512-VMEDbmguRdX/EeMaTsf9Mb0IQA90WdYF2cn4QDfslQFXgQ6LFtmlPn0FSotnS0kcFbFp+JBSIxtnF+bnAHG/hQ==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/builders": "^1.13.0",

View File

@@ -27,7 +27,7 @@
"typescript": "^5.9.2"
},
"dependencies": {
"discord.js": "^14.24.1",
"discord.js": "^14.24.2",
"dotenv": "^17.2.2"
}
}

View File

@@ -0,0 +1,30 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, MessageFlags, SlashCommandBuilder } from "discord.js";
import { CommandDefinition } from "../../type";
const cmd : CommandDefinition = {
data: new SlashCommandBuilder()
.setName('button')
.setDescription('Demo button'),
async execute(interaction) {
const button = new ButtonBuilder()
.setCustomId('test-button')
.setLabel('Click me !')
.setStyle(ButtonStyle.Success);
const row = new ActionRowBuilder<ButtonBuilder>()
.addComponents(button);
await interaction.reply({content: 'Oh one button !', components: [row]})
},
buttons: [
{
id: 'test-button',
async handle(interaction) {
await interaction.reply({content: 'Clicked !', flags: [MessageFlags.Ephemeral]});
},
}
]
}
export default cmd;

View File

@@ -5,7 +5,7 @@ const cmd : CommandDefinition = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Pong again!'),
async execute(interaction : ChatInputCommandInteraction) {
async execute(interaction) {
await interaction.reply('Pong !');
}
}

4
src/type.d.ts vendored
View File

@@ -1 +1,3 @@
export type CommandDefinition = { data: SlashCommandBuilder, execute: (interaction: ChatInputCommandInteraction) => void, buttons?: { id: string, handle: (interaction: ButtonInteraction) => void}[]};
import { ButtonInteraction, ChatInputCommandInteraction, SlashCommandOptionsOnlyBuilder } from "discord.js";
export type CommandDefinition = { data: SlashCommandBuilder | SlashCommandOptionsOnlyBuilder, execute: (interaction: ChatInputCommandInteraction) => void, buttons?: { id: string, handle: (interaction: ButtonInteraction) => void}[]};