From 1d37a586f8e70e0e88a8e1cfd7f1c8f7d1ce6649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=82=A6=C5=82=E2=82=B5=E2=82=AD=20=20=E2=82=A3=C9=84?= =?UTF-8?q?=E2=B1=A4=C9=8E?= <96591657+NICK-FURY-6023@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:03:41 +0000 Subject: [PATCH] fix: replace deprecated ephemeral option with MessageFlags.Ephemeral - Fixed deprecation warning for ephemeral interaction responses - Replaced ephemeral: true with flags: MessageFlags.Ephemeral - Replaced CommandInteraction with ChatInputCommandInteraction for proper typing - Removed unnecessary ephemeral: false (default value) --- src/buttons/Queue.ts | 3 ++- src/buttons/Shuffle.ts | 3 ++- src/commands/Music/Insert.ts | 4 ++-- src/commands/Music/Play.ts | 4 ++-- src/commands/Music/Radio.ts | 3 ++- src/commands/Playlist/Add.ts | 4 ++-- src/commands/Playlist/Editor.ts | 8 ++++---- src/events/guild/messageCreate.ts | 5 ++++- src/events/track/trackStart.ts | 6 +++--- src/services/ReplyInteractionService.ts | 3 +-- src/structures/CommandHandler.ts | 2 +- src/structures/PageQueue.ts | 3 ++- 12 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/buttons/Queue.ts b/src/buttons/Queue.ts index a59cae5b..2b6aad76 100644 --- a/src/buttons/Queue.ts +++ b/src/buttons/Queue.ts @@ -4,6 +4,7 @@ import { EmbedBuilder, InteractionCollector, Message, + MessageFlags, } from 'discord.js' import { PlayerButton } from '../@types/Button.js' import { Manager } from '../manager.js' @@ -72,6 +73,6 @@ export default class implements PlayerButton { pages.push(embed) } - message.reply({ embeds: [pages[0]], ephemeral: true }) + message.reply({ embeds: [pages[0]], flags: MessageFlags.Ephemeral }) } } diff --git a/src/buttons/Shuffle.ts b/src/buttons/Shuffle.ts index 2a28d745..285729ec 100644 --- a/src/buttons/Shuffle.ts +++ b/src/buttons/Shuffle.ts @@ -4,6 +4,7 @@ import { EmbedBuilder, InteractionCollector, Message, + MessageFlags, User, } from 'discord.js' import { PlayerButton } from '../@types/Button.js' @@ -104,6 +105,6 @@ export default class implements PlayerButton { message, qduration ) - } else message.reply({ embeds: [pages[0]], ephemeral: true }) + } else message.reply({ embeds: [pages[0]], flags: MessageFlags.Ephemeral }) } } diff --git a/src/commands/Music/Insert.ts b/src/commands/Music/Insert.ts index 363068d1..30a110cf 100644 --- a/src/commands/Music/Insert.ts +++ b/src/commands/Music/Insert.ts @@ -1,7 +1,7 @@ import { ApplicationCommandOptionType, AutocompleteInteraction, - CommandInteraction, + ChatInputCommandInteraction, EmbedBuilder, } from 'discord.js' import { Manager } from '../../manager.js' @@ -133,7 +133,7 @@ export default class implements Command { // Autocomplete function async autocomplete(client: Manager, interaction: GlobalInteraction, language: string) { let choice: AutocompleteInteractionChoices[] = [] - const url = String((interaction as CommandInteraction).options.get('search')!.value) + const url = String((interaction as ChatInputCommandInteraction).options.get('search')!.value) const Random = client.config.player.AUTOCOMPLETE_SEARCH[ diff --git a/src/commands/Music/Play.ts b/src/commands/Music/Play.ts index 31461f26..0ad68eff 100644 --- a/src/commands/Music/Play.ts +++ b/src/commands/Music/Play.ts @@ -1,7 +1,7 @@ import { ApplicationCommandOptionType, AutocompleteInteraction, - CommandInteraction, + ChatInputCommandInteraction, EmbedBuilder, } from 'discord.js' import { convertTime } from '../../utilities/ConvertTime.js' @@ -183,7 +183,7 @@ export default class implements Command { // Autocomplete function async autocomplete(client: Manager, interaction: GlobalInteraction, language: string) { let choice: AutocompleteInteractionChoices[] = [] - const url = String((interaction as CommandInteraction).options.get('search')!.value) + const url = String((interaction as ChatInputCommandInteraction).options.get('search')!.value) const maxLength = await client.db.maxlength.get(interaction.user.id) diff --git a/src/commands/Music/Radio.ts b/src/commands/Music/Radio.ts index d89c18b9..de0fbac0 100644 --- a/src/commands/Music/Radio.ts +++ b/src/commands/Music/Radio.ts @@ -3,6 +3,7 @@ import { ApplicationCommandOptionType, ComponentType, EmbedBuilder, + MessageFlags, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, } from 'discord.js' @@ -165,7 +166,7 @@ export default class implements Command { const msgReply = await message .reply({ embeds: [replyEmbed], - ephemeral: true, + flags: MessageFlags.Ephemeral, }) .catch(() => {}) if (msgReply) diff --git a/src/commands/Playlist/Add.ts b/src/commands/Playlist/Add.ts index 1c8bb549..6951e2d2 100644 --- a/src/commands/Playlist/Add.ts +++ b/src/commands/Playlist/Add.ts @@ -1,7 +1,7 @@ import { EmbedBuilder, ApplicationCommandOptionType, - CommandInteraction, + ChatInputCommandInteraction, AutocompleteInteraction, } from 'discord.js' import { convertTime } from '../../utilities/ConvertTime.js' @@ -220,7 +220,7 @@ export default class implements Command { // Autocomplete function public async autocomplete(client: Manager, interaction: GlobalInteraction, language: string) { let choice: AutocompleteInteractionChoices[] = [] - const url = String((interaction as CommandInteraction).options.get('search')!.value) + const url = String((interaction as ChatInputCommandInteraction).options.get('search')!.value) const maxLength = await client.db.maxlength.get(interaction.user.id) diff --git a/src/commands/Playlist/Editor.ts b/src/commands/Playlist/Editor.ts index 3e04bba8..557d7e74 100644 --- a/src/commands/Playlist/Editor.ts +++ b/src/commands/Playlist/Editor.ts @@ -2,7 +2,7 @@ import { EmbedBuilder, ApplicationCommandOptionType, Message, - CommandInteraction, + ChatInputCommandInteraction, ActionRowBuilder, TextInputBuilder, ModalBuilder, @@ -42,7 +42,7 @@ export default class implements Command { if (handler.message) { await this.prefixMode(client, handler.message, handler.args, handler.language, handler.prefix) } else if (handler.interaction) { - await this.interactionMode(client, handler.interaction, handler.language) + await this.interactionMode(client, handler.interaction as ChatInputCommandInteraction, handler.language) } else return } @@ -259,7 +259,7 @@ export default class implements Command { // Interaction mode private async interactionMode( client: Manager, - interaction: CommandInteraction, + interaction: ChatInputCommandInteraction, language: string ) { const playlistId = new TextInputBuilder() @@ -314,7 +314,7 @@ export default class implements Command { new ActionRowBuilder().addComponents(playlistPrivate) ) - const value = (interaction.options as CommandInteractionOptionResolver).getString('id') + const value = (interaction as ChatInputCommandInteraction).options.getString('id') const playlist = await client.db.playlist.get(value!) diff --git a/src/events/guild/messageCreate.ts b/src/events/guild/messageCreate.ts index b18c7aef..776d82b4 100644 --- a/src/events/guild/messageCreate.ts +++ b/src/events/guild/messageCreate.ts @@ -113,7 +113,10 @@ export default class { return } const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - const prefixRegex = new RegExp(`^(<@!?${client.user!.id}>|${escapeRegex(PREFIX.toLowerCase())})\\s*`, 'i') + const prefixRegex = new RegExp( + `^(<@!?${client.user!.id}>|${escapeRegex(PREFIX.toLowerCase())})\\s*`, + 'i' + ) if (!prefixRegex.test(message.content)) return const [matchedPrefix] = message.content.match(prefixRegex) as RegExpMatchArray const args = message.content.slice(matchedPrefix.length).trim().split(/ +/g) diff --git a/src/events/track/trackStart.ts b/src/events/track/trackStart.ts index a651f57d..bc9e65a6 100644 --- a/src/events/track/trackStart.ts +++ b/src/events/track/trackStart.ts @@ -1,5 +1,5 @@ import { Manager } from '../../manager.js' -import { ComponentType, TextChannel } from 'discord.js' +import { ComponentType, TextChannel, MessageFlags } from 'discord.js' import { EmbedBuilder } from 'discord.js' import { formatDuration } from '../../utilities/FormatDuration.js' import { filterSelect, playerRowOne, playerRowTwo } from '../../utilities/PlayerControlButton.js' @@ -142,7 +142,7 @@ export default class { else { message.reply({ content: `${client.i18n.get(language, 'event.player', 'join_voice')}`, - ephemeral: true, + flags: MessageFlags.Ephemeral, }) return false } @@ -160,7 +160,7 @@ export default class { else { message.reply({ content: `${client.i18n.get(language, 'event.player', 'join_voice')}`, - ephemeral: true, + flags: MessageFlags.Ephemeral, }) return false } diff --git a/src/services/ReplyInteractionService.ts b/src/services/ReplyInteractionService.ts index 990faf4f..47e00aa0 100644 --- a/src/services/ReplyInteractionService.ts +++ b/src/services/ReplyInteractionService.ts @@ -16,13 +16,12 @@ export class ReplyInteractionService { const msg = await this.message .reply({ embeds: [embed], - ephemeral: false, }) .catch(() => null) const setup = await this.client.db.setup.get(String(this.message.guildId)) setTimeout(() => { - (!setup || setup == null || setup.channel !== this.message.channelId) && msg + ;(!setup || setup == null || setup.channel !== this.message.channelId) && msg ? msg.delete().catch(() => null) : true }, this.client.config.utilities.DELETE_MSG_TIMEOUT) diff --git a/src/structures/CommandHandler.ts b/src/structures/CommandHandler.ts index d32307e8..5d3ad408 100644 --- a/src/structures/CommandHandler.ts +++ b/src/structures/CommandHandler.ts @@ -138,7 +138,7 @@ export class CommandHandler { public async deferReply() { if (this.interaction) { - const data = await this.interaction.deferReply({ ephemeral: false }) + const data = await this.interaction.deferReply() return (this.msg = data) } else { const data = await this.message?.reply(`**${this.client.user?.username}** is thinking...`) diff --git a/src/structures/PageQueue.ts b/src/structures/PageQueue.ts index e0ea238b..6c1c0167 100644 --- a/src/structures/PageQueue.ts +++ b/src/structures/PageQueue.ts @@ -7,6 +7,7 @@ import { ComponentType, EmbedBuilder, Message, + MessageFlags, } from 'discord.js' import { Manager } from '../manager.js' @@ -425,7 +426,7 @@ export class PageQueue { ], components: [row], allowedMentions: { repliedUser: false }, - ephemeral: true, + flags: MessageFlags.Ephemeral, }) if (this.pages.length == 0) return