Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/GJSBRT/txAdmin into GJSBR…
Browse files Browse the repository at this point in the history
…T-master
  • Loading branch information
tabarra committed Mar 12, 2023
2 parents 210c53e + 671e01d commit 2f7d8eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions core/components/DiscordBot/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -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.'
})
Expand Down
6 changes: 3 additions & 3 deletions core/components/DiscordBot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2f7d8eb

Please sign in to comment.