map and move interaction handlers
This commit is contained in:
9 files changed
+622
-584
No files matched your search
@@ -6,7 +6,6 @@ const mongoose = require('mongoose');
|
||||
const Logger = require("../util/Logger");
|
||||
const path = require("path");
|
||||
const fs = require('fs');
|
||||
const { exit } = require("process");
|
||||
|
||||
class QuarksBot extends Client {
|
||||
|
||||
@@ -15,6 +14,7 @@ class QuarksBot extends Client {
|
||||
|
||||
this.config = config;
|
||||
this.commands = new Collection();
|
||||
this.interactionHandlers = new Collection();
|
||||
this.logger = new Logger(path.join(__dirname, "..", "logs/Logs.log"));
|
||||
|
||||
if (this.config.Token === "")
|
||||
@@ -25,7 +25,7 @@ class QuarksBot extends Client {
|
||||
this.db;
|
||||
this.dbo;
|
||||
this.connectMongo(this.config.mongoURI, this.config.dbo);
|
||||
this.LoadCommands();
|
||||
this.LoadCommandsAndInteractionHandlers();
|
||||
this.LoadEvents();
|
||||
|
||||
this.Ready = false;
|
||||
@@ -56,12 +56,7 @@ class QuarksBot extends Client {
|
||||
try {
|
||||
cmd.SlashCommand.run(this, interaction, args, { GuildDB }, start); // start is only used in ping / stats command
|
||||
} catch (err) {
|
||||
client.error(err)
|
||||
const embed = new EmbedBuilder()
|
||||
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor(client.config.Colors.Red)
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
this.sendInternalError(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -98,7 +93,7 @@ class QuarksBot extends Client {
|
||||
return dDisplay + hDisplay + mDisplay + sDisplay;
|
||||
}
|
||||
|
||||
LoadCommands() {
|
||||
LoadCommandsAndInteractionHandlers() {
|
||||
let CommandsDir = path.join(__dirname, '..', 'commands');
|
||||
fs.readdir(CommandsDir, (err, files) => {
|
||||
if (err) this.error(err);
|
||||
@@ -112,6 +107,11 @@ class QuarksBot extends Client {
|
||||
", Reason: File doesn't had name/desciption"
|
||||
);
|
||||
this.commands.set(file.split(".")[0].toLowerCase(), cmd);
|
||||
if (this.exists(cmd.Interactions)) {
|
||||
for (let [interaction, handler] of Object.entries(cmd.Interactions)) {
|
||||
this.interactionHandlers.set(interaction, handler);
|
||||
}
|
||||
}
|
||||
this.log("Command Loaded: " + file.split(".")[0]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user