Skip to content

Commit

Permalink
fix(bot): reverted comparison type safety
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Mar 12, 2023
1 parent 2f7d8eb commit 7dc97fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion core/components/DiscordBot/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ export default async (interaction: ChatInputCommandInteraction, txAdmin: TxAdmin

//Attempt to send new message
try {
if (!(interaction.channel?.type == ChannelType.GuildText || interaction.channel?.type == ChannelType.GuildAnnouncement)) 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: 4 additions & 2 deletions core/components/DiscordBot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ 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 || oldChannel.type == ChannelType.GuildAnnouncement)) throw new Error(`oldChannel is not guild text or annoucement 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,7 +207,7 @@ 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 || fetchedChannel.type == ChannelType.GuildAnnouncement)) {
} 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 7dc97fb

Please sign in to comment.