Skip to content

Commit

Permalink
how has this not been an issue earlier
Browse files Browse the repository at this point in the history
This reverts commit 515c411.
  • Loading branch information
3vorp committed Oct 11, 2023
1 parent 515c411 commit 91201e6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/client/automation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Automation {
if (!this.ticking) return;

// polls check:
this.client.polls.each(this.pollCheck);
this.client.polls.each(this.pollCheck.bind(null, this));
}, 1000); // each second

// send to uptime kuma (only for production bot)
Expand All @@ -34,7 +34,7 @@ export class Automation {
}
}

private pollCheck(p: Poll): void {
private pollCheck(p: Poll) {
const poll = new Poll(p); // get methods back

if (poll.isTimeout()) {
Expand Down
2 changes: 2 additions & 0 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions src/commands/bot/shutdown.ts
Original file line number Diff line number Diff line change
@@ -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();
},
};
2 changes: 1 addition & 1 deletion src/helpers/functions/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/utility/handleJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 91201e6

Please sign in to comment.