Updated structures
This commit is contained in:
1 parent
3a39b05fe4
commit
ba38bce1da
3 files changed
+82
-86
No files matched your search
+10
-11
@@ -5,20 +5,19 @@ const fs = require("fs");
|
|||||||
|
|
||||||
const Discord = require("discord.js");
|
const Discord = require("discord.js");
|
||||||
|
|
||||||
const yaml = require('js-yaml');
|
const yaml = require("js-yaml");
|
||||||
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8'));
|
const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
|
||||||
|
|
||||||
function RunFunction(message, args, client) {}
|
function RunFunction(interaction) {}
|
||||||
|
|
||||||
class Addon {
|
class Addon {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.name = options.name;
|
this.name = options.name;
|
||||||
this.description = options.description;
|
this.description = options.description;
|
||||||
this.permission = options.permission;
|
this.permission = options.permission;
|
||||||
this.type = ["BOTH", "SLASH", "TEXT"].includes(options.type) ? options.type : "TEXT";
|
this.slashCommandOptions = options.slashCommandOptions || [];
|
||||||
this.slashCommandOptions = options.slashCommandOptions || [];
|
this.run = options.run;
|
||||||
this.run = options.run;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Addon;
|
module.exports = Addon;
|
||||||
+62
-64
@@ -8,96 +8,94 @@ const Command = require("./Command.js");
|
|||||||
const Event = require("./Event.js");
|
const Event = require("./Event.js");
|
||||||
const intents = new Discord.Intents(32767);
|
const intents = new Discord.Intents(32767);
|
||||||
|
|
||||||
const yaml = require('js-yaml');
|
const yaml = require("js-yaml");
|
||||||
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8'));
|
const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
|
||||||
|
|
||||||
class Client extends Discord.Client {
|
class Client extends Discord.Client {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({ intents });
|
super({ intents });
|
||||||
|
|
||||||
this.commands = new Discord.Collection();
|
this.commands = new Discord.Collection();
|
||||||
|
|
||||||
this.prefix = supportbot.Prefix;
|
this.prefix = supportbot.Prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
start(token) {
|
start(token) {
|
||||||
const commandFiles = fs.readdirSync("./Commands")
|
const commandFiles = fs
|
||||||
.filter(file => file.endsWith(".js"));
|
.readdirSync("./Commands")
|
||||||
|
.filter((file) => file.endsWith(".js"));
|
||||||
|
|
||||||
const commands = commandFiles.map(file => require(`../Commands/${file}`));
|
const commands = commandFiles.map((file) => require(`../Commands/${file}`));
|
||||||
|
|
||||||
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬')
|
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
|
||||||
|
|
||||||
commands.forEach(cmd => {
|
commands.forEach((cmd) => {
|
||||||
console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, 'Loaded');
|
console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, "Loaded");
|
||||||
this.commands.set(cmd.name, cmd);
|
this.commands.set(cmd.name, cmd);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬')
|
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬");
|
||||||
|
|
||||||
// Addons
|
// Addons
|
||||||
|
|
||||||
const addonFiles = fs.readdirSync("./Addons")
|
const addonFiles = fs
|
||||||
.filter(file => file.endsWith(".js"));
|
.readdirSync("./Addons")
|
||||||
|
.filter((file) => file.endsWith(".js"));
|
||||||
|
|
||||||
const addons = addonFiles.map(file => require(`../Addons/${file}`));
|
const addons = addonFiles.map((file) => require(`../Addons/${file}`));
|
||||||
|
|
||||||
console.log(' ')
|
console.log(" ");
|
||||||
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬')
|
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
|
||||||
|
|
||||||
addons.forEach(addon => {
|
addons.forEach((addon) => {
|
||||||
console.log(`\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, 'Loaded');
|
console.log(`\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, "Loaded");
|
||||||
this.commands.set(addon.name, addon);
|
this.commands.set(addon.name, addon);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬')
|
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬");
|
||||||
console.log(' ')
|
console.log(" ");
|
||||||
|
|
||||||
// Slash Commands
|
// Slash Commands
|
||||||
|
|
||||||
const slashCommands = commands
|
const slashCommands = commands.map((cmd) => ({
|
||||||
.filter(cmd => ["BOTH", "SLASH"].includes(cmd.type))
|
name: cmd.name.toLowerCase(),
|
||||||
.map(cmd => ({
|
description: cmd.description,
|
||||||
name: cmd.name.toLowerCase(),
|
permissions: [],
|
||||||
description: cmd.description,
|
options: cmd.slashCommandOptions,
|
||||||
permissions: [],
|
defaultPermission: true,
|
||||||
options: cmd.slashCommandOptions,
|
}));
|
||||||
defaultPermission: true
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.removeAllListeners();
|
this.removeAllListeners();
|
||||||
|
|
||||||
this.on("ready", async () => {
|
this.on("ready", async () => {
|
||||||
const cmds = await this.application.commands.set(slashCommands);
|
const cmds = await this.application?.commands.set(slashCommands);
|
||||||
|
|
||||||
console.log(' ')
|
console.log(" ");
|
||||||
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬'),
|
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬"),
|
||||||
console.log(' ')
|
console.log(" ");
|
||||||
|
|
||||||
cmds.forEach(cmd =>
|
cmds.forEach((cmd) =>
|
||||||
console.log(`Slash Command ${cmd.name} registered`),
|
console.log(`Slash Command ${cmd.name} registered`)
|
||||||
)
|
);
|
||||||
|
});
|
||||||
|
|
||||||
})
|
console.log(" ");
|
||||||
|
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
|
||||||
|
|
||||||
console.log(' ')
|
fs.readdirSync("./Events")
|
||||||
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬')
|
.filter((file) => file.endsWith(".js"))
|
||||||
|
.forEach((file) => {
|
||||||
|
const event = require(`../Events/${file}`);
|
||||||
|
console.log(`\u001b[31;1m`, `${event.event}`, `\u001b[32;1m`, "Loaded");
|
||||||
|
|
||||||
fs.readdirSync("./Events")
|
this.on(event.event, event.run.bind(null, this));
|
||||||
.filter(file => file.endsWith(".js"))
|
});
|
||||||
.forEach(file => {
|
|
||||||
|
|
||||||
const event = require(`../Events/${file}`);
|
console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬");
|
||||||
console.log(`\u001b[31;1m`, `${event.event}`, `\u001b[32;1m`, 'Loaded');
|
console.log(" ");
|
||||||
|
|
||||||
this.on(event.event, event.run.bind(null, this));
|
this.login(token);
|
||||||
});
|
}
|
||||||
|
|
||||||
console.log(`\u001b[34;1m`, '▬▬▬▬▬▬▬ Events ▬▬▬▬▬▬▬')
|
|
||||||
console.log(' ')
|
|
||||||
|
|
||||||
this.login(token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Client;
|
module.exports = Client;
|
||||||
+10
-11
@@ -5,20 +5,19 @@ const fs = require("fs");
|
|||||||
|
|
||||||
const Discord = require("discord.js");
|
const Discord = require("discord.js");
|
||||||
|
|
||||||
const yaml = require('js-yaml');
|
const yaml = require("js-yaml");
|
||||||
const supportbot = yaml.load(fs.readFileSync('./Data/supportbot.yml', 'utf8'));
|
const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8"));
|
||||||
|
|
||||||
function RunFunction(message, args, client) {}
|
function RunFunction(interaction) {}
|
||||||
|
|
||||||
class Command {
|
class Command {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.name = options.name;
|
this.name = options.name;
|
||||||
this.description = options.description;
|
this.description = options.description;
|
||||||
this.permission = options.permission;
|
this.permission = options.permission;
|
||||||
this.type = ["BOTH", "SLASH", "TEXT"].includes(options.type) ? options.type : "TEXT";
|
this.slashCommandOptions = options.slashCommandOptions || [];
|
||||||
this.slashCommandOptions = options.slashCommandOptions || [];
|
this.run = options.run;
|
||||||
this.run = options.run;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Command;
|
module.exports = Command;
|
||||||
Reference in new issue
Block a user