From 83501cf35e2041fbc82fdae34ba18b9a327343af Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sat, 12 Mar 2022 21:30:15 +0000 Subject: [PATCH] [CodeFactor] Apply fixes to commit e1a49cc --- src/commands/profile/index.js | 4 +- src/commands/reputation/addons/give.js | 58 ++++++++++++------- src/commands/reputation/index.js | 5 +- src/commands/settings/guild/addons/credits.js | 10 +++- .../settings/guild/addons/pterodactyl.js | 6 +- src/commands/settings/index.js | 30 +++++++--- src/commands/utilities/addons/lookup.js | 35 ++++++++--- src/commands/utilities/addons/users.js | 7 ++- src/commands/utilities/index.js | 4 +- src/deploy-commands.js | 17 ++++-- src/events/guildCreate.js | 4 +- src/events/interactionCreate.js | 5 +- src/events/messageCreate.js | 29 ++++++++-- src/events/ready.js | 4 +- src/handlers/locale.js | 13 ++++- src/helpers/creditNoun.js | 3 +- 16 files changed, 173 insertions(+), 61 deletions(-) diff --git a/src/commands/profile/index.js b/src/commands/profile/index.js index 6cdb8a6..d62947d 100644 --- a/src/commands/profile/index.js +++ b/src/commands/profile/index.js @@ -11,7 +11,9 @@ module.exports = { .setName('view') .setDescription('View a profile.') .addUserOption((option) => - option.setName('target').setDescription('The profile you wish to view') + option + .setName('target') + .setDescription('The profile you wish to view') ) ), async execute(interaction) { diff --git a/src/commands/reputation/addons/give.js b/src/commands/reputation/addons/give.js index 2029815..3702888 100644 --- a/src/commands/reputation/addons/give.js +++ b/src/commands/reputation/addons/give.js @@ -35,12 +35,18 @@ module.exports = async (interaction) => { // Build embed const embed = { - title: i18next.t('commands:reputation:addons:give:version03:embed:title', { - lng: await user.language, - }), - description: i18next.t('commands:reputation:addons:give:version02:embed:title', { - lng: await user.language, - }), + title: i18next.t( + 'commands:reputation:addons:give:version03:embed:title', + { + lng: await user.language, + } + ), + description: i18next.t( + 'commands:reputation:addons:give:version02:embed:title', + { + lng: await user.language, + } + ), }; // Send reply @@ -64,14 +70,20 @@ module.exports = async (interaction) => { // Build embed const embed = { - title: i18next.t('commands:reputation:addons:give:version02:embed:title', { - lng: await user.language, - }), - description: i18next.t('commands:reputation:addons:give:version02:embed:description', { - lng: await user.language, - user: target, - type, - }), + title: i18next.t( + 'commands:reputation:addons:give:version02:embed:title', + { + lng: await user.language, + } + ), + description: i18next.t( + 'commands:reputation:addons:give:version02:embed:description', + { + lng: await user.language, + user: target, + type, + } + ), timestamp: new Date(), color: config.colors.success, footer: { iconURL: config.footer.icon, text: config.footer.text }, @@ -110,12 +122,18 @@ module.exports = async (interaction) => { }, 86400000); } else { const embed = { - title: i18next.t('commands:reputation:addons:give:version01:embed:title', { - lng: await user.language, - }), - description: i18next.t('commands:reputation:addons:give:version01:embed:description', { - lng: await user.language, - }), + title: i18next.t( + 'commands:reputation:addons:give:version01:embed:title', + { + lng: await user.language, + } + ), + description: i18next.t( + 'commands:reputation:addons:give:version01:embed:description', + { + lng: await user.language, + } + ), timestamp: new Date(), color: config.colors.error, footer: { iconURL: config.footer.icon, text: config.footer.text }, diff --git a/src/commands/reputation/index.js b/src/commands/reputation/index.js index 6dfb014..737a95d 100644 --- a/src/commands/reputation/index.js +++ b/src/commands/reputation/index.js @@ -13,7 +13,10 @@ module.exports = { .setName('give') .setDescription('Give reputation for a user') .addUserOption((option) => - option.setName('target').setDescription('The user you want to repute.').setRequired(true) + option + .setName('target') + .setDescription('The user you want to repute.') + .setRequired(true) ) .addStringOption((option) => option diff --git a/src/commands/settings/guild/addons/credits.js b/src/commands/settings/guild/addons/credits.js index 764fb5a..694fbb8 100644 --- a/src/commands/settings/guild/addons/credits.js +++ b/src/commands/settings/guild/addons/credits.js @@ -42,8 +42,10 @@ module.exports = async (interaction) => { guild.credits.status = status !== null ? status : guild.credits.status; guild.credits.rate = rate !== null ? rate : guild.credits.rate; guild.credits.timeout = timeout !== null ? timeout : guild.credits.timeout; - guild.credits.workRate = workRate !== null ? workRate : guild.credits.workRate; - guild.credits.workTimeout = workTimeout !== null ? workTimeout : guild.credits.workTimeout; + guild.credits.workRate = + workRate !== null ? workRate : guild.credits.workRate; + guild.credits.workTimeout = + workTimeout !== null ? workTimeout : guild.credits.workTimeout; guild.credits.minimumLength = minimumLength !== null ? minimumLength : guild.credits.minimumLength; @@ -86,6 +88,8 @@ module.exports = async (interaction) => { // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} has changed credit details.`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} has changed credit details.` + ); }); }; diff --git a/src/commands/settings/guild/addons/pterodactyl.js b/src/commands/settings/guild/addons/pterodactyl.js index 2057b0c..fcc5d8c 100644 --- a/src/commands/settings/guild/addons/pterodactyl.js +++ b/src/commands/settings/guild/addons/pterodactyl.js @@ -32,7 +32,11 @@ module.exports = async (interaction) => { // Update API credentials await apis - .findOneAndUpdate({ guildId: member.guild.id }, { url, token }, { new: true, upsert: true }) + .findOneAndUpdate( + { guildId: member.guild.id }, + { url, token }, + { new: true, upsert: true } + ) .then(async () => { // Build embed diff --git a/src/commands/settings/index.js b/src/commands/settings/index.js index dc024b0..2335982 100644 --- a/src/commands/settings/index.js +++ b/src/commands/settings/index.js @@ -17,10 +17,16 @@ module.exports = { .setName('pterodactyl') .setDescription('Controlpanel.gg') .addStringOption((option) => - option.setName('url').setDescription('The api url').setRequired(true) + option + .setName('url') + .setDescription('The api url') + .setRequired(true) ) .addStringOption((option) => - option.setName('token').setDescription('The api token').setRequired(true) + option + .setName('token') + .setDescription('The api token') + .setRequired(true) ) ) .addSubcommand((command) => @@ -28,10 +34,14 @@ module.exports = { .setName('credits') .setDescription('Credits') .addBooleanOption((option) => - option.setName('status').setDescription('Should credits be enabled?') + option + .setName('status') + .setDescription('Should credits be enabled?') ) .addNumberOption((option) => - option.setName('rate').setDescription('Amount of credits per message.') + option + .setName('rate') + .setDescription('Amount of credits per message.') ) .addNumberOption((option) => option @@ -39,17 +49,23 @@ module.exports = { .setDescription('Minimum length of message to earn credits.') ) .addNumberOption((option) => - option.setName('work-rate').setDescription('Maximum amount of credits on work.') + option + .setName('work-rate') + .setDescription('Maximum amount of credits on work.') ) .addNumberOption((option) => option .setName('work-timeout') - .setDescription('Timeout between work schedules (milliseconds).') + .setDescription( + 'Timeout between work schedules (milliseconds).' + ) ) .addNumberOption((option) => option .setName('timeout') - .setDescription('Timeout between earning credits (milliseconds).') + .setDescription( + 'Timeout between earning credits (milliseconds).' + ) ) ) ) diff --git a/src/commands/utilities/addons/lookup.js b/src/commands/utilities/addons/lookup.js index 39a2473..da84e45 100644 --- a/src/commands/utilities/addons/lookup.js +++ b/src/commands/utilities/addons/lookup.js @@ -24,17 +24,38 @@ module.exports = async (interaction) => { title: 'Lookup', fields: [ { name: 'AS', value: `${res.data.as || 'Not available'}` }, - { name: 'Country', value: `${res.data.country || 'Not available'}` }, - { name: 'Country Code', value: `${res.data.countryCode || 'Not available'}` }, - { name: 'Region', value: `${res.data.region || 'Not available'}` }, - { name: 'Region Name', value: `${res.data.regionName || 'Not available'}` }, + { + name: 'Country', + value: `${res.data.country || 'Not available'}`, + }, + { + name: 'Country Code', + value: `${res.data.countryCode || 'Not available'}`, + }, + { + name: 'Region', + value: `${res.data.region || 'Not available'}`, + }, + { + name: 'Region Name', + value: `${res.data.regionName || 'Not available'}`, + }, { name: 'City', value: `${res.data.city || 'Not available'}` }, { name: 'ZIP Code', value: `${res.data.zip || 'Not available'}` }, { name: 'Latitude', value: `${res.data.lat || 'Not available'}` }, - { name: 'Longitude', value: `${res.data.lon || 'Not available'}` }, - { name: 'Timezone', value: `${res.data.timezone || 'Not available'}` }, + { + name: 'Longitude', + value: `${res.data.lon || 'Not available'}`, + }, + { + name: 'Timezone', + value: `${res.data.timezone || 'Not available'}`, + }, { name: 'ISP', value: `${res.data.isp || 'Not available'}` }, - { name: 'Organization', value: `${res.data.org || 'Not available'}` }, + { + name: 'Organization', + value: `${res.data.org || 'Not available'}`, + }, ], color: config.colors.success, timestamp: new Date(), diff --git a/src/commands/utilities/addons/users.js b/src/commands/utilities/addons/users.js index b461ff2..2431f8c 100644 --- a/src/commands/utilities/addons/users.js +++ b/src/commands/utilities/addons/users.js @@ -8,13 +8,16 @@ module.exports = async (interaction) => { if (!interaction.member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) { const embed = { title: 'Users failed', - description: 'You need to have permission to manage this guild (MANAGE_GUILD)', + description: + 'You need to have permission to manage this guild (MANAGE_GUILD)', }; return await interaction.editReply({ embeds: [embed], ephemeral: true }); } // eslint-disable-next-line max-len - const userList = await interaction.client.users.cache.filter((user) => !user.bot); + const userList = await interaction.client.users.cache.filter( + (user) => !user.bot + ); userList.map((user) => { logger.info(user); diff --git a/src/commands/utilities/index.js b/src/commands/utilities/index.js index bf748aa..7cdfedc 100644 --- a/src/commands/utilities/index.js +++ b/src/commands/utilities/index.js @@ -11,7 +11,9 @@ module.exports = { .addSubcommand((subcommand) => subcommand .setName('lookup') - .setDescription('Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)') + .setDescription( + 'Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)' + ) .addStringOption((option) => option .setName('target') diff --git a/src/deploy-commands.js b/src/deploy-commands.js index bbe8d8d..1b64f2c 100644 --- a/src/deploy-commands.js +++ b/src/deploy-commands.js @@ -22,13 +22,20 @@ module.exports = async () => { const rest = new REST({ version: '9' }).setToken(config.bot.token); - await rest.put(Routes.applicationCommands(config.bot.clientId), { body: commands }); + await rest.put(Routes.applicationCommands(config.bot.clientId), { + body: commands, + }); await rest - .put(Routes.applicationGuildCommands(config.bot.clientId, config.bot.guildId), { - body: commands, - }) - .then(async () => logger.info('Successfully registered application commands.')) + .put( + Routes.applicationGuildCommands(config.bot.clientId, config.bot.guildId), + { + body: commands, + } + ) + .then(async () => + logger.info('Successfully registered application commands.') + ) .catch(async (err) => { await logger.error(err); }); diff --git a/src/events/guildCreate.js b/src/events/guildCreate.js index a132aee..ea9133e 100644 --- a/src/events/guildCreate.js +++ b/src/events/guildCreate.js @@ -6,7 +6,9 @@ module.exports = { const { client } = guild; await guilds.findOne({ guildId: guild.id }, { new: true, upsert: true }); await client.user.setPresence({ - activities: [{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }], + activities: [ + { type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }, + ], status: 'online', }); }, diff --git a/src/events/interactionCreate.js b/src/events/interactionCreate.js index 54d368f..e9d55d3 100644 --- a/src/events/interactionCreate.js +++ b/src/events/interactionCreate.js @@ -13,7 +13,10 @@ module.exports = { if (!command) return; - await guilds.findOne({ guildId: member.guild.id }, { new: true, upsert: true }); + await guilds.findOne( + { guildId: member.guild.id }, + { new: true, upsert: true } + ); try { await interaction.deferReply({ diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index fef2cc5..7ac0415 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -1,6 +1,12 @@ const logger = require('../handlers/logger'); -const { users, guilds, experiences, credits, timeouts } = require('../helpers/database/models'); +const { + users, + guilds, + experiences, + credits, + timeouts, +} = require('../helpers/database/models'); module.exports = { name: 'messageCreate', @@ -15,7 +21,10 @@ module.exports = { // Create user if not already created - await users.findOne({ userId: message.author.id }, { new: true, upsert: true }); + await users.findOne( + { userId: message.author.id }, + { new: true, upsert: true } + ); // Stop if message content is shorter than guild configured minimum length @@ -44,7 +53,9 @@ module.exports = { { new: true, upsert: true } ) .then(async () => - logger.debug(`Guild: ${message.guild.id} Credits added to user: ${message.author.id}`) + logger.debug( + `Guild: ${message.guild.id} Credits added to user: ${message.author.id}` + ) ) .catch(async (err) => { await logger.error(err); @@ -59,7 +70,9 @@ module.exports = { { new: true, upsert: true } ) .then(async () => - logger.debug(`Guild: ${message.guild.id} Points added to user: ${message.author.id}`) + logger.debug( + `Guild: ${message.guild.id} Points added to user: ${message.author.id}` + ) ) .catch(async (err) => { await logger.error(err); @@ -75,7 +88,9 @@ module.exports = { setTimeout(async () => { await logger.debug( - `Guild: ${message.guild.id} User: ${message.author.id} has not talked within last ${ + `Guild: ${message.guild.id} User: ${ + message.author.id + } has not talked within last ${ guild.credits.timeout / 1000 } seconds, credits can be given` ); @@ -90,7 +105,9 @@ module.exports = { }, guild.credits.timeout); } else { await logger.debug( - `Guild: ${message.guild.id} User: ${message.author.id} has talked within last ${ + `Guild: ${message.guild.id} User: ${ + message.author.id + } has talked within last ${ guild.credits.timeout / 1000 } seconds, no credits given` ); diff --git a/src/events/ready.js b/src/events/ready.js index 506856e..79eac57 100644 --- a/src/events/ready.js +++ b/src/events/ready.js @@ -6,7 +6,9 @@ module.exports = { async execute(client) { await logger.info(`Ready! Logged in as ${client.user.tag}`); await client.user.setPresence({ - activities: [{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }], + activities: [ + { type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }, + ], status: 'online', }); }, diff --git a/src/handlers/locale.js b/src/handlers/locale.js index 390de2a..83a04ca 100644 --- a/src/handlers/locale.js +++ b/src/handlers/locale.js @@ -32,11 +32,15 @@ module.exports = async () => { version02: { embed: { title: 'Reputation', - description: 'You have given {{user}} a {{type}} reputation!', + description: + 'You have given {{user}} a {{type}} reputation!', }, }, version03: { - embed: { title: 'Reputation', description: 'You can not repute yourself.' }, + embed: { + title: 'Reputation', + description: 'You can not repute yourself.', + }, }, }, }, @@ -94,7 +98,10 @@ module.exports = async () => { }, }, version03: { - embed: { title: 'Omdöme', description: 'Du kan inte ge dig själv ett omdöme.' }, + embed: { + title: 'Omdöme', + description: 'Du kan inte ge dig själv ett omdöme.', + }, }, }, }, diff --git a/src/helpers/creditNoun.js b/src/helpers/creditNoun.js index caadc51..34276c5 100644 --- a/src/helpers/creditNoun.js +++ b/src/helpers/creditNoun.js @@ -1 +1,2 @@ -module.exports = (amount) => `${amount <= 1 ? `${amount} credit` : `${amount} credits`}`; +module.exports = (amount) => + `${amount <= 1 ? `${amount} credit` : `${amount} credits`}`;