diff --git a/src/plugins/events/messageUpdate/audits.ts b/src/plugins/events/messageUpdate/audits.ts index 81ab688..263bf5e 100644 --- a/src/plugins/events/messageUpdate/audits.ts +++ b/src/plugins/events/messageUpdate/audits.ts @@ -1,5 +1,5 @@ /* eslint-disable no-loops/no-loops */ -import { EmbedBuilder, Message, TextChannel } from "discord.js"; +import { ChannelType, EmbedBuilder, Message } from "discord.js"; import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; import guildSchema from "../../../models/guild"; @@ -29,9 +29,10 @@ export default { const channel = client.channels.cache.get(`${guildData.audits.channelId}`); - if (channel === null) return; + if (!channel) return; + if (channel.type !== ChannelType.GuildText) return; - (channel as TextChannel) + channel .send({ embeds: [ new EmbedBuilder() @@ -52,13 +53,13 @@ export default { }), ], }) - .then(async () => { + .then(() => { logger.info( `Audit log sent for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})` ); }) - .catch(async () => { - logger.error( + .catch(() => { + throw new Error( `Audit log failed to send for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})` ); }); diff --git a/src/plugins/events/messageUpdate/modules/counter.ts b/src/plugins/events/messageUpdate/modules/counter.ts index b969358..f0ed934 100644 --- a/src/plugins/events/messageUpdate/modules/counter.ts +++ b/src/plugins/events/messageUpdate/modules/counter.ts @@ -1,6 +1,5 @@ // Dependencies import { Message } from "discord.js"; - // Models import logger from "../../../../middlewares/logger"; import counterSchema from "../../../../models/counter"; @@ -24,12 +23,12 @@ export default async (message: Message) => { ); await message - ?.delete() - ?.then(async () => { + .delete() + .then(async () => { await channel?.send(`${author} said **${word}**.`); logger?.silly(`${author} said ${word} in ${channel}`); }) - ?.catch(async (error) => { - logger?.error(error); + .catch((error) => { + logger.error(error); }); }; diff --git a/src/plugins/events/rateLimit/index.ts b/src/plugins/events/rateLimit/index.ts index a96b144..36ade47 100644 --- a/src/plugins/events/rateLimit/index.ts +++ b/src/plugins/events/rateLimit/index.ts @@ -1,14 +1,13 @@ // Dependencies import { Client } from "discord.js"; -import logger from "../../../middlewares/logger"; - // Helpers import { IEventOptions } from "../../../interfaces/EventOptions"; +import logger from "../../../middlewares/logger"; export const options: IEventOptions = { type: "on", }; -export const execute = async (client: Client) => { +export const execute = (client: Client) => { logger.warn(`Discord's API client (${client?.user?.tag}) is rate-limited!`); };