Skip to content

Commit

Permalink
💬 Add Message Type compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 6, 2024
1 parent 7f4d23b commit 27a76d5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
16 changes: 12 additions & 4 deletions plugins/plugin_base/src/discord/base/CustomResponse.ts
Original file line number Diff line number Diff line change
@@ -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<CacheType> | ModalSubmitInteraction<CacheType> | ButtonInteraction<CacheType> | StringSelectMenuInteraction<CacheType>
interaction: CommandInteraction<CacheType> | ModalSubmitInteraction<CacheType> | ButtonInteraction<CacheType> | StringSelectMenuInteraction<CacheType> | Message<boolean>
ephemeral?: boolean
element: string
color?: ColorResolvable
Expand Down Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions plugins/tickets/src/discord/base/CustomResponse.ts
Original file line number Diff line number Diff line change
@@ -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<CacheType> | ModalSubmitInteraction<CacheType> | ButtonInteraction<CacheType> | StringSelectMenuInteraction<CacheType>
interaction: CommandInteraction<CacheType> | ModalSubmitInteraction<CacheType> | ButtonInteraction<CacheType> | StringSelectMenuInteraction<CacheType> | Message<boolean>
ephemeral?: boolean
element: string
color?: ColorResolvable
Expand Down Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions plugins/utils/src/discord/base/CustomResponse.ts
Original file line number Diff line number Diff line change
@@ -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<CacheType> | ModalSubmitInteraction<CacheType> | ButtonInteraction<CacheType> | StringSelectMenuInteraction<CacheType>
interaction: CommandInteraction<CacheType> | ModalSubmitInteraction<CacheType> | ButtonInteraction<CacheType> | StringSelectMenuInteraction<CacheType> | Message<boolean>
ephemeral?: boolean
element: string
color?: ColorResolvable
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 27a76d5

Please sign in to comment.