Merge pull request #424 from VermiumSifell/dev

🧑‍💻 Fixed some more code smells again
This commit is contained in:
Axel Olausson Holtenäs 2022-10-14 13:05:34 +02:00 committed by GitHub
commit 363a5ef0cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 14 deletions

View file

@ -1,5 +1,5 @@
/* eslint-disable no-loops/no-loops */ /* 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 getEmbedConfig from "../../../helpers/getEmbedData";
import logger from "../../../middlewares/logger"; import logger from "../../../middlewares/logger";
import guildSchema from "../../../models/guild"; import guildSchema from "../../../models/guild";
@ -29,9 +29,10 @@ export default {
const channel = client.channels.cache.get(`${guildData.audits.channelId}`); 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({ .send({
embeds: [ embeds: [
new EmbedBuilder() new EmbedBuilder()
@ -52,13 +53,13 @@ export default {
}), }),
], ],
}) })
.then(async () => { .then(() => {
logger.info( logger.info(
`Audit log sent for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})` `Audit log sent for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})`
); );
}) })
.catch(async () => { .catch(() => {
logger.error( throw new Error(
`Audit log failed to send for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})` `Audit log failed to send for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})`
); );
}); });

View file

@ -1,6 +1,5 @@
// Dependencies // Dependencies
import { Message } from "discord.js"; import { Message } from "discord.js";
// Models // Models
import logger from "../../../../middlewares/logger"; import logger from "../../../../middlewares/logger";
import counterSchema from "../../../../models/counter"; import counterSchema from "../../../../models/counter";
@ -24,12 +23,12 @@ export default async (message: Message) => {
); );
await message await message
?.delete() .delete()
?.then(async () => { .then(async () => {
await channel?.send(`${author} said **${word}**.`); await channel?.send(`${author} said **${word}**.`);
logger?.silly(`${author} said ${word} in ${channel}`); logger?.silly(`${author} said ${word} in ${channel}`);
}) })
?.catch(async (error) => { .catch((error) => {
logger?.error(error); logger.error(error);
}); });
}; };

View file

@ -1,14 +1,14 @@
// Dependencies // Dependencies
import { Client } from "discord.js"; import { Client } from "discord.js";
import logger from "../../../middlewares/logger";
// Helpers // Helpers
import { IEventOptions } from "../../../interfaces/EventOptions"; import { IEventOptions } from "../../../interfaces/EventOptions";
import logger from "../../../middlewares/logger";
export const options: IEventOptions = { export const options: IEventOptions = {
type: "on", type: "on",
}; };
export const execute = async (client: Client) => { // Function to execute the event
export const execute = (client: Client) => {
logger.warn(`Discord's API client (${client?.user?.tag}) is rate-limited!`); logger.warn(`Discord's API client (${client?.user?.tag}) is rate-limited!`);
}; };