diff --git a/src/client/client.ts b/src/client/client.ts index ad575ec4..e082134b 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -56,7 +56,7 @@ export type LogAction = | "slashCommand" | "button" | "selectMenu" - | "modal" + | "modalSubmit" | "guildMemberUpdate" | "guildJoined"; @@ -64,7 +64,7 @@ export type LogData = Message | Guild | AnyInteraction; export type Log = { type: LogAction; - data: any; // technically LogData but TS breaks without this + data: any; // technically LogData but TS union type validation is painful }; export interface FaithfulGuild { @@ -84,9 +84,8 @@ export class ExtendedClient extends Client>(); public readonly buttons = new Collection>(); @@ -120,8 +119,8 @@ export class ExtendedClient extends Client { this.loadSlashCommands(); - this.loadComponents(); this.loadEvents(); + this.loadComponents(); this.loadCollections(); this.automation.start(); @@ -163,10 +162,14 @@ export class ExtendedClient extends Client extends Client( collection: EmittingCollection, @@ -211,7 +214,7 @@ export class ExtendedClient extends Client extends Client file.endsWith(".ts")); for (const file of events) { const event: Event = require(file).default; @@ -325,8 +329,8 @@ export class ExtendedClient extends Client extends Client this.maxLogs) this.logs.shift(); + this.logs.push({ type, data }); } } diff --git a/src/commands/faithful/discords.ts b/src/commands/faithful/discords.ts index 36b905ff..6dd0a3b4 100644 --- a/src/commands/faithful/discords.ts +++ b/src/commands/faithful/discords.ts @@ -1,8 +1,7 @@ import type { SlashCommand } from "@interfaces/interactions"; import { SlashCommandBuilder } from "discord.js"; -import { EmbedBuilder, Message } from "@client"; +import { Message } from "@client"; import axios from "axios"; -import { colors } from "@utility/colors"; import { FaithfulGuild } from "client/client"; import { toTitleCase } from "@utility/methods"; diff --git a/src/events/modalSubmit.ts b/src/events/modalSubmit.ts index d866ad7e..e58b7a9f 100644 --- a/src/events/modalSubmit.ts +++ b/src/events/modalSubmit.ts @@ -1,10 +1,9 @@ import type { Event } from "@interfaces/events"; -import { Client, ModalSubmitInteraction } from "@client"; export default { name: "modalSubmit", async execute(client, interaction) { - client.storeAction("modal", interaction); + client.storeAction("modalSubmit", interaction); const modal = client.modals.get(interaction.customId); if (modal) return modal.execute(client, interaction); diff --git a/src/events/selectMenuUsed.ts b/src/events/selectMenuUsed.ts index 17c8f9d9..f84a5f03 100644 --- a/src/events/selectMenuUsed.ts +++ b/src/events/selectMenuUsed.ts @@ -1,5 +1,4 @@ import type { Event } from "@interfaces/events"; -import { Client, StringSelectMenuInteraction } from "@client"; export default { name: "selectMenuUsed", diff --git a/src/helpers/functions/handleError.ts b/src/helpers/functions/handleError.ts index 6a470059..34fb154c 100644 --- a/src/helpers/functions/handleError.ts +++ b/src/helpers/functions/handleError.ts @@ -2,7 +2,6 @@ import { DiscordAPIError, AttachmentBuilder } from "discord.js"; import { Client } from "@client"; import { readFileSync } from "fs"; import { devLogger, err } from "@helpers/logger"; -import { Log } from "client/client"; import { join } from "path"; import { choice } from "@utility/methods"; import { error as randomSentences } from "@json/quotes.json"; @@ -20,7 +19,7 @@ const loopLimit = 3; // how many times the same error needs to be made to trigge */ export const constructLogFile = ( client: Client, - reason: any = { stack: "You requested it with /logs ¯\\_(ツ)_/¯" }, + reason: any = { stack: "Requested with /logs ¯\\_(ツ)_/¯" }, ): AttachmentBuilder => { const logTemplate = readFileSync(join(__dirname, "logTemplate.log"), { encoding: "utf-8", @@ -36,11 +35,12 @@ export const constructLogFile = ( .replace("%randomSentence%", sentence) .replace("%randomSentenceUnderline%", "-".repeat(sentence.length)) .split("%templateStart%")[0] + - client.logs.reverse().reduce( - (acc, log: Log, index) => + // reduceRight does reduce and reverse at once + client.logs.reduceRight( + (acc, log, index) => acc + template - .replace("%templateIndex%", `${client.logs.length - index}`) + .replace("%templateIndex%", String(index)) .replace("%templateType%", formatLogType(log)) .replace( "%templateCreatedTimestamp%", @@ -53,10 +53,6 @@ export const constructLogFile = ( })} (UTC)`, ) .replace("%templateURL%", formatLogURL(log.data)) - .replace( - "%templateChannelType%", - log.data.channel ? log.data.channel.type : "Not relevant", - ) .replace("%templateContent%", formatLogContent(log)) .replace( "%templateEmbeds%", diff --git a/src/helpers/functions/logTemplate.log b/src/helpers/functions/logTemplate.log index 2cc8605e..d065992b 100644 --- a/src/helpers/functions/logTemplate.log +++ b/src/helpers/functions/logTemplate.log @@ -13,7 +13,6 @@ Actions: TYPE : %templateType% TIMESTAMP : %templateCreatedTimestamp% URL : %templateURL% - CHANNEL_TYPE : %templateChannelType% CONTENT : %templateContent% EMBEDS : %templateEmbeds% COMPONENTS : %templateComponents%