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
This commit is contained in:
mightypanders 2023-06-06 23:27:41 +02:00
parent efd4d69c74
commit 84a0d7bbe1

View File

@ -8,7 +8,7 @@ export async function execute(interaction: ExtendedInteraction) {
//console.dir(interaction, { depth: null }) //console.dir(interaction, { depth: null })
if (interaction.isCommand()) { if (interaction.isCommand()) {
logger.info(`Interaction is a command.`, { guildId: interaction.guild?.id }) logger.info(`Interaction is a command.`, { guildId: interaction.guild?.id })
await interaction.deferReply() await interaction.deferReply({ ephemeral: true })
const command = client.commands.get(interaction.commandName) const command = client.commands.get(interaction.commandName)
if (!command) if (!command)
return interaction.followUp('Invalid command') return interaction.followUp('Invalid command')