From ce94e0c61d351e30c024aefa1666ad317aed72f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morg=C3=A2n=20von=20Bryl=C3=A2n?= Date: Fri, 27 Jun 2025 03:13:19 +0200 Subject: [PATCH] ref: replace "Ephemeral" with a an enum value --- src/commands/delete-and-warn.ts | 7 ++++--- src/commands/info.ts | 3 ++- src/commands/purge.ts | 4 ++-- src/listeners/delete-and-warn.ts | 5 +++-- src/listeners/suggestion-interaction.ts | 11 ++++++----- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/commands/delete-and-warn.ts b/src/commands/delete-and-warn.ts index b4b1992..eb30dbe 100644 --- a/src/commands/delete-and-warn.ts +++ b/src/commands/delete-and-warn.ts @@ -2,6 +2,7 @@ import { PermissionFlagsBits, ApplicationCommandType, TextInputStyle, + MessageFlags, } from "discord.js"; const { ManageMessages, ModerateMembers } = PermissionFlagsBits; import { modalInput } from "../components.ts"; @@ -17,18 +18,18 @@ const DeleteAndWarn: MessageCommand = { const { channel, targetMessage } = interaction; if (!channel) return interaction.reply({ - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, content: "Error: could not fetch the channel", }); if (channel.isDMBased()) return interaction.reply({ - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, content: "Cannot use this command in DMs", }); if (!targetMessage.deletable) { return interaction.reply({ - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, content: "I do not have the permission to delete messages in this channel.", }); diff --git a/src/commands/info.ts b/src/commands/info.ts index 48845e7..e992f09 100644 --- a/src/commands/info.ts +++ b/src/commands/info.ts @@ -3,6 +3,7 @@ import { type APIEmbed, ApplicationCommandType, channelMention, + MessageFlags, } from "discord.js"; import type { Command } from "djs-fsrouter"; @@ -14,7 +15,7 @@ const Info: Command = { if (!interaction.guild) { interaction.reply({ content: "Run this command in a server to get server info", - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, }); return; } diff --git a/src/commands/purge.ts b/src/commands/purge.ts index b0b0701..4e5e94b 100644 --- a/src/commands/purge.ts +++ b/src/commands/purge.ts @@ -1,4 +1,4 @@ -import { ApplicationCommandOptionType, PermissionFlagsBits } from "discord.js"; +import { ApplicationCommandOptionType, PermissionFlagsBits, MessageFlags } from "discord.js"; const { ManageMessages } = PermissionFlagsBits; import type { Command } from "djs-fsrouter"; @@ -28,7 +28,7 @@ const Purge: Command = { const { channel } = interaction; function reply(content: string) { - return interaction.reply({ flags: "Ephemeral", content }); + return interaction.reply({ flags: MessageFlags.Ephemeral, content }); } if (!channel) { diff --git a/src/listeners/delete-and-warn.ts b/src/listeners/delete-and-warn.ts index 505f756..739c155 100644 --- a/src/listeners/delete-and-warn.ts +++ b/src/listeners/delete-and-warn.ts @@ -1,5 +1,6 @@ import type { Listener } from "../types/listener.ts"; import { customId } from "../commands/delete-and-warn.ts"; +import { MessageFlags } from "discord.js"; export default [ { @@ -29,7 +30,7 @@ export default [ .then(() => { interaction .reply({ - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, content: "Reason sent.", }) .catch(console.error); @@ -37,7 +38,7 @@ export default [ .catch(() => { interaction .reply({ - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, content: `The reason could not be sent to ${target}; they proabably blocked me or disabled DMs from server members.\n\`\`\`${reason}\`\`\``, }) .catch(console.error); diff --git a/src/listeners/suggestion-interaction.ts b/src/listeners/suggestion-interaction.ts index 2ad634e..ed799be 100644 --- a/src/listeners/suggestion-interaction.ts +++ b/src/listeners/suggestion-interaction.ts @@ -4,6 +4,7 @@ import { ModalBuilder, TextInputStyle, inlineCode, + MessageFlags, } from "discord.js"; import type { Listener } from "../types/listener.ts"; import { @@ -56,7 +57,7 @@ export default [ content: `You're missing the manager role and ${inlineCode( "ManageGuild", )} permission`, - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, }); } @@ -66,7 +67,7 @@ export default [ ) { return interaction.reply({ content: `You're missing the ${inlineCode("ManageGuild")} permission`, - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, }); } @@ -124,7 +125,7 @@ export default [ "this suggestion", interaction.message.url, )} to ${inlineCode(statusString.toLowerCase())}`, - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, }); }, }, @@ -154,7 +155,7 @@ export default [ "this", interaction.message.url, )} suggestion`, - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, }); } else { await suggestion.downvote(interaction.user.id, config); @@ -163,7 +164,7 @@ export default [ "this", interaction.message.url, )} suggestion`, - flags: "Ephemeral", + flags: MessageFlags.Ephemeral, }); } },