From 27a76d5d9aa3b66a0ef28e7eba7c75289e1a6b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A7=81Ash=C3=BB=EA=A7=82?= <30575805+Ashu11-A@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:37:06 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AC=20Add=20Message=20Type=20compatibi?= =?UTF-8?q?lity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/discord/base/CustomResponse.ts | 16 ++++++++++++---- .../tickets/src/discord/base/CustomResponse.ts | 16 ++++++++++++---- plugins/utils/src/discord/base/CustomResponse.ts | 16 ++++++++++++---- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/plugins/plugin_base/src/discord/base/CustomResponse.ts b/plugins/plugin_base/src/discord/base/CustomResponse.ts index f514174e..3058968e 100644 --- a/plugins/plugin_base/src/discord/base/CustomResponse.ts +++ b/plugins/plugin_base/src/discord/base/CustomResponse.ts @@ -1,8 +1,8 @@ -import { ButtonInteraction, CacheType, ColorResolvable, CommandInteraction, EmbedBuilder, MessageComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js" +import { ButtonInteraction, CacheType, ColorResolvable, CommandInteraction, EmbedBuilder, Message, MessageComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js" interface ErrorOptions { - interaction: CommandInteraction | ModalSubmitInteraction | ButtonInteraction | StringSelectMenuInteraction + interaction: CommandInteraction | ModalSubmitInteraction | ButtonInteraction | StringSelectMenuInteraction | Message ephemeral?: boolean element: string color?: ColorResolvable @@ -63,12 +63,20 @@ export class Error { const { interaction, ephemeral } = this.options if (this.embed === undefined) return - if (interaction.isRepliable() && !interaction.replied) { + if (!(interaction instanceof Message) && interaction.isRepliable() && !interaction.replied) { + console.log(interaction.deferred) if (interaction.deferred) { await interaction.editReply({ embeds: [this.embed] }) return } - if (!interaction.replied) {await interaction.reply({ embeds: [this.embed], ephemeral: ephemeral ?? true }); return} + if (!interaction.replied) { + await interaction.reply({ embeds: [this.embed], ephemeral: ephemeral ?? true }) + .catch(async (err) => { + console.log(err) + return await interaction.editReply({ embeds: [this.embed as EmbedBuilder] }) + }) + return + } if (interaction instanceof MessageComponentInteraction) { await interaction.update({ embeds: [this.embed], components: [] }) return diff --git a/plugins/tickets/src/discord/base/CustomResponse.ts b/plugins/tickets/src/discord/base/CustomResponse.ts index f514174e..3058968e 100644 --- a/plugins/tickets/src/discord/base/CustomResponse.ts +++ b/plugins/tickets/src/discord/base/CustomResponse.ts @@ -1,8 +1,8 @@ -import { ButtonInteraction, CacheType, ColorResolvable, CommandInteraction, EmbedBuilder, MessageComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js" +import { ButtonInteraction, CacheType, ColorResolvable, CommandInteraction, EmbedBuilder, Message, MessageComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js" interface ErrorOptions { - interaction: CommandInteraction | ModalSubmitInteraction | ButtonInteraction | StringSelectMenuInteraction + interaction: CommandInteraction | ModalSubmitInteraction | ButtonInteraction | StringSelectMenuInteraction | Message ephemeral?: boolean element: string color?: ColorResolvable @@ -63,12 +63,20 @@ export class Error { const { interaction, ephemeral } = this.options if (this.embed === undefined) return - if (interaction.isRepliable() && !interaction.replied) { + if (!(interaction instanceof Message) && interaction.isRepliable() && !interaction.replied) { + console.log(interaction.deferred) if (interaction.deferred) { await interaction.editReply({ embeds: [this.embed] }) return } - if (!interaction.replied) {await interaction.reply({ embeds: [this.embed], ephemeral: ephemeral ?? true }); return} + if (!interaction.replied) { + await interaction.reply({ embeds: [this.embed], ephemeral: ephemeral ?? true }) + .catch(async (err) => { + console.log(err) + return await interaction.editReply({ embeds: [this.embed as EmbedBuilder] }) + }) + return + } if (interaction instanceof MessageComponentInteraction) { await interaction.update({ embeds: [this.embed], components: [] }) return diff --git a/plugins/utils/src/discord/base/CustomResponse.ts b/plugins/utils/src/discord/base/CustomResponse.ts index f514174e..3058968e 100644 --- a/plugins/utils/src/discord/base/CustomResponse.ts +++ b/plugins/utils/src/discord/base/CustomResponse.ts @@ -1,8 +1,8 @@ -import { ButtonInteraction, CacheType, ColorResolvable, CommandInteraction, EmbedBuilder, MessageComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js" +import { ButtonInteraction, CacheType, ColorResolvable, CommandInteraction, EmbedBuilder, Message, MessageComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js" interface ErrorOptions { - interaction: CommandInteraction | ModalSubmitInteraction | ButtonInteraction | StringSelectMenuInteraction + interaction: CommandInteraction | ModalSubmitInteraction | ButtonInteraction | StringSelectMenuInteraction | Message ephemeral?: boolean element: string color?: ColorResolvable @@ -63,12 +63,20 @@ export class Error { const { interaction, ephemeral } = this.options if (this.embed === undefined) return - if (interaction.isRepliable() && !interaction.replied) { + if (!(interaction instanceof Message) && interaction.isRepliable() && !interaction.replied) { + console.log(interaction.deferred) if (interaction.deferred) { await interaction.editReply({ embeds: [this.embed] }) return } - if (!interaction.replied) {await interaction.reply({ embeds: [this.embed], ephemeral: ephemeral ?? true }); return} + if (!interaction.replied) { + await interaction.reply({ embeds: [this.embed], ephemeral: ephemeral ?? true }) + .catch(async (err) => { + console.log(err) + return await interaction.editReply({ embeds: [this.embed as EmbedBuilder] }) + }) + return + } if (interaction instanceof MessageComponentInteraction) { await interaction.update({ embeds: [this.embed], components: [] }) return