From 8a15f3434253c3fbaa4c79a86aea2af7c636c93c Mon Sep 17 00:00:00 2001 From: Isaac Date: Tue, 18 May 2021 18:12:07 +0100 Subject: [PATCH] Make @davidjcralph happy const --- src/commands/add.js | 8 ++-- src/commands/blacklist.js | 16 +++---- src/commands/close.js | 14 +++--- src/commands/help.js | 9 ++-- src/commands/new.js | 28 +++++------ src/commands/panel.js | 12 ++--- src/commands/remove.js | 8 ++-- src/commands/settings.js | 36 +++++++------- src/commands/stats.js | 6 +-- src/commands/topic.js | 12 ++--- src/database/index.js | 4 +- src/database/models/guild.model.js | 4 ++ src/index.js | 14 +++--- src/listeners/guildMemberRemove.js | 4 +- src/listeners/message.js | 14 +++--- src/listeners/messageReactionAdd.js | 20 ++++---- src/listeners/messageReactionRemove.js | 6 +-- src/listeners/ready.js | 2 +- src/modules/commands/command.js | 4 +- src/modules/commands/manager.js | 18 +++---- src/modules/listeners/loader.js | 2 +- src/modules/plugins/manager.js | 6 +-- src/modules/plugins/plugin.js | 8 ++-- src/modules/tickets/archives.js | 18 +++---- src/modules/tickets/manager.js | 48 +++++++++---------- ...tings_schema.json => settings.schema.json} | 6 ++- src/structures/guild.js | 2 +- src/structures/guild_member.js | 2 +- src/updater.js | 6 +-- src/utils/discord.js | 4 +- src/utils/index.js | 2 +- 31 files changed, 176 insertions(+), 167 deletions(-) rename src/{settings_schema.json => settings.schema.json} (96%) diff --git a/src/commands/add.js b/src/commands/add.js index 7ad6337..51e1331 100644 --- a/src/commands/add.js +++ b/src/commands/add.js @@ -34,11 +34,11 @@ module.exports = class AddCommand extends Command { * @returns {Promise} */ async execute(message, args) { - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); - let ticket = message.mentions.channels.first() ?? message.channel; - let t_row = await this.client.tickets.resolve(ticket.id, message.guild.id); + const ticket = message.mentions.channels.first() ?? message.channel; + const t_row = await this.client.tickets.resolve(ticket.id, message.guild.id); if (!t_row) { return await message.channel.send( @@ -50,7 +50,7 @@ module.exports = class AddCommand extends Command { ); } - let member = message.mentions.members.first() ?? message.guild.members.cache.get(args); + const member = message.mentions.members.first() ?? message.guild.members.cache.get(args); if (!member) { return await message.channel.send( diff --git a/src/commands/blacklist.js b/src/commands/blacklist.js index 3481628..bff6938 100644 --- a/src/commands/blacklist.js +++ b/src/commands/blacklist.js @@ -31,10 +31,10 @@ module.exports = class BlacklistCommand extends Command { * @returns {Promise} */ async execute(message, args) { - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); - let member = message.mentions.members.first(); + const member = message.mentions.members.first(); if (member && (await member.isStaff() || member.hasPermission(this.permissions))) { return await message.channel.send( @@ -47,9 +47,9 @@ module.exports = class BlacklistCommand extends Command { } - let role = message.mentions.roles.first(); + const role = message.mentions.roles.first(); let id; - let input = args.trim().split(/\s/g)[0]; + const input = args.trim().split(/\s/g)[0]; if (member) id = member.id; else if (role) id = role.id; @@ -64,7 +64,7 @@ module.exports = class BlacklistCommand extends Command { ); } else { // list blacklisted members - let blacklist = settings.blacklist.map(element => { + const blacklist = settings.blacklist.map(element => { const is_role = message.guild.roles.cache.has(element); if (is_role) return `» <@&${element}> (\`${element}\`)`; else return `» <@${element}> (\`${element}\`)`; @@ -79,10 +79,10 @@ module.exports = class BlacklistCommand extends Command { } const is_role = role !== undefined || message.guild.roles.cache.has(id); - let member_or_role = is_role ? 'role' : 'member'; - let index = settings.blacklist.findIndex(element => element === id); + const member_or_role = is_role ? 'role' : 'member'; + const index = settings.blacklist.findIndex(element => element === id); - let new_blacklist = [ ...settings.blacklist]; + const new_blacklist = [ ...settings.blacklist ]; if (index === -1) { new_blacklist.push(id); diff --git a/src/commands/close.js b/src/commands/close.js index 5a20d9e..4e794f1 100644 --- a/src/commands/close.js +++ b/src/commands/close.js @@ -59,7 +59,7 @@ module.exports = class CloseCommand extends Command { const arg_reason = this.args[1].name; const arg_time = this.args[2].name; - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); if (args[arg_time]) { @@ -77,7 +77,7 @@ module.exports = class CloseCommand extends Command { ); } - let tickets = await this.client.db.models.Ticket.findAndCountAll({ + const tickets = await this.client.db.models.Ticket.findAndCountAll({ where: { last_message: { [Op.lte]: new Date(Date.now() - period) @@ -95,7 +95,7 @@ module.exports = class CloseCommand extends Command { .setFooter(settings.footer, message.guild.iconURL()) ); } else { - let collector_message = await message.channel.send( + const collector_message = await message.channel.send( new MessageEmbed() .setColor(settings.colour) .setTitle(i18n('commands.close.response.confirm_multiple.title')) @@ -109,7 +109,7 @@ module.exports = class CloseCommand extends Command { return user.id === message.author.id && reaction.emoji.name === '✅'; }; - let collector = collector_message.createReactionCollector(collector_filter, { + const collector = collector_message.createReactionCollector(collector_filter, { time: 30000 }); @@ -124,7 +124,7 @@ module.exports = class CloseCommand extends Command { .setFooter(settings.footer, message.guild.iconURL()) ); - for (let ticket of tickets.rows) { + for (const ticket of tickets.rows) { await this.client.tickets.close(ticket.id, message.author.id, message.guild.id, args[arg_reason]); } @@ -186,7 +186,7 @@ module.exports = class CloseCommand extends Command { } } - let collector_message = await message.channel.send( + const collector_message = await message.channel.send( new MessageEmbed() .setColor(settings.colour) .setTitle(i18n('commands.close.response.confirm.title')) @@ -200,7 +200,7 @@ module.exports = class CloseCommand extends Command { return user.id === message.author.id && reaction.emoji.name === '✅'; }; - let collector = collector_message.createReactionCollector(collector_filter, { + const collector = collector_message.createReactionCollector(collector_filter, { time: 30000 }); diff --git a/src/commands/help.js b/src/commands/help.js index f796117..9a176db 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -31,7 +31,7 @@ module.exports = class HelpCommand extends Command { * @returns {Promise} */ async execute(message, args) { - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); const cmd = this.manager.commands.find(command => command.aliases.includes(args.toLowerCase())); @@ -39,13 +39,12 @@ module.exports = class HelpCommand extends Command { if (cmd) { return await cmd.sendUsage(message.channel, args); } else { - let commands = this.manager.commands.filter(async command => { + const commands = this.manager.commands.filter(async command => { if (command.permissions.length >= 1) return !message.member.hasPermission(command.permissions); else if (command.staff_only) return await message.member.isStaff(); }); - let list = commands.map(command => { - // let description = command.description; - let description = command.description.length > 50 + const list = commands.map(command => { + const description = command.description.length > 50 ? command.description.substring(0, 50) + '...' : command.description; return `**\`${settings.command_prefix}${command.name}\` ·** ${description}`; diff --git a/src/commands/new.js b/src/commands/new.js index 4055ce3..eb71fd1 100644 --- a/src/commands/new.js +++ b/src/commands/new.js @@ -35,7 +35,7 @@ module.exports = class NewCommand extends Command { * @returns {Promise} */ async execute(message, args) { - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); const editOrSend = async (msg, content) => { @@ -44,7 +44,7 @@ module.exports = class NewCommand extends Command { }; const create = async (cat_row, response) => { - let tickets = await this.client.db.models.Ticket.findAndCountAll({ + const tickets = await this.client.db.models.Ticket.findAndCountAll({ where: { category: cat_row.id, creator: message.author.id, @@ -63,10 +63,10 @@ module.exports = class NewCommand extends Command { .setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL()) ); } else { - let list = tickets.rows.map(row => { + const list = tickets.rows.map(row => { if (row.topic) { - let description = row.topic.substring(0, 30); - let ellipses = row.topic.length > 30 ? '...' : ''; + const description = row.topic.substring(0, 30); + const ellipses = row.topic.length > 30 ? '...' : ''; return `<#${row.id}>: \`${description}${ellipses}\``; } else { return `<#${row.id}>`; @@ -83,7 +83,7 @@ module.exports = class NewCommand extends Command { } } else { try { - let t_row = await this.client.tickets.create(message.guild.id, message.author.id, cat_row.id, args); + const t_row = await this.client.tickets.create(message.guild.id, message.author.id, cat_row.id, args); response = await editOrSend(response, new MessageEmbed() .setColor(settings.success_colour) @@ -114,7 +114,7 @@ module.exports = class NewCommand extends Command { }, 15000); }; - let categories = await this.client.db.models.Category.findAndCountAll({ + const categories = await this.client.db.models.Category.findAndCountAll({ where: { guild: message.guild.id } @@ -132,9 +132,9 @@ module.exports = class NewCommand extends Command { } else if (categories.count === 1) { create(categories.rows[0]); // skip the category selection } else { - let letters_array = Object.values(letters); // convert the A-Z emoji object to an array - let category_list = categories.rows.map((category, i) => `${letters_array[i]} » ${category.name}`); // list category names with an A-Z emoji - let collector_message = await message.channel.send( + const letters_array = Object.values(letters); // convert the A-Z emoji object to an array + const category_list = categories.rows.map((category, i) => `${letters_array[i]} » ${category.name}`); // list category names with an A-Z emoji + const collector_message = await message.channel.send( new MessageEmbed() .setColor(settings.colour) .setAuthor(message.author.username, message.author.displayAvatarURL()) @@ -143,23 +143,23 @@ module.exports = class NewCommand extends Command { .setFooter(footer(settings.footer, i18n('collector_expires_in', 30)), message.guild.iconURL()) ); - for (let i in categories.rows) { + for (const i in categories.rows) { collector_message.react(letters_array[i]); // add the correct number of letter reactions await wait(1000); // 1 reaction per second rate-limit } const collector_filter = (reaction, user) => { - let allowed = letters_array.slice(0, categories.count); // get the first x letters of the emoji array + const allowed = letters_array.slice(0, categories.count); // get the first x letters of the emoji array return user.id === message.author.id && allowed.includes(reaction.emoji.name); }; - let collector = collector_message.createReactionCollector(collector_filter, { + const collector = collector_message.createReactionCollector(collector_filter, { time: 30000 }); collector.on('collect', async (reaction) => { collector.stop(); - let index = letters_array.findIndex(value => value === reaction.emoji.name); // find where the letter is in the alphabet + const index = letters_array.findIndex(value => value === reaction.emoji.name); // find where the letter is in the alphabet if (index === -1) return setTimeout(async () => { await collector_message.delete(); }, 15000); diff --git a/src/commands/panel.js b/src/commands/panel.js index 4f2dc3e..6da3d90 100644 --- a/src/commands/panel.js +++ b/src/commands/panel.js @@ -69,7 +69,7 @@ module.exports = class PanelCommand extends Command { const arg_emoji = this.args[2].name; const arg_categories = this.args[3].name; - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); if (!args[arg_emoji]) @@ -78,7 +78,7 @@ module.exports = class PanelCommand extends Command { args[arg_emoji] = args[arg_emoji].map(emoji => emojify(emoji.replace(/\\/g, ''))); const invalid_category = await some(args[arg_categories], async id => { - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: id, guild: message.guild.id @@ -102,7 +102,7 @@ module.exports = class PanelCommand extends Command { let categories_map = args[arg_categories][0]; - let embed = new MessageEmbed() + const embed = new MessageEmbed() .setColor(settings.colour) .setFooter(settings.footer, message.guild.iconURL()); @@ -173,9 +173,9 @@ module.exports = class PanelCommand extends Command { let description = ''; categories_map = {}; - for (let i in args[arg_emoji]) { + for (const i in args[arg_emoji]) { categories_map[args[arg_emoji][i]] = args[arg_categories][i]; - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: args[arg_categories][i], guild: message.guild.id @@ -187,7 +187,7 @@ module.exports = class PanelCommand extends Command { embed.setDescription(args[arg_description] + '\n' + description); panel_message = await panel_channel.send(embed); - for (let emoji of args[arg_emoji]) { + for (const emoji of args[arg_emoji]) { await panel_message.react(emoji); await wait(1000); // 1 reaction per second rate-limit } diff --git a/src/commands/remove.js b/src/commands/remove.js index 2263d10..18b0c3f 100644 --- a/src/commands/remove.js +++ b/src/commands/remove.js @@ -34,11 +34,11 @@ module.exports = class RemoveCommand extends Command { * @returns {Promise} */ async execute(message, args) { - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); - let ticket = message.mentions.channels.first() ?? message.channel; - let t_row = await this.client.tickets.resolve(ticket.id, message.guild.id); + const ticket = message.mentions.channels.first() ?? message.channel; + const t_row = await this.client.tickets.resolve(ticket.id, message.guild.id); if (!t_row) { return await message.channel.send( @@ -50,7 +50,7 @@ module.exports = class RemoveCommand extends Command { ); } - let member = message.mentions.members.first() ?? message.guild.members.cache.get(args); + const member = message.mentions.members.first() ?? message.guild.members.cache.get(args); if (!member) { return await message.channel.send( diff --git a/src/commands/settings.js b/src/commands/settings.js index b271567..c4e37e4 100644 --- a/src/commands/settings.js +++ b/src/commands/settings.js @@ -19,7 +19,7 @@ module.exports = class SettingsCommand extends Command { permissions: ['MANAGE_GUILD'] }); - this.schema = require('../settings_schema.json'); + this.schema = require('../settings.schema.json'); this.v = new Validator(); } @@ -30,16 +30,16 @@ module.exports = class SettingsCommand extends Command { * @returns {Promise} */ async execute(message) { - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); - let attachments = [ ...message.attachments.values() ]; + const attachments = [ ...message.attachments.values() ]; if (attachments.length >= 1) { // load settings from json this.client.log.info(`Downloading settings for "${message.guild.name}"`); - let data = await (await fetch(attachments[0].url)).json(); + const data = await (await fetch(attachments[0].url)).json(); const { valid, errors } = this.v.validate(data, this.schema); @@ -55,13 +55,14 @@ module.exports = class SettingsCommand extends Command { settings.locale = data.locale; settings.log_messages = data.log_messages; settings.success_colour = data.success_colour; + settings.tags = data.tags; await settings.save(); - for (let c of data.categories) { + for (const c of data.categories) { if (c.id) { // existing category - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: c.id } @@ -79,13 +80,13 @@ module.exports = class SettingsCommand extends Command { cat_row.survey = c.survey; cat_row.save(); - let cat_channel = await this.client.channels.fetch(c.id); + const cat_channel = await this.client.channels.fetch(c.id); if (cat_channel) { if (cat_channel.name !== c.name) await cat_channel.setName(c.name, `Tickets category updated by ${message.author.tag}`); - for (let r of c.roles) { + for (const r of c.roles) { await cat_channel.updateOverwrite(r, { VIEW_CHANNEL: true, READ_MESSAGE_HISTORY: true, @@ -99,7 +100,7 @@ module.exports = class SettingsCommand extends Command { // create a new category const allowed_permissions = ['VIEW_CHANNEL', 'READ_MESSAGE_HISTORY', 'SEND_MESSAGES', 'EMBED_LINKS', 'ATTACH_FILES']; - let cat_channel = await message.guild.channels.create(c.name, { + const cat_channel = await message.guild.channels.create(c.name, { type: 'category', reason: `Tickets category created by ${message.author.tag}`, position: 1, @@ -142,12 +143,12 @@ module.exports = class SettingsCommand extends Command { } } - for (let survey in data.surveys) { - let survey_data = { + for (const survey in data.surveys) { + const survey_data = { guild: message.guild.id, name: survey, }; - let [s_row] = await this.client.db.models.Survey.findOrCreate({ + const [s_row] = await this.client.db.models.Survey.findOrCreate({ where: survey_data, defaults: survey_data }); @@ -162,19 +163,19 @@ module.exports = class SettingsCommand extends Command { // upload settings as json to be edited - let categories = await this.client.db.models.Category.findAll({ + const categories = await this.client.db.models.Category.findAll({ where: { guild: message.guild.id } }); - let surveys = await this.client.db.models.Survey.findAll({ + const surveys = await this.client.db.models.Survey.findAll({ where: { guild: message.guild.id } }); - let data = { + const data = { categories: categories.map(c => { return { id: c.id, @@ -199,14 +200,15 @@ module.exports = class SettingsCommand extends Command { log_messages: settings.log_messages, success_colour: settings.success_colour, surveys: {}, + tags: settings.tags }; - for (let survey in surveys) { + for (const survey in surveys) { const { name, questions } = surveys[survey]; data.surveys[name] = questions; } - let attachment = new MessageAttachment( + const attachment = new MessageAttachment( Buffer.from(JSON.stringify(data, null, 2)), `Settings for ${message.guild.name}.json` ); diff --git a/src/commands/stats.js b/src/commands/stats.js index 6b57268..45541d3 100644 --- a/src/commands/stats.js +++ b/src/commands/stats.js @@ -27,7 +27,7 @@ module.exports = class StatsCommand extends Command { * @returns {Promise} */ async execute(message) { - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); const messages = await this.client.db.models.Message.findAndCountAll(); @@ -35,7 +35,7 @@ module.exports = class StatsCommand extends Command { let stats = await this.cache.get(message.guild.id); if (!stats) { - let tickets = await this.client.db.models.Ticket.findAndCountAll({ + const tickets = await this.client.db.models.Ticket.findAndCountAll({ where: { guild: message.guild.id } @@ -60,7 +60,7 @@ module.exports = class StatsCommand extends Command { await this.cache.set(message.guild.id, stats, 60 * 60 * 1000); // cache for an hour } - let guild_embed = new MessageEmbed() + const guild_embed = new MessageEmbed() .setColor(settings.colour) .setTitle(i18n('commands.stats.response.guild.title')) .setDescription(i18n('commands.stats.response.guild.description')) diff --git a/src/commands/topic.js b/src/commands/topic.js index a5484d7..39108a9 100644 --- a/src/commands/topic.js +++ b/src/commands/topic.js @@ -28,10 +28,10 @@ module.exports = class TopicCommand extends Command { * @returns {Promise} */ async execute(message, args) { - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); - let t_row = await this.client.db.models.Ticket.findOne({ + const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } @@ -51,18 +51,18 @@ module.exports = class TopicCommand extends Command { topic: this.client.cryptr.encrypt(args) }); - let member = await message.guild.members.fetch(t_row.creator); + const member = await message.guild.members.fetch(t_row.creator); /* await */message.channel.setTopic(`${member} | ${args}`, { reason: 'User updated ticket topic' }); - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: t_row.category } }); - let description = cat_row.opening_message + const description = cat_row.opening_message .replace(/{+\s?(user)?name\s?}+/gi, member.displayName) .replace(/{+\s?(tag|ping|mention)?\s?}+/gi, member.user.toString()); - let opening_message = await message.channel.messages.fetch(t_row.opening_message); + const opening_message = await message.channel.messages.fetch(t_row.opening_message); await opening_message.edit( new MessageEmbed() diff --git a/src/database/index.js b/src/database/index.js index 08142d9..b0deb11 100644 --- a/src/database/index.js +++ b/src/database/index.js @@ -14,7 +14,7 @@ module.exports = async (client) => { DB_NAME } = process.env; - let type = (DB_TYPE || 'sqlite').toLowerCase(); + const type = (DB_TYPE || 'sqlite').toLowerCase(); const supported = Object.keys(types); if (!supported.includes(type)) { @@ -25,7 +25,7 @@ module.exports = async (client) => { try { types[type].packages.forEach(pkg => require(pkg)); } catch { - let required = types[type].packages.map(i => `"${i}"`).join(' and '); + const required = types[type].packages.map(i => `"${i}"`).join(' and '); client.log.error(new Error(`Please install the package(s) for your selected database type: ${required}`)); return process.exit(); } diff --git a/src/database/models/guild.model.js b/src/database/models/guild.model.js index e76dae0..5792378 100644 --- a/src/database/models/guild.model.js +++ b/src/database/models/guild.model.js @@ -39,6 +39,10 @@ module.exports = ({ config }, sequelize) => { type: DataTypes.STRING, defaultValue: 'GREEN' }, + tags: { + type: DataTypes.JSON, + defaultValue: {} + } }, { tableName: DB_TABLE_PREFIX + 'guilds' }); diff --git a/src/index.js b/src/index.js index 4528317..c1a7303 100644 --- a/src/index.js +++ b/src/index.js @@ -50,8 +50,8 @@ if (!checkFile('./.env', './example.env')) { const file = path('./.env'); const crypto = require('crypto'); - let key = 'DB_ENCRYPTION_KEY='; - let value = crypto + const key = 'DB_ENCRYPTION_KEY='; + const value = crypto .randomBytes(24) .toString('hex'); @@ -132,14 +132,14 @@ class Bot extends Client { /** A [Cryptr](https://www.npmjs.com/package/cryptr) instance */ this.cryptr = new Cryptr(process.env.DB_ENCRYPTION_KEY); - let locales = {}; + const locales = {}; fs.readdirSync(path('./src/locales')) .filter(file => file.endsWith('.json')) .forEach(file => { - let data = fs.readFileSync(path(`./src/locales/${file}`), { + const data = fs.readFileSync(path(`./src/locales/${file}`), { encoding: 'utf8' }); - let name = file.slice(0, file.length - 5); + const name = file.slice(0, file.length - 5); locales[name] = JSON.parse(data); }); @@ -179,7 +179,7 @@ class Bot extends Client { * You can see the source here: https://github.com/discord-tickets/stats */ if (this.config.super_secret_setting) { // you can disable it if you really want - let tickets = await this.db.models.Ticket.count(); + const tickets = await this.db.models.Ticket.count(); await fetch(`https://stats.discordtickets.app/client?id=${this.user.id}&tickets=${tickets}`, { method: 'post', }).catch(e => { @@ -187,7 +187,7 @@ class Bot extends Client { this.log.debug(e); }); this.guilds.cache.forEach(async g => { - let members = (await g.fetch()).approximateMemberCount; + const members = (await g.fetch()).approximateMemberCount; await fetch(`https://stats.discordtickets.app/guild?id=${g.id}&members=${members}`, { method: 'post', }).catch(e => { diff --git a/src/listeners/guildMemberRemove.js b/src/listeners/guildMemberRemove.js index 1d76780..7de5c04 100644 --- a/src/listeners/guildMemberRemove.js +++ b/src/listeners/guildMemberRemove.js @@ -8,14 +8,14 @@ module.exports = class GuildMemberRemoveEventListener extends EventListener { } async execute(member) { - let tickets = await this.client.db.models.Ticket.findAndCountAll({ + const tickets = await this.client.db.models.Ticket.findAndCountAll({ where: { creator: member.id, guild: member.guild.id } }); - for (let ticket of tickets.rows) { + for (const ticket of tickets.rows) { await this.client.tickets.close(ticket.id, null, member.guild.id, 'Member left the guild'); } diff --git a/src/listeners/message.js b/src/listeners/message.js index 694f76e..a98adcd 100644 --- a/src/listeners/message.js +++ b/src/listeners/message.js @@ -17,7 +17,7 @@ module.exports = class MessageEventListener extends EventListener { if (!settings) settings = await message.guild.createSettings(); const i18n = this.client.i18n.getLocale(settings.locale); - let t_row = await this.client.db.models.Ticket.findOne({ + const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } @@ -34,7 +34,7 @@ module.exports = class MessageEventListener extends EventListener { } else { if (message.author.bot) return; - let p_row = await this.client.db.models.Panel.findOne({ + const p_row = await this.client.db.models.Panel.findOne({ where: { channel: message.channel.id } @@ -45,13 +45,13 @@ module.exports = class MessageEventListener extends EventListener { await message.delete(); - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: p_row.categories } }); - let tickets = await this.client.db.models.Ticket.findAndCountAll({ + const tickets = await this.client.db.models.Ticket.findAndCountAll({ where: { category: cat_row.id, creator: message.author.id, @@ -75,10 +75,10 @@ module.exports = class MessageEventListener extends EventListener { response = await message.channel.send(embed); } } else { - let list = tickets.rows.map(row => { + const list = tickets.rows.map(row => { if (row.topic) { - let description = row.topic.substring(0, 30); - let ellipses = row.topic.length > 30 ? '...' : ''; + const description = row.topic.substring(0, 30); + const ellipses = row.topic.length > 30 ? '...' : ''; return `<#${row.id}>: \`${description}${ellipses}\``; } else { return `<#${row.id}>`; diff --git a/src/listeners/messageReactionAdd.js b/src/listeners/messageReactionAdd.js index 9496935..2a03db9 100644 --- a/src/listeners/messageReactionAdd.js +++ b/src/listeners/messageReactionAdd.js @@ -50,7 +50,7 @@ module.exports = class MessageReactionAddEventListener extends EventListener { }); } - let t_row = await this.client.db.models.Ticket.findOne({ + const t_row = await this.client.db.models.Ticket.findOne({ where: { id: channel.id } @@ -68,13 +68,13 @@ module.exports = class MessageReactionAddEventListener extends EventListener { VIEW_CHANNEL: true, }, `Ticket claimed by ${member.user.tag}`); - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: t_row.category } }); - for (let role of cat_row.roles) { + for (const role of cat_row.roles) { await channel.updateOverwrite(role, { VIEW_CHANNEL: false, }, `Ticket claimed by ${member.user.tag}`); @@ -94,7 +94,7 @@ module.exports = class MessageReactionAddEventListener extends EventListener { await r.users.remove(u.id); } } else { - let p_row = await this.client.db.models.Panel.findOne({ + const p_row = await this.client.db.models.Panel.findOne({ where: { message: r.message.id } @@ -104,16 +104,16 @@ module.exports = class MessageReactionAddEventListener extends EventListener { // panels await r.users.remove(u.id); - let category_id = p_row.categories[r.emoji.name]; + const category_id = p_row.categories[r.emoji.name]; if (!category_id) return; - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: category_id } }); - let tickets = await this.client.db.models.Ticket.findAndCountAll({ + const tickets = await this.client.db.models.Ticket.findAndCountAll({ where: { category: cat_row.id, creator: u.id, @@ -137,10 +137,10 @@ module.exports = class MessageReactionAddEventListener extends EventListener { response = await channel.send(embed); } } else { - let list = tickets.rows.map(row => { + const list = tickets.rows.map(row => { if (row.topic) { - let description = row.topic.substring(0, 30); - let ellipses = row.topic.length > 30 ? '...' : ''; + const description = row.topic.substring(0, 30); + const ellipses = row.topic.length > 30 ? '...' : ''; return `<#${row.id}>: \`${description}${ellipses}\``; } else { return `<#${row.id}>`; diff --git a/src/listeners/messageReactionRemove.js b/src/listeners/messageReactionRemove.js index acbe387..3045e92 100644 --- a/src/listeners/messageReactionRemove.js +++ b/src/listeners/messageReactionRemove.js @@ -39,7 +39,7 @@ module.exports = class MessageReactionRemoveEventListener extends EventListener const channel = r.message.channel; const member = await guild.members.fetch(u.id); - let t_row = await this.client.db.models.Ticket.findOne({ + const t_row = await this.client.db.models.Ticket.findOne({ where: { id: channel.id } @@ -57,13 +57,13 @@ module.exports = class MessageReactionRemoveEventListener extends EventListener .get(member.user.id) ?.delete(`Ticket released by ${member.user.tag}`); - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: t_row.category } }); - for (let role of cat_row.roles) { + for (const role of cat_row.roles) { await channel.updateOverwrite(role, { VIEW_CHANNEL: true, }, `Ticket released by ${member.user.tag}`); diff --git a/src/listeners/ready.js b/src/listeners/ready.js index ebdd60d..fbc6b53 100644 --- a/src/listeners/ready.js +++ b/src/listeners/ready.js @@ -18,7 +18,7 @@ module.exports = class ReadyEventListener extends EventListener { if (this.client.config.presence.presences.length > 1) { const { selectPresence } = require('../utils/discord'); setInterval(() => { - let presence = selectPresence(); + const presence = selectPresence(); this.client.user.setPresence(presence); this.client.log.debug(`Updated presence: ${presence.activity.type} ${presence.activity.name}`); }, this.client.config.presence.duration * 1000); diff --git a/src/modules/commands/command.js b/src/modules/commands/command.js index 2e6afcd..fa26f18 100644 --- a/src/modules/commands/command.js +++ b/src/modules/commands/command.js @@ -120,14 +120,14 @@ module.exports = class Command { * @returns {Message} */ async sendUsage(channel, alias) { - let settings = await channel.guild.settings; + const settings = await channel.guild.settings; if (!alias) alias = this.name; const prefix = settings.command_prefix; const i18n = this.client.i18n.getLocale(settings.locale); const addArgs = (embed, arg) => { - let required = arg.required ? '`❗` ' : ''; + const required = arg.required ? '`❗` ' : ''; let description = `» ${i18n('cmd_usage.args.description', arg.description)}`; if (arg.example) description += `\n» ${i18n('cmd_usage.args.example', arg.example)}`; embed.addField(required + arg.name, description); diff --git a/src/modules/commands/manager.js b/src/modules/commands/manager.js index 7138642..1eca5e3 100644 --- a/src/modules/commands/manager.js +++ b/src/modules/commands/manager.js @@ -48,7 +48,7 @@ module.exports = class CommandManager { const is_internal = (exists && cmd.internal) || (exists && this.commands.get(cmd.name).internal); if (is_internal) { - let plugin = this.client.plugins.plugins.find(p => p.commands.includes(cmd.name)); + const plugin = this.client.plugins.plugins.find(p => p.commands.includes(cmd.name)); if (plugin) this.client.log.commands(`The "${plugin.name}" plugin has overridden the internal "${cmd.name}" command`); else @@ -69,7 +69,7 @@ module.exports = class CommandManager { async handle(message) { if (message.author.bot) return; // ignore self and other bots - let settings = await message.guild.settings; + const settings = await message.guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); let is_blacklisted = false; @@ -100,14 +100,14 @@ module.exports = class CommandManager { let cmd_name = message.content.match(new RegExp(`^(${escaped_prefix}|${client_mention}\\s?)(\\S+)`, 'mi')); // capture prefix and command if (!cmd_name) return; // stop here if the message is not a command - let raw_args = message.content.replace(cmd_name[0], '').trim(); // remove the prefix and command + const raw_args = message.content.replace(cmd_name[0], '').trim(); // remove the prefix and command cmd_name = cmd_name[2].toLowerCase(); // set cmd_name to the actual command alias, effectively removing the prefix const cmd = this.commands.find(cmd => cmd.aliases.includes(cmd_name)); if (!cmd) return; - let bot_permissions = message.guild.me.permissionsIn(message.channel); - let required_bot_permissions = [ + const bot_permissions = message.guild.me.permissionsIn(message.channel); + const required_bot_permissions = [ 'ADD_REACTIONS', 'ATTACH_FILES', 'EMBED_LINKS', @@ -118,7 +118,7 @@ module.exports = class CommandManager { ]; if (!bot_permissions.has(required_bot_permissions)) { - let perms = required_bot_permissions.map(p => `\`${p}\``).join(', '); + const perms = required_bot_permissions.map(p => `\`${p}\``).join(', '); if (bot_permissions.has(['EMBED_LINKS', 'SEND_MESSAGES'])) { await message.channel.send( new MessageEmbed() @@ -138,7 +138,7 @@ module.exports = class CommandManager { const missing_permissions = cmd.permissions instanceof Array && !message.member.hasPermission(cmd.permissions); if (missing_permissions) { - let perms = cmd.permissions.map(p => `\`${p}\``).join(', '); + const perms = cmd.permissions.map(p => `\`${p}\``).join(', '); return await message.channel.send( new MessageEmbed() .setColor(settings.error_colour) @@ -162,7 +162,7 @@ module.exports = class CommandManager { try { args = parseArgs(cmd.args, { argv: argv(raw_args) }); } catch (error) { - let help_cmd = `${settings.command_prefix}${i18n('commands.help.name')} ${cmd_name}`; + const help_cmd = `${settings.command_prefix}${i18n('commands.help.name')} ${cmd_name}`; return await message.channel.send( new MessageEmbed() .setColor(settings.error_colour) @@ -170,7 +170,7 @@ module.exports = class CommandManager { .setDescription(i18n('cmd_usage.invalid_named_args.description', error.message, help_cmd)) ); } - for (let arg of cmd.args) { + for (const arg of cmd.args) { if (arg.required && args[arg.name] === undefined) { return await cmd.sendUsage(message.channel, cmd_name); // send usage if any required arg is missing } diff --git a/src/modules/listeners/loader.js b/src/modules/listeners/loader.js index a6e61f3..2c1cd9c 100644 --- a/src/modules/listeners/loader.js +++ b/src/modules/listeners/loader.js @@ -22,7 +22,7 @@ module.exports = class ListenerLoader { try { file = require(`../../listeners/${file}`); const listener = new file(this.client); - let on = listener.once ? 'once' : 'on'; + const on = listener.once ? 'once' : 'on'; if (listener.raw) this.client.ws[on](listener.event, (...data) => listener.execute(...data)); else diff --git a/src/modules/plugins/manager.js b/src/modules/plugins/manager.js index 36cc26d..9e938e6 100644 --- a/src/modules/plugins/manager.js +++ b/src/modules/plugins/manager.js @@ -55,7 +55,7 @@ module.exports = class PluginManager { author = author.name ?? 'unknown'; } - let about = { + const about = { id, version, author, @@ -79,8 +79,8 @@ module.exports = class PluginManager { load() { this.client.config.plugins.forEach(plugin => { try { - let main = require(plugin); - let pkg = require(`${plugin}/package.json`); + const main = require(plugin); + const pkg = require(`${plugin}/package.json`); this.register(main, pkg); } catch (e) { this.handleError(plugin); diff --git a/src/modules/plugins/plugin.js b/src/modules/plugins/plugin.js index e251dc4..c39f62c 100644 --- a/src/modules/plugins/plugin.js +++ b/src/modules/plugins/plugin.js @@ -27,7 +27,7 @@ module.exports = class Plugin { /** An official plugin? */ this.official = this.manager.official.includes(this.id); - let { + const { id, version, author, @@ -70,7 +70,7 @@ module.exports = class Plugin { */ this.description = description; - let clean = this.id.replace(/@[-_a-zA-Z0-9]+\//, ''); + const clean = this.id.replace(/@[-_a-zA-Z0-9]+\//, ''); /** * Information about the plugin directory @@ -104,7 +104,7 @@ module.exports = class Plugin { */ createConfig(template) { this.createDirectory(); - let file = join(this.directory.path, 'config.json'); + const file = join(this.directory.path, 'config.json'); if (!fs.existsSync(file)) { this.client.log.plugins(`Creating plugin config file for "${this.name}"`); fs.writeFileSync(file, JSON.stringify(template, null, 2)); @@ -120,7 +120,7 @@ module.exports = class Plugin { */ resetConfig(template) { this.createDirectory(); - let file = join(this.directory.path, 'config.json'); + const file = join(this.directory.path, 'config.json'); this.client.log.plugins(`Resetting plugin config file for "${this.name}"`); fs.writeFileSync(file, JSON.stringify(template, null, 2)); } diff --git a/src/modules/tickets/archives.js b/src/modules/tickets/archives.js index 5594f6a..9567a4b 100644 --- a/src/modules/tickets/archives.js +++ b/src/modules/tickets/archives.js @@ -19,7 +19,7 @@ module.exports = class TicketArchives { async addMessage(message) { try { // await this.client.db.transaction(async t => { - let t_row = await this.client.db.models.Ticket.findOne({ + const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id }, @@ -53,7 +53,7 @@ module.exports = class TicketArchives { async updateMessage(message) { try { // await this.client.db.transaction(async t => { - let m_row = await this.client.db.models.Message.findOne({ + const m_row = await this.client.db.models.Message.findOne({ where: { id: message.id }, @@ -86,7 +86,7 @@ module.exports = class TicketArchives { async deleteMessage(message) { try { // await this.client.db.transaction(async t => { - let msg = await this.client.db.models.Message.findOne({ + const msg = await this.client.db.models.Message.findOne({ where: { id: message.id }, @@ -129,12 +129,12 @@ module.exports = class TicketArchives { try { // await this.client.db.transaction(async t => { - let u_model_data = { + const u_model_data = { user: member.user.id, ticket: ticket_id }; - let [u_row] = await this.client.db.models.UserEntity.findOrCreate({ + const [u_row] = await this.client.db.models.UserEntity.findOrCreate({ where: u_model_data, defaults: { ...u_model_data, @@ -163,11 +163,11 @@ module.exports = class TicketArchives { async updateChannel(ticket_id, channel) { try { // await this.client.db.transaction(async t => { - let c_model_data = { + const c_model_data = { channel: channel.id, ticket: ticket_id }; - let [c_row] = await this.client.db.models.ChannelEntity.findOrCreate({ + const [c_row] = await this.client.db.models.ChannelEntity.findOrCreate({ where: c_model_data, defaults: c_model_data, /* transaction: t */ @@ -188,11 +188,11 @@ module.exports = class TicketArchives { async updateRole(ticket_id, role) { try { // await this.client.db.transaction(async t => { - let r_model_data = { + const r_model_data = { role: role.id, ticket: ticket_id }; - let [r_row] = await this.client.db.models.RoleEntity.findOrCreate({ + const [r_row] = await this.client.db.models.RoleEntity.findOrCreate({ where: r_model_data, defaults: r_model_data, /* transaction: t */ diff --git a/src/modules/tickets/manager.js b/src/modules/tickets/manager.js index 2fe7d4d..18680ec 100644 --- a/src/modules/tickets/manager.js +++ b/src/modules/tickets/manager.js @@ -30,7 +30,7 @@ module.exports = class TicketManager extends EventEmitter { async create(guild_id, creator_id, category_id, topic) { if (!topic) topic = ''; - let cat_row = await this.client.db.models.Category.findOne({ + const cat_row = await this.client.db.models.Category.findOne({ where: { id: category_id } @@ -39,24 +39,24 @@ module.exports = class TicketManager extends EventEmitter { if (!cat_row) throw new Error('Ticket category does not exist'); - let cat_channel = await this.client.channels.fetch(category_id); + const cat_channel = await this.client.channels.fetch(category_id); if (cat_channel.children.size >= 50) throw new Error('Ticket category has reached child channel limit (50)'); - let number = (await this.client.db.models.Ticket.count({ + const number = (await this.client.db.models.Ticket.count({ where: { guild: guild_id } })) + 1; - let guild = this.client.guilds.cache.get(guild_id); - let member = await guild.members.fetch(creator_id); - let name = cat_row.name_format + const guild = this.client.guilds.cache.get(guild_id); + const member = await guild.members.fetch(creator_id); + const name = cat_row.name_format .replace(/{+\s?(user)?name\s?}+/gi, member.displayName) .replace(/{+\s?num(ber)?\s?}+/gi, number); - let t_channel = await guild.channels.create(name, { + const t_channel = await guild.channels.create(name, { type: 'text', topic: `${member}${topic.length > 0 ? ` | ${topic}` : ''}`, parent: category_id, @@ -70,7 +70,7 @@ module.exports = class TicketManager extends EventEmitter { ATTACH_FILES: true }, `Ticket channel created by ${member.user.tag}`); - let t_row = await this.client.db.models.Ticket.create({ + const t_row = await this.client.db.models.Ticket.create({ id: t_channel.id, number, guild: guild_id, @@ -80,7 +80,7 @@ module.exports = class TicketManager extends EventEmitter { }); (async () => { - let settings = await guild.settings; + const settings = await guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); topic = t_row.topic @@ -88,7 +88,7 @@ module.exports = class TicketManager extends EventEmitter { : ''; if (cat_row.ping instanceof Array && cat_row.ping.length > 0) { - let mentions = cat_row.ping.map(id => id === 'everyone' + const mentions = cat_row.ping.map(id => id === 'everyone' ? '@everyone' : id === 'here' ? '@here' @@ -101,10 +101,10 @@ module.exports = class TicketManager extends EventEmitter { await t_channel.send(cat_row.image); } - let description = cat_row.opening_message + const description = cat_row.opening_message .replace(/{+\s?(user)?name\s?}+/gi, member.displayName) .replace(/{+\s?(tag|ping|mention)?\s?}+/gi, member.user.toString()); - let embed = new MessageEmbed() + const embed = new MessageEmbed() .setColor(settings.colour) .setAuthor(member.user.username, member.user.displayAvatarURL()) .setDescription(description) @@ -112,14 +112,14 @@ module.exports = class TicketManager extends EventEmitter { if (topic) embed.addField(i18n('ticket.opening_message.fields.topic'), topic); - let sent = await t_channel.send(member.user.toString(), embed); + const sent = await t_channel.send(member.user.toString(), embed); await sent.pin({ reason: 'Ticket opening message' }); await t_row.update({ opening_message: sent.id }); - let pinned = t_channel.messages.cache.last(); + const pinned = t_channel.messages.cache.last(); if (pinned.system) { pinned @@ -139,7 +139,7 @@ module.exports = class TicketManager extends EventEmitter { } if (cat_row.require_topic && topic.length === 0) { - let collector_message = await t_channel.send( + const collector_message = await t_channel.send( new MessageEmbed() .setColor(settings.colour) .setTitle('⚠️ ' + i18n('commands.new.request_topic.title')) @@ -149,7 +149,7 @@ module.exports = class TicketManager extends EventEmitter { const collector_filter = (message) => message.author.id === t_row.creator; - let collector = t_channel.createMessageCollector(collector_filter, { + const collector = t_channel.createMessageCollector(collector_filter, { time: 120000 }); @@ -211,24 +211,24 @@ module.exports = class TicketManager extends EventEmitter { * @param {string} [reason] - The reason for closing the ticket */ async close(ticket_id, closer_id, guild_id, reason) { - let t_row = await this.resolve(ticket_id, guild_id); + const t_row = await this.resolve(ticket_id, guild_id); if (!t_row) throw new Error(`A ticket with the ID or number "${ticket_id}" could not be resolved`); ticket_id = t_row.id; this.emit('beforeClose', ticket_id); - let guild = this.client.guilds.cache.get(t_row.guild); - let settings = await guild.settings; + const guild = this.client.guilds.cache.get(t_row.guild); + const settings = await guild.settings; const i18n = this.client.i18n.getLocale(settings.locale); - let channel = await this.client.channels.fetch(t_row.id); + const channel = await this.client.channels.fetch(t_row.id); if (closer_id) { - let member = await guild.members.fetch(closer_id); + const member = await guild.members.fetch(closer_id); await this.archives.updateMember(ticket_id, member); if (channel) { - let description = reason + const description = reason ? i18n('ticket.closed_by_member_with_reason.description', member.user.toString(), reason) : i18n('ticket.closed_by_member.description', member.user.toString()); await channel.send( @@ -248,7 +248,7 @@ module.exports = class TicketManager extends EventEmitter { this.client.log.info(`${member.user.tag} closed a ticket (${ticket_id})${reason ? `: "${reason}"` : ''}`); } else { if (channel) { - let description = reason + const description = reason ? i18n('ticket.closed_with_reason.description') : i18n('ticket.closed.description'); await channel.send( @@ -267,7 +267,7 @@ module.exports = class TicketManager extends EventEmitter { this.client.log.info(`A ticket was closed (${ticket_id})${reason ? `: "${reason}"` : ''}`); } - let pinned = await channel.messages.fetchPinned(); + const pinned = await channel.messages.fetchPinned(); await t_row.update({ open: false, diff --git a/src/settings_schema.json b/src/settings.schema.json similarity index 96% rename from src/settings_schema.json rename to src/settings.schema.json index dba9760..73c07f4 100644 --- a/src/settings_schema.json +++ b/src/settings.schema.json @@ -95,6 +95,9 @@ }, "surveys": { "type": "object" + }, + "tags": { + "type": "object" } }, "required": [ @@ -106,6 +109,7 @@ "locale", "log_messages", "success_colour", - "surveys" + "surveys", + "tags" ] } \ No newline at end of file diff --git a/src/structures/guild.js b/src/structures/guild.js index 914b2eb..3e11bba 100644 --- a/src/structures/guild.js +++ b/src/structures/guild.js @@ -13,7 +13,7 @@ Structures.extend('Guild', Guild => { } async deleteSettings() { - let row = await this.settings; + const row = await this.settings; return await row.destroy(); } diff --git a/src/structures/guild_member.js b/src/structures/guild_member.js index 1d31cd5..6539170 100644 --- a/src/structures/guild_member.js +++ b/src/structures/guild_member.js @@ -7,7 +7,7 @@ Structures.extend('GuildMember', GuildMember => { } async isStaff() { - let guild_categories = await this.client.db.models.Category.findAll({ + const guild_categories = await this.client.db.models.Category.findAll({ where: { guild: this.guild.id } diff --git a/src/updater.js b/src/updater.js index 309cd45..dccdd69 100644 --- a/src/updater.js +++ b/src/updater.js @@ -4,21 +4,21 @@ const link = require('terminal-link'); const semver = require('semver'); const { format } = require('leekslazylogger-fastify'); -let { version: current } = require('../package.json'); +const { version: current } = require('../package.json'); module.exports = async client => { if (!client.config.update_notice) return; const json = await (await fetch('https://api.github.com/repos/discord-tickets/bot/releases')).json(); const update = json[0]; - let latest = semver.coerce(update.tag_name); + const latest = semver.coerce(update.tag_name); if (!semver.valid(latest)) return; if (semver.lt(current, latest)) { client.log.notice(`There is an update available for Discord Tickets (${current} -> ${update.tag_name})`); - let lines = [ + const lines = [ `&k&6You are currently using &c${current}&6, the latest is &a${update.tag_name}&6.&r`, `&k&6Download "&f${update.name}&6" from&r`, link('&k&6the GitHub releases page.&r&6', 'https://github.com/discord-tickets/bot/releases/') diff --git a/src/utils/discord.js b/src/utils/discord.js index 8e1216b..d18ae04 100644 --- a/src/utils/discord.js +++ b/src/utils/discord.js @@ -18,7 +18,7 @@ module.exports = { * @returns {PresenceData} */ selectPresence: () => { - let length = config.presence.presences.length; + const length = config.presence.presences.length; if (length === 0) return {}; let num; @@ -33,7 +33,7 @@ module.exports = { num = current_presence; } - let { + const { activity: name, status, type, diff --git a/src/utils/index.js b/src/utils/index.js index 6bb6db0..84148a9 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,7 +1,7 @@ module.exports = { int2hex: (int) => int.toString(16).toUpperCase(), some: async (array, func) => { - for (let element of array) { + for (const element of array) { if (await func(element)) return true; } return false;