mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-02 16:41:25 +03:00
consistency
This commit is contained in:
@@ -11,7 +11,7 @@ const log = new ChildLogger();
|
||||
|
||||
module.exports = {
|
||||
event: 'debug',
|
||||
execute(client, [e]) {
|
||||
execute(_client, [e]) {
|
||||
log.debug(e);
|
||||
}
|
||||
};
|
@@ -11,7 +11,7 @@ const log = new ChildLogger();
|
||||
|
||||
module.exports = {
|
||||
event: 'error',
|
||||
execute(client, [e]) {
|
||||
execute(_client, [e]) {
|
||||
log.error(e);
|
||||
}
|
||||
};
|
@@ -30,8 +30,7 @@ Type \`${config.prefix}new\` on the server to create a new ticket.`);
|
||||
*/
|
||||
|
||||
let ticket = await Ticket.findOne({ where: { channel: message.channel.id } });
|
||||
if(ticket)
|
||||
archive.add(message); // add message to archive
|
||||
if (ticket) archive.add(message); // add message to archive
|
||||
|
||||
if (message.author.bot || message.author.id === client.user.id) return; // goodbye bots
|
||||
|
||||
@@ -52,8 +51,7 @@ Type \`${config.prefix}new\` on the server to create a new ticket.`);
|
||||
|
||||
if (!command || commandName === 'none') return; // not an existing command
|
||||
|
||||
if (message.guild.id !== guild.id)
|
||||
return message.reply(`This bot can only be used within the "${guild}" server`); // not in this server
|
||||
if (message.guild.id !== guild.id) return message.reply(`This bot can only be used within the "${guild}" server`); // not in this server
|
||||
|
||||
if (command.permission && !message.member.hasPermission(command.permission)) {
|
||||
log.console(`${message.author.tag} tried to use the '${command.name}' command without permission`);
|
||||
@@ -66,7 +64,7 @@ Type \`${config.prefix}new\` on the server to create a new ticket.`);
|
||||
);
|
||||
}
|
||||
|
||||
if (command.args && !args.length)
|
||||
if (command.args && !args.length) {
|
||||
return message.channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(config.err_colour)
|
||||
@@ -74,6 +72,7 @@ Type \`${config.prefix}new\` on the server to create a new ticket.`);
|
||||
.addField('Help', `Type \`${config.prefix}help ${command.name}\` for more information`)
|
||||
.setFooter(guild.name, guild.iconURL())
|
||||
);
|
||||
}
|
||||
|
||||
if (!client.cooldowns.has(command.name)) client.cooldowns.set(command.name, new Collection());
|
||||
|
||||
|
@@ -12,11 +12,10 @@ const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
event: 'messageDelete',
|
||||
async execute(client, [message], {config, Ticket}) {
|
||||
async execute(_client, [message], {config, Ticket}) {
|
||||
if (!config.transcripts.web.enabled) return;
|
||||
|
||||
if(!config.transcripts.web.enabled) return;
|
||||
|
||||
if (message.partial)
|
||||
if (message.partial) {
|
||||
try {
|
||||
await message.fetch();
|
||||
} catch (err) {
|
||||
@@ -24,15 +23,15 @@ module.exports = {
|
||||
log.error(err.message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let ticket = await Ticket.findOne({ where: { channel: message.channel.id } });
|
||||
if(!ticket) return;
|
||||
if (!ticket) return;
|
||||
|
||||
|
||||
let path = `user/transcripts/raw/${message.channel.id}.log`;
|
||||
let embeds = [];
|
||||
for (let embed in message.embeds)
|
||||
embeds.push(message.embeds[embed].toJSON());
|
||||
for (let embed in message.embeds) embeds.push(message.embeds[embed].toJSON());
|
||||
|
||||
fs.appendFileSync(path, JSON.stringify({
|
||||
id: message.id,
|
||||
@@ -44,6 +43,5 @@ module.exports = {
|
||||
edited: message.edits.length > 1,
|
||||
deleted: true // delete the message
|
||||
}) + '\n');
|
||||
|
||||
}
|
||||
};
|
@@ -14,28 +14,28 @@ const fs = require('fs');
|
||||
module.exports = {
|
||||
event: 'messageReactionAdd',
|
||||
async execute(client, [r, u], {config, Ticket, Setting}) {
|
||||
|
||||
if (r.partial)
|
||||
if (r.partial) {
|
||||
try {
|
||||
await r.fetch();
|
||||
} catch (err) {
|
||||
log.error(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let panelID = await Setting.findOne({ where: { key: 'panel_msg_id' } });
|
||||
if (!panelID) return;
|
||||
|
||||
if(r.message.id !== panelID.get('value')) return;
|
||||
if (r.message.id !== panelID.get('value')) return;
|
||||
|
||||
if(u.id === client.user.id) return;
|
||||
if (u.id === client.user.id) return;
|
||||
|
||||
if (r.emoji.name !== config.panel.reaction && r.emoji.id !== config.panel.reaction) return;
|
||||
|
||||
let channel = r.message.channel;
|
||||
|
||||
const supportRole = channel.guild.roles.cache.get(config.staff_role);
|
||||
if (!supportRole)
|
||||
if (!supportRole) {
|
||||
return channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(config.err_colour)
|
||||
@@ -43,7 +43,7 @@ module.exports = {
|
||||
.setDescription(`${config.name} has not been set up correctly. Could not find a 'support team' role with the id \`${config.staff_role}\``)
|
||||
.setFooter(channel.guild.name, channel.guild.iconURL())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// everything is cool
|
||||
|
||||
@@ -67,7 +67,6 @@ module.exports = {
|
||||
let dm = u.dmChannel || await u.createDM();
|
||||
|
||||
try {
|
||||
|
||||
return dm.send(
|
||||
new MessageEmbed()
|
||||
.setColor(config.err_colour)
|
||||
@@ -76,10 +75,7 @@ module.exports = {
|
||||
.setDescription(`Use \`${config.prefix}close\` in a server channel to close unneeded tickets.\n\n${ticketList.join(',\n')}`)
|
||||
.setFooter(channel.guild.name, channel.guild.iconURL())
|
||||
);
|
||||
|
||||
|
||||
} catch (e) {
|
||||
|
||||
let m = await channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(config.err_colour)
|
||||
@@ -88,11 +84,8 @@ module.exports = {
|
||||
.setDescription(`Use \`${config.prefix}close\` to close unneeded tickets.\n\n${ticketList.join(',\n')}`)
|
||||
.setFooter(channel.guild.name + ' | This message will be deleted in 15 seconds', channel.guild.iconURL())
|
||||
);
|
||||
|
||||
return m.delete({ timeout: 15000 });
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
let topic = 'No topic given (created via panel)';
|
||||
@@ -130,7 +123,6 @@ module.exports = {
|
||||
],
|
||||
reason: 'User requested a new support ticket channel'
|
||||
}).then(async c => {
|
||||
|
||||
Ticket.update({
|
||||
channel: c.id
|
||||
}, {
|
||||
@@ -179,9 +171,8 @@ module.exports = {
|
||||
.setFooter(channel.guild.name, channel.guild.iconURL())
|
||||
);
|
||||
|
||||
if (config.tickets.pin)
|
||||
await w.pin();
|
||||
// await w.pin().then(m => m.delete()); // oopsie, this deletes the pinned message
|
||||
if (config.tickets.pin) await w.pin();
|
||||
// await w.pin().then(m => m.delete()); // oopsie, this deletes the pinned message
|
||||
|
||||
if (config.logs.discord.enabled)
|
||||
client.channels.cache.get(config.logs.discord.channel).send(
|
||||
@@ -197,8 +188,6 @@ module.exports = {
|
||||
);
|
||||
|
||||
log.info(`${u.tag} created a new ticket (#${name}) via panel`);
|
||||
|
||||
|
||||
}).catch(log.error);
|
||||
}
|
||||
};
|
||||
|
@@ -12,33 +12,33 @@ const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
event: 'messageUpdate',
|
||||
async execute(client, [o, n], {config, Ticket}) {
|
||||
async execute(_client, [o, n], {config, Ticket}) {
|
||||
if (!config.transcripts.web.enabled) return;
|
||||
|
||||
if(!config.transcripts.web.enabled) return;
|
||||
|
||||
if (o.partial)
|
||||
if (o.partial) {
|
||||
try {
|
||||
await o.fetch();
|
||||
} catch (err) {
|
||||
log.error(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (n.partial)
|
||||
if (n.partial) {
|
||||
try {
|
||||
await n.fetch();
|
||||
} catch (err) {
|
||||
log.error(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let ticket = await Ticket.findOne({ where: { channel: n.channel.id } });
|
||||
if(!ticket) return;
|
||||
if (!ticket) return;
|
||||
|
||||
let path = `user/transcripts/raw/${n.channel.id}.log`;
|
||||
let embeds = [];
|
||||
for (let embed in n.embeds)
|
||||
embeds.push({ ...n.embeds[embed] });
|
||||
for (let embed in n.embeds) embeds.push({ ...n.embeds[embed] });
|
||||
|
||||
fs.appendFileSync(path, JSON.stringify({
|
||||
id: n.id,
|
||||
|
@@ -11,7 +11,7 @@ const log = new ChildLogger();
|
||||
|
||||
module.exports = {
|
||||
event: 'rateLimit',
|
||||
execute(client, [limit]) {
|
||||
execute(_client, [limit]) {
|
||||
log.warn('Rate-limited! (Enable debug mode in config for details)');
|
||||
log.debug(limit);
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ const config = require('../../user/' + require('../').config);
|
||||
module.exports = {
|
||||
event: 'ready',
|
||||
execute(client) {
|
||||
|
||||
log.success(`Authenticated as ${client.user.tag}`);
|
||||
|
||||
const updatePresence = () => {
|
||||
@@ -33,10 +32,8 @@ module.exports = {
|
||||
}, 60000);
|
||||
|
||||
|
||||
if (client.guilds.cache.get(config.guild).member(client.user).hasPermission('ADMINISTRATOR', false))
|
||||
if (client.guilds.cache.get(config.guild).member(client.user).hasPermission('ADMINISTRATOR', false)) {
|
||||
log.success('\'ADMINISTRATOR\' permission has been granted');
|
||||
else
|
||||
log.warn('Bot does not have \'ADMINISTRATOR\' permission');
|
||||
|
||||
} else log.warn('Bot does not have \'ADMINISTRATOR\' permission');
|
||||
}
|
||||
};
|
||||
|
@@ -11,7 +11,7 @@ const log = new ChildLogger();
|
||||
|
||||
module.exports = {
|
||||
event: 'warn',
|
||||
execute(client, [e]) {
|
||||
execute(_client, [e]) {
|
||||
log.warn(e);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user