mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 04:13:08 +02:00
Merge pull request #107 from davidjcralph/master
Only create a logger instance once
This commit is contained in:
commit
7763889a2d
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
logs/
|
||||
.vscode/
|
||||
node_modules/
|
||||
user/dev.env
|
||||
user/dev.config.js
|
||||
|
@ -23,7 +23,7 @@
|
||||
"mysql2": "2.x",
|
||||
"mariadb": "2.x",
|
||||
"pg": "8.x",
|
||||
"tedious": "9.x"
|
||||
"tedious": "11.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.19.0",
|
||||
|
@ -7,8 +7,6 @@
|
||||
*/
|
||||
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
|
||||
module.exports = {
|
||||
name: 'add',
|
||||
@ -17,7 +15,7 @@ module.exports = {
|
||||
aliases: ['none'],
|
||||
example: 'add @member to #ticket-23',
|
||||
args: true,
|
||||
async execute(client, message, args, {config, Ticket}) {
|
||||
async execute(client, message, args, log, {config, Ticket}) {
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
|
||||
const notTicket = new MessageEmbed()
|
||||
|
@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
@ -20,7 +18,7 @@ module.exports = {
|
||||
aliases: ['none'],
|
||||
example: 'close #ticket-17',
|
||||
args: false,
|
||||
async execute(client, message, args, { config, Ticket }) {
|
||||
async execute(client, message, _args, log, { config, Ticket }) {
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
|
||||
const notTicket = new MessageEmbed()
|
||||
|
@ -5,8 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
@ -26,7 +24,7 @@ module.exports = {
|
||||
example: 'closeall 1mo 1w',
|
||||
args: false,
|
||||
disabled: !config.commands.closeall.enabled,
|
||||
async execute(client, message, args, {
|
||||
async execute(client, message, args, log, {
|
||||
config,
|
||||
Ticket
|
||||
}) {
|
||||
|
@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const {
|
||||
MessageEmbed
|
||||
} = require('discord.js');
|
||||
@ -21,7 +19,7 @@ module.exports = {
|
||||
aliases: ['del'],
|
||||
example: 'delete #ticket-17',
|
||||
args: false,
|
||||
async execute(client, message, args, {
|
||||
async execute(client, message, _args, log, {
|
||||
config,
|
||||
Ticket
|
||||
}) {
|
||||
|
@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
@ -17,7 +15,7 @@ module.exports = {
|
||||
aliases: ['command', 'commands'],
|
||||
example: 'help new',
|
||||
args: false,
|
||||
execute(client, message, args, {config}) {
|
||||
execute(client, message, args, log, {config}) {
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
|
||||
const commands = Array.from(client.commands.values());
|
||||
|
@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
@ -21,7 +19,7 @@ module.exports = {
|
||||
example: 'new my server won\'t start',
|
||||
args: false,
|
||||
disabled: !config.commands.new.enabled,
|
||||
async execute(client, message, args, {config, Ticket}) {
|
||||
async execute(client, message, args, log, {config, Ticket}) {
|
||||
|
||||
if (!config.commands.new.enabled) return; // stop if the command is disabled
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
@ -17,7 +15,7 @@ module.exports = {
|
||||
aliases: ['widget'],
|
||||
args: false,
|
||||
permission: 'MANAGE_GUILD',
|
||||
async execute(client, message, _args, {config, Setting}) {
|
||||
async execute(client, message, _args, log, {config, Setting}) {
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
|
||||
let msgID = await Setting.findOne({ where: { key: 'panel_msg_id' } });
|
||||
|
@ -7,8 +7,6 @@
|
||||
*/
|
||||
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
|
||||
module.exports = {
|
||||
name: 'remove',
|
||||
@ -17,7 +15,7 @@ module.exports = {
|
||||
aliases: ['none'],
|
||||
example: 'remove @member from #ticket-23',
|
||||
args: true,
|
||||
async execute(client, message, args, {config, Ticket}) {
|
||||
async execute(client, message, args, log, {config, Ticket}) {
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
|
||||
const notTicket = new MessageEmbed()
|
||||
|
@ -6,12 +6,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
|
||||
module.exports = {
|
||||
event: 'debug',
|
||||
execute(_client, [e]) {
|
||||
execute(_client, log, [e]) {
|
||||
log.debug(e);
|
||||
}
|
||||
};
|
@ -6,12 +6,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
|
||||
module.exports = {
|
||||
event: 'error',
|
||||
execute(_client, [e]) {
|
||||
execute(_client, log, [e]) {
|
||||
log.error(e);
|
||||
}
|
||||
};
|
@ -7,13 +7,11 @@
|
||||
*/
|
||||
|
||||
const { Collection, MessageEmbed } = require('discord.js');
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const archive = require('../modules/archive');
|
||||
|
||||
module.exports = {
|
||||
event: 'message',
|
||||
async execute(client, [message], {config, Ticket, Setting}) {
|
||||
async execute(client, log, [message], {config, Ticket, Setting}) {
|
||||
|
||||
const guild = client.guilds.cache.get(config.guild);
|
||||
|
||||
@ -104,7 +102,7 @@ Type \`${config.prefix}new\` on the server to create a new ticket.`);
|
||||
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
|
||||
|
||||
try {
|
||||
command.execute(client, message, args, {config, Ticket, Setting});
|
||||
command.execute(client, message, args, log, {config, Ticket, Setting});
|
||||
log.console(`${message.author.tag} used the '${command.name}' command`);
|
||||
} catch (error) {
|
||||
log.warn(`An error occurred whilst executing the '${command.name}' command`);
|
||||
|
@ -6,14 +6,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
module.exports = {
|
||||
event: 'messageDelete',
|
||||
async execute(_client, [message], {config, Ticket}) {
|
||||
async execute(_client, log, [message], {config, Ticket}) {
|
||||
if (!config.transcripts.web.enabled) return;
|
||||
|
||||
if (message.partial) {
|
||||
|
@ -6,15 +6,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
module.exports = {
|
||||
event: 'messageReactionAdd',
|
||||
async execute(client, [r, u], {config, Ticket, Setting}) {
|
||||
async execute(client, log, [r, u], {config, Ticket, Setting}) {
|
||||
if (r.partial) {
|
||||
try {
|
||||
await r.fetch();
|
||||
|
@ -6,14 +6,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
module.exports = {
|
||||
event: 'messageUpdate',
|
||||
async execute(_client, [o, n], {config, Ticket}) {
|
||||
async execute(_client, log, [o, n], {config, Ticket}) {
|
||||
if (!config.transcripts.web.enabled) return;
|
||||
|
||||
if (o.partial) {
|
||||
|
@ -6,12 +6,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
|
||||
module.exports = {
|
||||
event: 'rateLimit',
|
||||
execute(_client, [limit]) {
|
||||
execute(_client, log, [limit]) {
|
||||
log.warn('Rate-limited! (Enable debug mode in config for details)');
|
||||
log.debug(limit);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ const config = require('../../user/' + require('../').config);
|
||||
|
||||
module.exports = {
|
||||
event: 'ready',
|
||||
execute(client) {
|
||||
execute(client, log) {
|
||||
log.success(`Authenticated as ${client.user.tag}`);
|
||||
|
||||
const updatePresence = () => {
|
||||
|
@ -6,12 +6,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const Logger = require('leekslazylogger');
|
||||
const log = new Logger();
|
||||
|
||||
module.exports = {
|
||||
event: 'warn',
|
||||
execute(_client, [e]) {
|
||||
execute(_client, log, [e]) {
|
||||
log.warn(e);
|
||||
}
|
||||
};
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
const version = Number(process.version.split('.')[0].replace('v', ''));
|
||||
if (!version === 12 || !version > 12) return console.log('Please upgrade to Node v12 or higher');
|
||||
if (version < 12) return console.log('Please upgrade to Node v12 or higher');
|
||||
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
@ -29,9 +29,11 @@ const client = new Discord.Client({
|
||||
autoReconnect: true,
|
||||
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
|
||||
});
|
||||
|
||||
client.events = new Discord.Collection();
|
||||
client.commands = new Discord.Collection();
|
||||
client.cooldowns = new Discord.Collection();
|
||||
|
||||
const utils = require('./modules/utils');
|
||||
const leeks = require('leeks.js');
|
||||
|
||||
@ -127,7 +129,7 @@ for (const file of events) {
|
||||
const event = require(`./events/${file}`);
|
||||
client.events.set(event.event, event);
|
||||
// client.on(event.event, e => client.events.get(event.event).execute(client, e, Ticket, Setting));
|
||||
client.on(event.event, (e1, e2) => client.events.get(event.event).execute(client, [e1, e2], {config, Ticket, Setting}));
|
||||
client.on(event.event, (e1, e2) => client.events.get(event.event).execute(client, log, [e1, e2], {config, Ticket, Setting}));
|
||||
log.console(log.format(`> Loaded &7${event.event}&f event`));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user