jellyfin-discord-bot/server/events/interactionCreate.ts
mightypanders 84a0d7bbe1 turn all slash command replies into an ephemeral message
Setting ephemeral has to happen in an initial reply (reply() or
deferReply()) to set the mode for all replies in this 'thread'. Once the
ephemeral state of a message has been set it can not be changed. If you
want to send a visible message after an ephemeral message it has to be
new message. See https://discordjs.guide/slash-commands/response-methods.html#ephemeral-responses
2023-06-06 23:27:41 +02:00

22 lines
777 B
TypeScript

import { CommandInteractionOptionResolver } from "discord.js"
import { ExtendedInteraction } from "../types/commandTypes"
import { client } from "../.."
import { logger } from "../logger"
export const name = 'interactionCreate'
export async function execute(interaction: ExtendedInteraction) {
//console.dir(interaction, { depth: null })
if (interaction.isCommand()) {
logger.info(`Interaction is a command.`, { guildId: interaction.guild?.id })
await interaction.deferReply({ ephemeral: true })
const command = client.commands.get(interaction.commandName)
if (!command)
return interaction.followUp('Invalid command')
command.run({
args: interaction.options as CommandInteractionOptionResolver,
client,
interaction
})
}
}