From 2c5699d9464d34a2fca4e2082b7429a783616e1e Mon Sep 17 00:00:00 2001 From: "Isaac (eartharoid)" Date: Sun, 23 Aug 2020 23:15:39 +0100 Subject: [PATCH] config --- src/commands/add.js | 3 +-- src/commands/close.js | 3 +-- src/commands/help.js | 3 +-- src/commands/new.js | 3 +-- src/commands/panel.js | 3 +-- src/commands/remove.js | 3 +-- src/commands/stats.js | 5 +---- src/commands/tickets.js | 3 +-- src/commands/topic.js | 3 +-- src/commands/transcript.js | 3 +-- src/events/message.js | 5 ++--- src/events/messageDelete.js | 3 +-- src/events/messageReactionAdd.js | 3 +-- src/events/messageUpdate.js | 5 +---- src/index.js | 2 +- src/modules/archive.js | 2 -- 16 files changed, 16 insertions(+), 36 deletions(-) diff --git a/src/commands/add.js b/src/commands/add.js index d90cf5b..dc500d7 100644 --- a/src/commands/add.js +++ b/src/commands/add.js @@ -7,7 +7,6 @@ */ const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); @@ -18,7 +17,7 @@ module.exports = { aliases: ['none'], example: 'add @member to #ticket-23', args: true, - async execute(client, message, args, Ticket) { + async execute(client, message, args, {config, Ticket}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/close.js b/src/commands/close.js index 4c72ccd..74a49a0 100644 --- a/src/commands/close.js +++ b/src/commands/close.js @@ -9,7 +9,6 @@ const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); const fs = require('fs'); const archive = require('../modules/archive'); @@ -20,7 +19,7 @@ module.exports = { aliases: ['none'], example: 'close #ticket-17', args: false, - async execute(client, message, args, Ticket) { + async execute(client, message, args, {config, Ticket}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/help.js b/src/commands/help.js index 4f846a2..a9af45b 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -9,7 +9,6 @@ const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); module.exports = { name: 'help', @@ -18,7 +17,7 @@ module.exports = { aliases: ['command', 'commands'], example: 'help new', args: false, - execute(client, message, args) { + execute(client, message, args, {config}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/new.js b/src/commands/new.js index 6a9e45a..276add0 100644 --- a/src/commands/new.js +++ b/src/commands/new.js @@ -10,7 +10,6 @@ const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); const { MessageEmbed } = require('discord.js'); const fs = require('fs'); -const config = require('../../user/' + require('../').config); module.exports = { name: 'new', @@ -19,7 +18,7 @@ module.exports = { aliases: ['ticket', 'open'], example: 'new my server won\'t start', args: false, - async execute(client, message, args, Ticket) { + async execute(client, message, args, {config, Ticket}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/panel.js b/src/commands/panel.js index 7ba5549..12be5fe 100644 --- a/src/commands/panel.js +++ b/src/commands/panel.js @@ -9,7 +9,6 @@ const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); module.exports = { name: 'panel', @@ -19,7 +18,7 @@ module.exports = { example: '', args: false, permission: 'MANAGE_SERVER', - async execute(client, message, args, Ticket, Setting) { + async execute(client, message, args, {config, Setting}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/remove.js b/src/commands/remove.js index 43cb012..92b717b 100644 --- a/src/commands/remove.js +++ b/src/commands/remove.js @@ -7,7 +7,6 @@ */ const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); @@ -18,7 +17,7 @@ module.exports = { aliases: ['none'], example: 'remove @member from #ticket-23', args: true, - async execute(client, message, args, Ticket) { + async execute(client, message, args, {config, Ticket}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/stats.js b/src/commands/stats.js index ca6d507..762028f 100644 --- a/src/commands/stats.js +++ b/src/commands/stats.js @@ -6,10 +6,7 @@ * */ -const ChildLogger = require('leekslazylogger').ChildLogger; -const log = new ChildLogger(); const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); module.exports = { name: 'stats', @@ -18,7 +15,7 @@ module.exports = { aliases: ['data', 'statistics'], example: '', args: false, - async execute(client, message, args, Ticket) { + async execute(client, message, args, {config, Ticket}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/tickets.js b/src/commands/tickets.js index 06986d6..048971f 100644 --- a/src/commands/tickets.js +++ b/src/commands/tickets.js @@ -8,7 +8,6 @@ const { MessageEmbed } = require('discord.js'); const fs = require('fs'); -const config = require('../../user/' + require('../').config); module.exports = { name: 'tickets', @@ -17,7 +16,7 @@ module.exports = { aliases: ['list'], example: '', args: false, - async execute(client, message, args, Ticket) { + async execute(client, message, args, {config, Ticket}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/topic.js b/src/commands/topic.js index edae035..5868121 100644 --- a/src/commands/topic.js +++ b/src/commands/topic.js @@ -7,7 +7,6 @@ */ const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); module.exports = { name: 'topic', @@ -16,7 +15,7 @@ module.exports = { aliases: ['edit'], example: 'topic need help error', args: true, - async execute(client, message, args, Ticket) { + async execute(client, message, args, {config, Ticket}) { const guild = client.guilds.cache.get(config.guild); diff --git a/src/commands/transcript.js b/src/commands/transcript.js index a0e7d06..7ae3882 100644 --- a/src/commands/transcript.js +++ b/src/commands/transcript.js @@ -10,7 +10,6 @@ const fs = require('fs'); const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); module.exports = { name: 'transcript', @@ -19,7 +18,7 @@ module.exports = { aliases: ['archive', 'download'], example: 'transcript 57', args: true, - async execute(client, message, args, Ticket) { + async execute(client, message, args, {config, Ticket}) { const guild = client.guilds.cache.get(config.guild); const id = args[0]; diff --git a/src/events/message.js b/src/events/message.js index c13ddab..3b70228 100644 --- a/src/events/message.js +++ b/src/events/message.js @@ -9,12 +9,11 @@ const { Collection, MessageEmbed } = require('discord.js'); const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); -const config = require('../../user/' + require('../').config); const archive = require('../modules/archive'); module.exports = { event: 'message', - async execute(client, [message], {Ticket, Setting}) { + async execute(client, [message], {config, Ticket, Setting}) { const guild = client.guilds.cache.get(config.guild); @@ -101,7 +100,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, Ticket, Setting); + command.execute(client, message, args, {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`); diff --git a/src/events/messageDelete.js b/src/events/messageDelete.js index 36f21e7..77ea811 100644 --- a/src/events/messageDelete.js +++ b/src/events/messageDelete.js @@ -8,12 +8,11 @@ const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); -const config = require('../../user/' + require('../').config); const fs = require('fs'); module.exports = { event: 'messageDelete', - async execute(client, [message], {Ticket}) { + async execute(client, [message], {config, Ticket}) { if(!config.transcripts.web.enabled) return; diff --git a/src/events/messageReactionAdd.js b/src/events/messageReactionAdd.js index 9286024..4e48eb2 100644 --- a/src/events/messageReactionAdd.js +++ b/src/events/messageReactionAdd.js @@ -9,12 +9,11 @@ const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); const { MessageEmbed } = require('discord.js'); -const config = require('../../user/' + require('../').config); const fs = require('fs'); module.exports = { event: 'messageReactionAdd', - async execute(client, [r, u], {Ticket, Setting}) { + async execute(client, [r, u], {config, Ticket, Setting}) { if (r.partial) try { diff --git a/src/events/messageUpdate.js b/src/events/messageUpdate.js index 2dd60ca..eee70d7 100644 --- a/src/events/messageUpdate.js +++ b/src/events/messageUpdate.js @@ -6,16 +6,13 @@ * */ -const Discord = require('discord.js'); const ChildLogger = require('leekslazylogger').ChildLogger; const log = new ChildLogger(); -const config = require('../../user/' + require('../').config); const fs = require('fs'); -const dtf = require('@eartharoid/dtf'); module.exports = { event: 'messageUpdate', - async execute(client, [o, n], {Ticket}) { + async execute(client, [o, n], {config, Ticket}) { if(!config.transcripts.web.enabled) return; diff --git a/src/index.js b/src/index.js index d38a278..744d890 100644 --- a/src/index.js +++ b/src/index.js @@ -95,7 +95,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], {Ticket, Setting})); + client.on(event.event, (e1, e2) => client.events.get(event.event).execute(client, [e1, e2], {config, Ticket, Setting})); log.console(log.format(`> Loaded &7${event.event}&f event`)); } diff --git a/src/modules/archive.js b/src/modules/archive.js index 28c514d..ab7a913 100644 --- a/src/modules/archive.js +++ b/src/modules/archive.js @@ -6,8 +6,6 @@ * */ -const ChildLogger = require('leekslazylogger').ChildLogger; -const log = new ChildLogger(); const lineReader = require('line-reader'); const fs = require('fs'); const dtf = require('@eartharoid/dtf');