324 FUCKING FORMATTING ERRORS
This commit is contained in:
parent
ec0cdd859f
commit
f555831aeb
6 changed files with 167 additions and 167 deletions
|
@ -1,11 +1,11 @@
|
||||||
module.exports = class {
|
module.exports = class {
|
||||||
constructor (client) {
|
constructor (client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
async run () {
|
async run () {
|
||||||
await this.client.functions.wait(1000);
|
await this.client.functions.wait(1000);
|
||||||
this.client.user.setActivity(`BNA | v${this.client.version}`, { type: "WATCHING" }) // lol
|
this.client.user.setActivity(`BNA | v${this.client.version}`, { type: 'WATCHING' }); // lol
|
||||||
this.client.logger.ready(`Connected to Discord as ${this.client.user.tag}`);
|
this.client.logger.ready(`Connected to Discord as ${this.client.user.tag}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
20
bot/index.js
20
bot/index.js
|
@ -5,7 +5,7 @@ const { CommandHandler, EventHandler } = require('./util/handlers');
|
||||||
const Functions = require('./util/functions');
|
const Functions = require('./util/functions');
|
||||||
const Database = require('./util/database');
|
const Database = require('./util/database');
|
||||||
const logger = require('./util/logger');
|
const logger = require('./util/logger');
|
||||||
const sentry = require('@sentry/node');
|
const sentry = require('@sentry/node'); // eslint-disable-line no-unused-vars
|
||||||
const config = require('../config.json');
|
const config = require('../config.json');
|
||||||
const pkg = require('../package.json');
|
const pkg = require('../package.json');
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class WoomyClient extends Client {
|
||||||
if (this.config.devmode === true) {
|
if (this.config.devmode === true) {
|
||||||
this.dev = true;
|
this.dev = true;
|
||||||
// sentry.init({ dsn: this.config.keys.sentry });
|
// sentry.init({ dsn: this.config.keys.sentry });
|
||||||
};
|
}
|
||||||
|
|
||||||
// Essential modules
|
// Essential modules
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
@ -38,8 +38,8 @@ class WoomyClient extends Client {
|
||||||
// Handlers, to load commands and events
|
// Handlers, to load commands and events
|
||||||
this.commandHandler = new CommandHandler(this);
|
this.commandHandler = new CommandHandler(this);
|
||||||
this.eventHandler = new EventHandler(this);
|
this.eventHandler = new EventHandler(this);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
const client = new WoomyClient();
|
const client = new WoomyClient();
|
||||||
|
@ -54,17 +54,17 @@ async function init() {
|
||||||
client.login(client.config.devtoken);
|
client.login(client.config.devtoken);
|
||||||
} else {
|
} else {
|
||||||
client.login(client.config.token);
|
client.login(client.config.token);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
process.on('uncaughtException', (err) => {
|
process.on('uncaughtException', (err) => {
|
||||||
const errorMsg = err.stack.replace(new RegExp(`${__dirname}/`, 'g'), './');
|
const errorMsg = err.stack.replace(new RegExp(`${__dirname}/`, 'g'), './');
|
||||||
console.error('Uncaught Exception: ', errorMsg);
|
console.error('Uncaught Exception: ', errorMsg);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('unhandledRejection', err => {
|
process.on('unhandledRejection', err => {
|
||||||
console.error('Uncaught Promise Error: ', err);
|
console.error('Uncaught Promise Error: ', err);
|
||||||
});
|
});
|
|
@ -1,13 +1,13 @@
|
||||||
const discord = require("discord.js");
|
const discord = require('discord.js');
|
||||||
const config = require("../config.json");
|
const config = require('../config.json');
|
||||||
|
|
||||||
const manager = new discord.ShardingManager("./index.js", {
|
const manager = new discord.ShardingManager('./index.js', {
|
||||||
totalShards: "auto",
|
totalShards: 'auto',
|
||||||
token: config.token
|
token: config.token
|
||||||
});
|
});
|
||||||
|
|
||||||
manager.on("shardCreate", (shard) => {
|
manager.on('shardCreate', (shard) => {
|
||||||
console.log("Shard " + shard.id + " launched");
|
console.log('Shard ' + shard.id + ' launched');
|
||||||
});
|
});
|
||||||
|
|
||||||
manager.spawn();
|
manager.spawn();
|
|
@ -4,7 +4,7 @@ const { inspect, promisify } = require('util');
|
||||||
class Functions {
|
class Functions {
|
||||||
constructor (client) {
|
constructor (client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
};
|
}
|
||||||
|
|
||||||
userError (channel, cmd, error) {
|
userError (channel, cmd, error) {
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
|
@ -15,12 +15,12 @@ class Functions {
|
||||||
.setFooter(`Run 'help ${cmd.help.name}' for more information.`);
|
.setFooter(`Run 'help ${cmd.help.name}' for more information.`);
|
||||||
|
|
||||||
channel.send(embed);
|
channel.send(embed);
|
||||||
};
|
}
|
||||||
|
|
||||||
async getLastMessage (channel) {
|
async getLastMessage (channel) {
|
||||||
let messages = await channel.messages.fetch({ limit: 2 });
|
let messages = await channel.messages.fetch({ limit: 2 });
|
||||||
return messages.last().content;
|
return messages.last().content;
|
||||||
};
|
}
|
||||||
|
|
||||||
async awaitReply(message, question, limit = 60000) {
|
async awaitReply(message, question, limit = 60000) {
|
||||||
const filter = (m) => m.author.id === message.author.id;
|
const filter = (m) => m.author.id === message.author.id;
|
||||||
|
@ -48,35 +48,35 @@ class Functions {
|
||||||
try {
|
try {
|
||||||
match = guild.members.cache.find(x => x.displayName.toLowerCase() == query);
|
match = guild.members.cache.find(x => x.displayName.toLowerCase() == query);
|
||||||
if (!match) guild.members.cache.find(x => x.user.username.toLowerCase() == query);
|
if (!match) guild.members.cache.find(x => x.user.username.toLowerCase() == query);
|
||||||
} catch (err) {};
|
} catch (err) {} //eslint-disable-line no-empty
|
||||||
|
|
||||||
if (match) matches.push(match);
|
if (match) matches.push(match);
|
||||||
guild.members.cache.forEach(member => {
|
guild.members.cache.forEach(member => {
|
||||||
if (
|
if (
|
||||||
(member.displayName.toLowerCase().startsWith(query) ||
|
(member.displayName.toLowerCase().startsWith(query) ||
|
||||||
member.user.tag.toLowerCase().startsWith(query)) &&
|
member.user.tag.toLowerCase().startsWith(query)) &&
|
||||||
member.id != (match && match.id)
|
member.id != (match && match.id)
|
||||||
) {
|
) {
|
||||||
matches.push(member);
|
matches.push(member);
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
};
|
}
|
||||||
|
|
||||||
findRole (input, message) {
|
findRole (input, message) {
|
||||||
let role;
|
let role;
|
||||||
role = message.guild.roles.cache.find(r => r.name.toLowerCase() === input.toLowerCase());
|
role = message.guild.roles.cache.find(r => r.name.toLowerCase() === input.toLowerCase());
|
||||||
if(!role) {
|
if(!role) {
|
||||||
role = message.guild.roles.cache.get(input.toLowerCase());
|
role = message.guild.roles.cache.get(input.toLowerCase());
|
||||||
};
|
}
|
||||||
if(!role) return;
|
if(!role) return;
|
||||||
return role;
|
return role;
|
||||||
};
|
}
|
||||||
|
|
||||||
intBetween (min, max) {
|
intBetween (min, max) {
|
||||||
return Math.round((Math.random() * (max - min) + min));
|
return Math.round((Math.random() * (max - min) + min));
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@ class Functions {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
shutdown () {
|
shutdown () {
|
||||||
const exitQuotes = [
|
const exitQuotes = [
|
||||||
|
@ -99,34 +99,34 @@ class Functions {
|
||||||
];
|
];
|
||||||
|
|
||||||
this.client.db.pool.end().then(() => {
|
this.client.db.pool.end().then(() => {
|
||||||
this.client.logger.info('Connection to database closed.')
|
this.client.logger.info('Connection to database closed.');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.client.destroy();
|
this.client.destroy();
|
||||||
|
|
||||||
console.log(exitQuotes);
|
console.log(exitQuotes);
|
||||||
};
|
}
|
||||||
|
|
||||||
async clean (text) {
|
async clean (text) {
|
||||||
if (text && text.constructor.name === 'Promise') {
|
if (text && text.constructor.name === 'Promise') {
|
||||||
text = await text;
|
text = await text;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (typeof text !== 'string') {
|
if (typeof text !== 'string') {
|
||||||
text = inspect(text, { depth: 1});
|
text = inspect(text, { depth: 1});
|
||||||
};
|
}
|
||||||
|
|
||||||
text = text
|
text = text
|
||||||
.replace(/`/g, "`" + String.fromCharCode(8203))
|
.replace(/`/g, '`' + String.fromCharCode(8203))
|
||||||
.replace(/@/g, "@" + String.fromCharCode(8203))
|
.replace(/@/g, '@' + String.fromCharCode(8203))
|
||||||
.replace(this.client.token, "mfa.VkO_2G4Qv3T--NO--lWetW_tjND--TOKEN--QFTm6YGtzq9PH--4U--tG0");
|
.replace(this.client.token, 'mfa.VkO_2G4Qv3T--NO--lWetW_tjND--TOKEN--QFTm6YGtzq9PH--4U--tG0');
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
};
|
}
|
||||||
|
|
||||||
wait () {
|
wait () {
|
||||||
promisify(setTimeout);
|
promisify(setTimeout);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = Functions;
|
module.exports = Functions;
|
|
@ -1,132 +1,132 @@
|
||||||
const fs = require("fs");
|
const fs = require('fs');
|
||||||
|
|
||||||
class CommandHandler {
|
class CommandHandler {
|
||||||
constructor (client) {
|
constructor (client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
|
||||||
|
|
||||||
load (name, category) {
|
|
||||||
try {
|
|
||||||
const path = this.client.path + "/commands/" + category + "/" + name + ".js";
|
|
||||||
const props = new (require(path))(this.client);
|
|
||||||
|
|
||||||
this.client.logger.debug(`Loading command ${category}/${name}`);
|
|
||||||
|
|
||||||
props.help.name = name;
|
|
||||||
props.help.category = category;
|
|
||||||
|
|
||||||
if (props.init) {
|
|
||||||
props.init(this.client);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.client.commands.set(props.help.name, props);
|
|
||||||
|
|
||||||
this.client.cooldowns.set(props.help.name, new Map());
|
|
||||||
|
|
||||||
props.conf.aliases.forEach(alias => {
|
|
||||||
this.client.aliases.set(alias, props.help.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
} catch (err) {
|
|
||||||
return `Failed to load command ${name}: ${err.stack}`;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
loadAll () {
|
load (name, category) {
|
||||||
const commandDirectories = fs.readdirSync("./commands/");
|
try {
|
||||||
this.client.logger.debug(`Found ${commandDirectories.length} command directories.`);
|
const path = this.client.path + '/commands/' + category + '/' + name + '.js';
|
||||||
commandDirectories.forEach((dir) => {
|
const props = new (require(path))(this.client);
|
||||||
const commandFiles = fs.readdirSync("./commands/" + dir + "/");
|
|
||||||
commandFiles.filter((cmd) => cmd.split(".").pop() === "js").forEach((cmd) => {
|
this.client.logger.debug(`Loading command ${category}/${name}`);
|
||||||
cmd = cmd.substring(0, cmd.length - 3);
|
|
||||||
const resp = this.load(cmd, dir);
|
props.help.name = name;
|
||||||
if (resp) {
|
props.help.category = category;
|
||||||
this.client.logger.error(resp);
|
|
||||||
|
if (props.init) {
|
||||||
|
props.init(this.client);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.client.commands.set(props.help.name, props);
|
||||||
|
|
||||||
|
this.client.cooldowns.set(props.help.name, new Map());
|
||||||
|
|
||||||
|
props.conf.aliases.forEach(alias => {
|
||||||
|
this.client.aliases.set(alias, props.help.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
} catch (err) {
|
||||||
|
return `Failed to load command ${name}: ${err.stack}`;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
this.client.logger.info(`Loaded a total of ${this.client.commands.size} commands.`)
|
|
||||||
}
|
|
||||||
|
|
||||||
async unload (name, category) {
|
|
||||||
const path = this.client.path + "/commands/" + category + "/" + name + ".js";
|
|
||||||
|
|
||||||
let command;
|
|
||||||
|
|
||||||
if (this.client.commands.has(name)) {
|
|
||||||
command = this.client.commands.get(name);
|
|
||||||
} else if (this.client.aliases.has(name)) {
|
|
||||||
command = this.client.commands.get(this.client.aliases.get(name));
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!command) {
|
|
||||||
return `\`${name}\` does not exist as a command or an alias.`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.logger.debug(`Unloading command ${category}/${name}`);
|
loadAll () {
|
||||||
|
const commandDirectories = fs.readdirSync('./commands/');
|
||||||
if (command.shutdown) {
|
this.client.logger.debug(`Found ${commandDirectories.length} command directories.`);
|
||||||
await command.shutdown(this.client)
|
commandDirectories.forEach((dir) => {
|
||||||
|
const commandFiles = fs.readdirSync('./commands/' + dir + '/');
|
||||||
|
commandFiles.filter((cmd) => cmd.split('.').pop() === 'js').forEach((cmd) => {
|
||||||
|
cmd = cmd.substring(0, cmd.length - 3);
|
||||||
|
const resp = this.load(cmd, dir);
|
||||||
|
if (resp) {
|
||||||
|
this.client.logger.error(resp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.client.logger.info(`Loaded a total of ${this.client.commands.size} commands.`);
|
||||||
}
|
}
|
||||||
delete require.cache[require.resolve(path)];
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
unloadAll () {
|
async unload (name, category) {
|
||||||
const commandDirectories = fs.readdirSync("./commands/");
|
const path = this.client.path + '/commands/' + category + '/' + name + '.js';
|
||||||
this.client.logger.debug(`Found ${commandDirectories.length} command directories.`);
|
|
||||||
commandDirectories.forEach((dir) => {
|
let command;
|
||||||
const commandFiles = fs.readdirSync("./commands/" + dir + "/");
|
|
||||||
commandFiles.filter((cmd) => cmd.split(".").pop() === "js").forEach((cmd) => {
|
if (this.client.commands.has(name)) {
|
||||||
cmd = cmd.substring(0, cmd.length - 3);
|
command = this.client.commands.get(name);
|
||||||
const resp = this.unload(cmd, dir);
|
} else if (this.client.aliases.has(name)) {
|
||||||
if (resp) {
|
command = this.client.commands.get(this.client.aliases.get(name));
|
||||||
this.client.logger.error(resp);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
if (!command) {
|
||||||
}
|
return `\`${name}\` does not exist as a command or an alias.`;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.client.logger.debug(`Unloading command ${category}/${name}`);
|
||||||
|
|
||||||
|
if (command.shutdown) {
|
||||||
|
await command.shutdown(this.client);
|
||||||
|
}
|
||||||
|
delete require.cache[require.resolve(path)];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unloadAll () {
|
||||||
|
const commandDirectories = fs.readdirSync('./commands/');
|
||||||
|
this.client.logger.debug(`Found ${commandDirectories.length} command directories.`);
|
||||||
|
commandDirectories.forEach((dir) => {
|
||||||
|
const commandFiles = fs.readdirSync('./commands/' + dir + '/');
|
||||||
|
commandFiles.filter((cmd) => cmd.split('.').pop() === 'js').forEach((cmd) => {
|
||||||
|
cmd = cmd.substring(0, cmd.length - 3);
|
||||||
|
const resp = this.unload(cmd, dir);
|
||||||
|
if (resp) {
|
||||||
|
this.client.logger.error(resp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EventHandler {
|
class EventHandler {
|
||||||
constructor (client) {
|
constructor (client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
|
||||||
|
|
||||||
load (name) {
|
|
||||||
try {
|
|
||||||
this.client.logger.debug(`Loading event ${name}`);
|
|
||||||
|
|
||||||
const path = this.client.path + "/events/" + name + ".js";
|
|
||||||
const event = new (require(path))(this.client);
|
|
||||||
this.client.on(name, (...args) => event.run(...args));
|
|
||||||
delete require.cache[require.resolve(path)];
|
|
||||||
|
|
||||||
return;
|
|
||||||
} catch (err) {
|
|
||||||
return `Failed to load event ${name}: ${err}`;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
unload (name) {
|
load (name) {
|
||||||
|
try {
|
||||||
|
this.client.logger.debug(`Loading event ${name}`);
|
||||||
|
|
||||||
}
|
const path = this.client.path + '/events/' + name + '.js';
|
||||||
|
const event = new (require(path))(this.client);
|
||||||
|
this.client.on(name, (...args) => event.run(...args));
|
||||||
|
delete require.cache[require.resolve(path)];
|
||||||
|
|
||||||
loadAll () {
|
return;
|
||||||
const eventFiles = fs.readdirSync(this.client.path + "/events");
|
} catch (err) {
|
||||||
eventFiles.forEach(file => {
|
return `Failed to load event ${name}: ${err}`;
|
||||||
const name = file.split(".")[0];
|
}
|
||||||
const resp = this.load(name);
|
}
|
||||||
|
|
||||||
if (resp) {
|
unload (name) { //eslint-disable-line no-unused-vars
|
||||||
this.client.logger.error(resp);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
loadAll () {
|
||||||
|
const eventFiles = fs.readdirSync(this.client.path + '/events');
|
||||||
|
eventFiles.forEach(file => {
|
||||||
|
const name = file.split('.')[0];
|
||||||
|
const resp = this.load(name);
|
||||||
|
|
||||||
|
if (resp) {
|
||||||
|
this.client.logger.error(resp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
CommandHandler: CommandHandler,
|
CommandHandler: CommandHandler,
|
||||||
EventHandler: EventHandler
|
EventHandler: EventHandler
|
||||||
};
|
};
|
|
@ -14,7 +14,7 @@ const customLevels = {
|
||||||
error: 5
|
error: 5
|
||||||
},
|
},
|
||||||
|
|
||||||
colours: {
|
colours: {
|
||||||
debug: 'black magentaBG',
|
debug: 'black magentaBG',
|
||||||
cmd: 'black whiteBG',
|
cmd: 'black whiteBG',
|
||||||
info: 'black cyanBG',
|
info: 'black cyanBG',
|
||||||
|
@ -36,14 +36,14 @@ const logger = createLogger({
|
||||||
|
|
||||||
transports: [
|
transports: [
|
||||||
new transports.Console({
|
new transports.Console({
|
||||||
level: 'error',
|
level: 'error',
|
||||||
format: format.combine(
|
format: format.combine(
|
||||||
format.timestamp({
|
format.timestamp({
|
||||||
format: 'YYYY-MM-DD hh:mm:ss'
|
format: 'YYYY-MM-DD hh:mm:ss'
|
||||||
}),
|
}),
|
||||||
format.colorize(),
|
format.colorize(),
|
||||||
fmt
|
fmt
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue