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