initial commit - base code

This commit is contained in:
SowinskiBraeden committed 2022-12-02 22:08:05 -08:00
commit 00ace29403
15 files changed
+2257

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
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)
);
}
error(Text) {
let d = new Date();
this.logger.log({
level: "error",
message:
`${d.getHours()}:${
d.getMinutes
} - ${d.getDate()}:${d.getMonth()}:${d.getFullYear()} | Error: ` + Text,
});
console.log(
colors.green(
`${d.getDate()}:${d.getMonth()}:${d.getFullYear()} - ${d.getHours()}:${d.getMinutes()}`
) + colors.yellow(" | Error: ") + colors.red(Text)
);
}
}
module.exports = Logger;
+69
View File
@@ -0,0 +1,69 @@
const fs = require("fs");
const path = require("path");
const { Routes } = require('discord.js');
const { REST } = require('@discordjs/rest');
/**
* Register slash commands for a guild
* @param {require("../structures/QuarksBot")} client
*/
module.exports = {
// Register guild commands
RegisterGuildCommands: async function(client, guild) {
const commands = [];
const commandFiles = fs.readdirSync(path.join(__dirname, "..", "commands")).filter(file => file.endsWith('.js'));
// Place your client and guild ids here
const clientId = client.application.id;
const guildId = guild;
for (const file of commandFiles) {
const command = require(`../commands/${file}`);
if (!commands.global) commands.push(command); // don't include global commands
}
const rest = new REST({ version: '10' }).setToken(client.config.Token);
try {
client.log(`[${guildId}] Started refreshing guild (/) commands.`);
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
client.log(`[${guildId}] Successfully reloaded guild (/) commands.`);
} catch (error) {
client.error(error);
}
},
// Register global commands
RegisterGlobalCommands: async function(client) {
const commands = [];
const commandFiles = fs.readdirSync(path.join(__dirname, "..", "commands")).filter(file => file.endsWith('.js'));
// Place your client and guild ids here
const clientId = client.application.id;
for (const file of commandFiles) {
const command = require(`../commands/${file}`);
if (command.global) commands.push(command);
}
const rest = new REST({ version: '10' }).setToken(client.config.Token);
try {
client.log('[global] Started refreshing global (/) commands.');
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
client.log('[global] Successfully reloaded global (/) commands.');
} catch (error) {
client.error(error);
}
}
};