initial commit
This commit is contained in:
14 files changed
+3067
No files matched your search
@@ -0,0 +1,28 @@
|
||||
const winston = require("winston");
|
||||
const colors = require("colors");
|
||||
|
||||
class Logger {
|
||||
constructor(LoggingFile) {
|
||||
this.logger = winston.createLogger({
|
||||
transports: [new winston.transports.File({ filename: LoggingFile })],
|
||||
});
|
||||
}
|
||||
|
||||
log(Text) {
|
||||
let d = new Date();
|
||||
this.logger.log({
|
||||
level: "info",
|
||||
message:
|
||||
`${d.getHours()}:${
|
||||
d.getMinutes
|
||||
} - ${d.getDate()}:${d.getMonth()}:${d.getFullYear()} | Info: ` + Text,
|
||||
});
|
||||
console.log(
|
||||
colors.green(
|
||||
`${d.getDate()}:${d.getMonth()}:${d.getFullYear()} - ${d.getHours()}:${d.getMinutes()}`
|
||||
) + colors.yellow(" | Info: " + Text)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Logger;
|
||||
@@ -0,0 +1,40 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
/**
|
||||
* Register slash commands for a guild
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {string} guild
|
||||
*/
|
||||
module.exports = (client, guild) => {
|
||||
|
||||
let commandsDir = path.join(__dirname, "..", "commands");
|
||||
|
||||
fs.readdir(commandsDir, (err, files) => {
|
||||
if (err) throw err;
|
||||
files.forEach(async (file) => {
|
||||
let cmd = require(commandsDir + "/" + file);
|
||||
if (!cmd.SlashCommand || !cmd.SlashCommand.run) return;
|
||||
let dataStuff = {
|
||||
name: cmd.name,
|
||||
description: cmd.description,
|
||||
options: cmd.SlashCommand.options,
|
||||
};
|
||||
|
||||
//Creating variables like this, So you might understand my code :)
|
||||
let ClientAPI = client.api.applications(client.user.id);
|
||||
let GuildAPI = ClientAPI.guilds(guild);
|
||||
|
||||
try {
|
||||
await GuildAPI.commands.post({ data: dataStuff });
|
||||
} catch (e) {
|
||||
client.log('Error: API missing permissions, re-invite the bot');
|
||||
|
||||
// Forces bot to leave server
|
||||
let guildID = client.guilds.cache.get(guild);
|
||||
if (guildID) guildID.leave();
|
||||
client.log(`Server stats is now down to ${client.guilds.cache.size}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user