diff --git a/core/components/DiscordBot/commands/status.ts b/core/components/DiscordBot/commands/status.ts index a5cba29e0..e8ac30d43 100644 --- a/core/components/DiscordBot/commands/status.ts +++ b/core/components/DiscordBot/commands/status.ts @@ -229,10 +229,10 @@ export const removeOldEmbed = async (interaction: ChatInputCommandInteraction, t const oldMessageId = txAdmin.persistentCache.get('discord:status:messageId'); if (typeof oldChannelId === 'string' && typeof oldMessageId === 'string') { const oldChannel = await interaction.client.channels.fetch(oldChannelId); - if (oldChannel?.type === ChannelType.GuildText) { + if (oldChannel?.type === ChannelType.GuildText || oldChannel?.type === ChannelType.GuildAnnouncement) { await oldChannel.messages.delete(oldMessageId); } else { - throw new Error(`oldChannel is not a guild text channel`); + throw new Error(`oldChannel is not a guild text or announcement channel`); } } else { throw new Error(`no old message id saved, maybe was never sent, maybe it was removed`); @@ -275,7 +275,7 @@ export default async (interaction: ChatInputCommandInteraction, txAdmin: TxAdmin //Attempt to send new message try { - if (interaction.channel?.type !== ChannelType.GuildText) throw new Error(`channel type not supported`); + if (!(interaction.channel?.type == ChannelType.GuildText || interaction.channel?.type == ChannelType.GuildAnnouncement)) throw new Error(`channel type not supported`); const placeholderEmbed = new EmbedBuilder({ description: '_placeholder message, attempting to edit with embed..._\n**Note:** If you are seeing this message, it probably means that something was wrong with the configured Embed JSONs and Discord\'s API rejected the request to replace this placeholder.' }) diff --git a/core/components/DiscordBot/index.ts b/core/components/DiscordBot/index.ts index 59a8cb0b4..1fd590716 100644 --- a/core/components/DiscordBot/index.ts +++ b/core/components/DiscordBot/index.ts @@ -152,7 +152,7 @@ export default class DiscordBot { if (typeof oldChannelId === 'string' && typeof oldMessageId === 'string') { const oldChannel = await this.#client.channels.fetch(oldChannelId); if (!oldChannel) throw new Error(`oldChannel could not be resolved`); - if (oldChannel.type !== ChannelType.GuildText) throw new Error(`oldChannel is not guild text channel`); + if (!(oldChannel.type == ChannelType.GuildText || oldChannel.type == ChannelType.GuildAnnouncement)) throw new Error(`oldChannel is not guild text or annoucement channel`); await oldChannel.messages.edit(oldMessageId, generateStatusMessage(this.#txAdmin)); } @@ -205,8 +205,8 @@ export default class DiscordBot { const fetchedChannel = this.#client.channels.cache.find((x) => x.id === this.config.announceChannel); if (!fetchedChannel) { return sendError(`Channel ${this.config.announceChannel} not found.`); - } else if (fetchedChannel.type !== ChannelType.GuildText) { - return sendError(`Channel ${this.config.announceChannel} - ${(fetchedChannel as any)?.name} is not a text channel.`); + } else if (!(fetchedChannel.type == ChannelType.GuildText || fetchedChannel.type == ChannelType.GuildAnnouncement)) { + return sendError(`Channel ${this.config.announceChannel} - ${(fetchedChannel as any)?.name} is not a text or annoucement channel.`); } else { this.announceChannel = fetchedChannel; }