From 4bd8b1f2b3e579683677172a76ac0c20b6308262 Mon Sep 17 00:00:00 2001 From: Evorp <3vorpgaming@gmail.com> Date: Wed, 11 Oct 2023 15:24:12 -0700 Subject: [PATCH] fix poll bug maybe --- src/client/automation.ts | 4 ++-- src/client/client.ts | 2 ++ src/commands/bot/shutdown.ts | 17 +++++++++++++++++ src/helpers/functions/errorHandler.ts | 2 +- src/helpers/utility/handleJSON.ts | 2 +- 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/commands/bot/shutdown.ts diff --git a/src/client/automation.ts b/src/client/automation.ts index 972e6843a..6cdb38a3a 100644 --- a/src/client/automation.ts +++ b/src/client/automation.ts @@ -34,12 +34,12 @@ export class Automation { } } - private pollCheck(p: Poll): void { + private pollCheck(p: Poll) { const poll = new Poll(p); // get methods back if (poll.isTimeout()) { poll.setStatus("ended"); - poll.updateEmbed(this.client).then(() => this.client.polls.delete(poll.id)); + poll.updateEmbed(this.client).then(() => this.client.polls.delete(poll.id)).catch(() => {}); } } } diff --git a/src/client/client.ts b/src/client/client.ts index ea1ad12ba..74a558a8c 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -126,6 +126,8 @@ export class ExtendedClient extends Client { this.loadComponents(); this.loadEvents(); this.loadCollections(); + + this.automation.start(); }); // I know this restarting stuff kinda sucks but you can't guarantee which one is triggered diff --git a/src/commands/bot/shutdown.ts b/src/commands/bot/shutdown.ts new file mode 100644 index 000000000..2cd310fcc --- /dev/null +++ b/src/commands/bot/shutdown.ts @@ -0,0 +1,17 @@ +import { SlashCommand } from "@interfaces"; +import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"; +import { ChatInputCommandInteraction, EmbedBuilder } from "@client"; + +export const command: SlashCommand = { + data: new SlashCommandBuilder() + .setName("shutdown") + .setDescription("Shuts down the bot.") + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + async execute(interaction: ChatInputCommandInteraction) { + if (!interaction.hasPermission("dev")) return; + await interaction.reply({ + embeds: [new EmbedBuilder().setTitle("Shutting down...")], + }); + return process.exit(); + }, +}; diff --git a/src/helpers/functions/errorHandler.ts b/src/helpers/functions/errorHandler.ts index aa3b133f9..c8a70ecc3 100644 --- a/src/helpers/functions/errorHandler.ts +++ b/src/helpers/functions/errorHandler.ts @@ -123,7 +123,7 @@ export async function errorHandler(client: Client, error: any, type: string) { let eprotoError = false; let description = error.stack; - let codeBlocks = ""; + let codeBlocks = " "; if (error.isAxiosError) { // axios errors are JSON diff --git a/src/helpers/utility/handleJSON.ts b/src/helpers/utility/handleJSON.ts index 84b72b9c1..7c2973f2c 100644 --- a/src/helpers/utility/handleJSON.ts +++ b/src/helpers/utility/handleJSON.ts @@ -43,7 +43,7 @@ export function getData(options: GetOptions) { * @param options data to set */ export function setData(options: SetOptions) { - let folder = path.resolve(__dirname, options.relative_path); + const folder = path.resolve(__dirname, options.relative_path); const file = path.resolve(folder, options.filename); try {