Files
pixelpoebel/src/events/interactionCreate.ts
sarah f78636447b
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 6s
Fix: Replace deprecated ephemeral with MessageFlags.Ephemeral
Fixes Discord.js v14 deprecation warning by replacing all
ephemeral: true usages with flags: [MessageFlags.Ephemeral].

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 18:22:44 +01:00

32 lines
1.1 KiB
TypeScript

import { Events, MessageFlags } from 'discord.js';
export default {
name: Events.InteractionCreate,
async execute(interaction: any, client: any) {
if (!interaction.isChatInputCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
await command.execute(interaction, client);
client.DB.run(`
INSERT INTO command_stats (command_name, uses)
VALUES (?, 1)
ON CONFLICT(command_name) DO UPDATE SET uses = uses + 1
`, interaction.commandName);
} catch (error) {
console.error(error);
const replyOptions = { content: 'There was an error while executing this command!', flags: [MessageFlags.Ephemeral] };
if (interaction.replied || interaction.deferred) {
await interaction.followUp(replyOptions);
} else {
await interaction.reply(replyOptions);
}
}
},
};