From d25f92a21a0f7e66328b49ad5962e78314b938bc Mon Sep 17 00:00:00 2001 From: VermiumSifell Date: Thu, 10 Mar 2022 09:24:33 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20made=20better=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc | 46 -------- .eslintrc.js | 13 ++- .prettierrc | 9 +- .vscode/extensions.json | 14 +++ .vscode/settings.json | 10 +- config.json.example | 22 +++- package.json | 1 + src/commands/admin/credits/addons/give.js | 6 +- src/commands/admin/credits/addons/index.js | 5 +- src/commands/admin/credits/addons/set.js | 6 +- src/commands/admin/credits/addons/take.js | 6 +- src/commands/admin/credits/addons/transfer.js | 11 +- src/commands/admin/credits/index.js | 10 +- src/commands/admin/index.js | 106 +++++++++++------- src/commands/credits/addons/balance.js | 12 +- src/commands/credits/addons/gift.js | 2 +- src/commands/credits/addons/work.js | 36 +++--- src/commands/credits/index.js | 58 ++++++---- src/commands/profile/addons/view.js | 78 ++++++++----- src/commands/profile/index.js | 10 +- src/commands/reputation/addons/give.js | 6 +- src/commands/reputation/index.js | 32 ++++-- src/commands/settings/guild/addons/credits.js | 25 ++--- .../settings/guild/addons/pterodactyl.js | 36 +++--- src/commands/settings/guild/index.js | 6 +- src/commands/settings/index.js | 96 ++++++++++------ .../settings/user/addons/appearance.js | 4 +- src/commands/utilities/addons/users.js | 4 +- src/commands/utilities/index.js | 30 +++-- src/deploy-commands.js | 5 +- src/events/guildCreate.js | 11 +- src/events/interactionCreate.js | 5 +- src/events/memberCreate.js | 1 - src/events/messageCreate.js | 49 ++++---- src/events/ready.js | 5 +- src/handlers/locale.js | 22 +++- src/helpers/database/models/apiSchema.js | 3 +- src/helpers/database/models/creditSchema.js | 2 +- .../database/models/experienceSchema.js | 2 +- src/helpers/database/models/guildSchema.js | 2 +- src/helpers/database/models/index.js | 7 +- src/helpers/database/models/timeoutSchema.js | 2 +- src/helpers/database/models/userSchema.js | 2 +- src/helpers/saveUser.js | 34 +++--- 44 files changed, 477 insertions(+), 375 deletions(-) delete mode 100644 .eslintrc create mode 100644 .vscode/extensions.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 622d18e..0000000 --- a/.eslintrc +++ /dev/null @@ -1,46 +0,0 @@ -{ - "extends": ["airbnb", "prettier"], - "plugins": ["prettier"], - "rules": { - "arrow-spacing": ["warn", { "before": true, "after": true }], - "brace-style": ["error", "stroustrup", { "allowSingleLine": true }], - "comma-dangle": ["error", "always-multiline"], - "comma-spacing": "error", - "comma-style": "error", - "curly": ["error", "multi-line", "consistent"], - "dot-location": ["error", "property"], - "handle-callback-err": "off", - "indent": ["error", "tab"], - "keyword-spacing": "error", - "max-nested-callbacks": ["error", { "max": 4 }], - "max-statements-per-line": ["error", { "max": 2 }], - "no-console": "off", - "no-empty-function": "error", - "no-floating-decimal": "error", - "no-inline-comments": "error", - "no-lonely-if": "error", - "no-multi-spaces": "error", - "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }], - "no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }], - "no-trailing-spaces": ["error"], - "no-var": "error", - "object-curly-spacing": ["error", "always"], - "prefer-const": "error", - "quotes": ["error", "single"], - "semi": ["error", "always"], - "space-before-blocks": "error", - "space-before-function-paren": [ - "error", - { - "anonymous": "never", - "named": "never", - "asyncArrow": "always" - } - ], - "space-in-parens": "error", - "space-infix-ops": "error", - "space-unary-ops": "error", - "spaced-comment": "error", - "yoda": "error" - } -} diff --git a/.eslintrc.js b/.eslintrc.js index e04d612..a77622a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,15 +1,16 @@ module.exports = { env: { - commonjs: true, + es6: true, + browser: true, es2021: true, - node: true, }, - extends: [ - 'airbnb-base', - ], + extends: ['airbnb-base', 'prettier'], parserOptions: { - ecmaVersion: 'latest', + ecmaVersion: 12, + sourceType: 'module', }, rules: { + 'prettier/prettier': 'error', }, + plugins: ['prettier'], }; diff --git a/.prettierrc b/.prettierrc index 1c99d1d..a9a2af9 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,7 @@ { - "printWidth": 100, - "singleQuote": true -} \ No newline at end of file + "trailingComma": "es5", + "tabWidth": 2, + "printWidth": 100, + "semi": true, + "singleQuote": true +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..2aa4b81 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,14 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "CoenraadS.bracket-pair-colorizer-2", + "seatonjiang.gitmoji-vscode" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index d4aa4da..fc02003 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -46,13 +46,5 @@ "titleBar.inactiveBackground": "#33669999", "titleBar.inactiveForeground": "#e7e7e799" }, - "cSpell.words": [ - "Controlpanel", - "discordjs", - "pino", - "runned", - "Timout", - "upsert", - "uuidv" - ] + "cSpell.words": ["Controlpanel", "discordjs", "pino", "runned", "Timout", "upsert", "uuidv"] } diff --git a/config.json.example b/config.json.example index 1fe26fb..d059beb 100644 --- a/config.json.example +++ b/config.json.example @@ -5,18 +5,30 @@ "guildId": "required" }, "credits": { - "url": "scheme://domain/api/", + "url": "scheme://domain/api/", "token": "required", "timeout": "5000", "rate": "1", "minimumLength": "5", - "excludedChannels": ["channel_id", "channel_id"] + "excludedChannels": [ + "channel_id", + "channel_id" + ] + }, + "colors": { + "success": "0x22bb33", + "error": "0xbb2124", + "wait": "0xf0ad4e" }, - "colors": { "success": "0x22bb33", "error": "0xbb2124", "wait": "0xf0ad4e" }, "mongodb": { "url": "mongodb+srv://username:password@server/database?retryWrites=true&w=majority" }, - "footer": { "icon": "https://avatars.githubusercontent.com/u/83163073", "text": "https://github.com/ZynerOrg/xyter" }, - "disable": { "redeem": false }, + "footer": { + "icon": "https://avatars.githubusercontent.com/u/83163073", + "text": "https://github.com/ZynerOrg/xyter" + }, + "disable": { + "redeem": false + }, "debug": false } diff --git a/package.json b/package.json index 9a0a02d..bf2117f 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "devDependencies": { "eslint": "8.10.0", "eslint-config-airbnb-base": "15.0.0", + "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "2.25.4" } } diff --git a/src/commands/admin/credits/addons/give.js b/src/commands/admin/credits/addons/give.js index 10f2fa2..b118bfc 100644 --- a/src/commands/admin/credits/addons/give.js +++ b/src/commands/admin/credits/addons/give.js @@ -77,7 +77,7 @@ module.exports = async (interaction) => { await logger.debug( `Administrator: ${interaction.user.username} gave ${ amount <= 1 ? `${amount} credit` : `${amount} credits` - } to ${user.username}`, + } to ${user.username}` ); // Send reply @@ -85,6 +85,8 @@ module.exports = async (interaction) => { // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} gave ${user.id} ${creditNoun(amount)}.`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} gave ${user.id} ${creditNoun(amount)}.` + ); }); }; diff --git a/src/commands/admin/credits/addons/index.js b/src/commands/admin/credits/addons/index.js index ab3352e..599d8aa 100644 --- a/src/commands/admin/credits/addons/index.js +++ b/src/commands/admin/credits/addons/index.js @@ -4,5 +4,8 @@ const take = require('./take'); const transfer = require('./transfer'); module.exports = { - give, set, take, transfer, + give, + set, + take, + transfer, }; diff --git a/src/commands/admin/credits/addons/set.js b/src/commands/admin/credits/addons/set.js index b1ab71e..bcd30d7 100644 --- a/src/commands/admin/credits/addons/set.js +++ b/src/commands/admin/credits/addons/set.js @@ -77,7 +77,7 @@ module.exports = async (interaction) => { await logger.debug( `Administrator: ${interaction.user.username} set ${ amount <= 1 ? `${amount} credit` : `${amount} credits` - } on ${user.username}`, + } on ${user.username}` ); // Send reply @@ -85,6 +85,8 @@ module.exports = async (interaction) => { // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} set ${user.id} to ${creditNoun(amount)}.`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} set ${user.id} to ${creditNoun(amount)}.` + ); }); }; diff --git a/src/commands/admin/credits/addons/take.js b/src/commands/admin/credits/addons/take.js index 5f34da6..8e9bdaa 100644 --- a/src/commands/admin/credits/addons/take.js +++ b/src/commands/admin/credits/addons/take.js @@ -77,7 +77,7 @@ module.exports = async (interaction) => { await logger.debug( `Administrator: ${interaction.user.username} took ${ amount <= 1 ? `${amount} credit` : `${amount} credits` - } from ${user.username}`, + } from ${user.username}` ); // Send reply @@ -85,6 +85,8 @@ module.exports = async (interaction) => { // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} took ${creditNoun(amount)} from ${user.id}.`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} took ${creditNoun(amount)} from ${user.id}.` + ); }); }; diff --git a/src/commands/admin/credits/addons/transfer.js b/src/commands/admin/credits/addons/transfer.js index a19494c..6231096 100644 --- a/src/commands/admin/credits/addons/transfer.js +++ b/src/commands/admin/credits/addons/transfer.js @@ -34,10 +34,7 @@ module.exports = async (interaction) => { // Get fromUser object - const fromUser = await credits.findOne({ - userId: from.id, - guildId: interaction.member.guild.id, - }); + const fromUser = await credits.findOne({ userId: from.id, guildId: interaction.member.guild.id }); // Get toUser object @@ -117,6 +114,10 @@ module.exports = async (interaction) => { // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} transferred ${creditNoun(amount)} from ${from.id} to ${to.id}.`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} transferred ${creditNoun(amount)} from ${ + from.id + } to ${to.id}.` + ); }); }; diff --git a/src/commands/admin/credits/index.js b/src/commands/admin/credits/index.js index dce4dee..d8dc5d6 100644 --- a/src/commands/admin/credits/index.js +++ b/src/commands/admin/credits/index.js @@ -2,9 +2,7 @@ const { Permissions } = require('discord.js'); const config = require('../../../../config.json'); const logger = require('../../../handlers/logger'); -const { - give, take, set, transfer, -} = require('./addons'); +const { give, take, set, transfer } = require('./addons'); module.exports = async (interaction) => { // Destructure member @@ -46,5 +44,9 @@ module.exports = async (interaction) => { // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} executed /${interaction.commandName} ${interaction.options.getSubcommandGroup()} ${interaction.options.getSubcommand()}`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} executed /${ + interaction.commandName + } ${interaction.options.getSubcommandGroup()} ${interaction.options.getSubcommand()}` + ); }; diff --git a/src/commands/admin/index.js b/src/commands/admin/index.js index cebc7a7..33501e1 100644 --- a/src/commands/admin/index.js +++ b/src/commands/admin/index.js @@ -7,45 +7,73 @@ module.exports = { data: new SlashCommandBuilder() .setName('admin') .setDescription('Admin actions.') - .addSubcommandGroup((group) => group - .setName('credits') - .setDescription('Manage credits.') - .addSubcommand((command) => command - .setName('give') - .setDescription('Give credits to a user') - .addUserOption((option) => option.setName('user').setDescription('The user you want to pay.').setRequired(true)) - .addIntegerOption((option) => option.setName('amount').setDescription('The amount you will pay.').setRequired(true))) - .addSubcommand((command) => command - .setName('set') - .setDescription('Set credits to a user') - .addUserOption((option) => option - .setName('user') - .setDescription('The user you want to set credits on.') - .setRequired(true)) - .addIntegerOption((option) => option.setName('amount').setDescription('The amount you will set.').setRequired(true))) - .addSubcommand((command) => command - .setName('take') - .setDescription('Take credits from a user') - .addUserOption((option) => option - .setName('user') - .setDescription('The user you want to take credits from.') - .setRequired(true)) - .addIntegerOption((option) => option.setName('amount').setDescription('The amount you will take.').setRequired(true))) - .addSubcommand((command) => command - .setName('transfer') - .setDescription('Transfer credits from a user to another user.') - .addUserOption((option) => option - .setName('from') - .setDescription('The user you want to take credits from.') - .setRequired(true)) - .addUserOption((option) => option - .setName('to') - .setDescription('The user you want to give credits to.') - .setRequired(true)) - .addIntegerOption((option) => option - .setName('amount') - .setDescription('The amount you will transfer.') - .setRequired(true)))), + .addSubcommandGroup((group) => + group + .setName('credits') + .setDescription('Manage credits.') + .addSubcommand((command) => + command + .setName('give') + .setDescription('Give credits to a user') + .addUserOption((option) => + option.setName('user').setDescription('The user you want to pay.').setRequired(true) + ) + .addIntegerOption((option) => + option.setName('amount').setDescription('The amount you will pay.').setRequired(true) + ) + ) + .addSubcommand((command) => + command + .setName('set') + .setDescription('Set credits to a user') + .addUserOption((option) => + option + .setName('user') + .setDescription('The user you want to set credits on.') + .setRequired(true) + ) + .addIntegerOption((option) => + option.setName('amount').setDescription('The amount you will set.').setRequired(true) + ) + ) + .addSubcommand((command) => + command + .setName('take') + .setDescription('Take credits from a user') + .addUserOption((option) => + option + .setName('user') + .setDescription('The user you want to take credits from.') + .setRequired(true) + ) + .addIntegerOption((option) => + option.setName('amount').setDescription('The amount you will take.').setRequired(true) + ) + ) + .addSubcommand((command) => + command + .setName('transfer') + .setDescription('Transfer credits from a user to another user.') + .addUserOption((option) => + option + .setName('from') + .setDescription('The user you want to take credits from.') + .setRequired(true) + ) + .addUserOption((option) => + option + .setName('to') + .setDescription('The user you want to give credits to.') + .setRequired(true) + ) + .addIntegerOption((option) => + option + .setName('amount') + .setDescription('The amount you will transfer.') + .setRequired(true) + ) + ) + ), async execute(interaction) { if (interaction.options.getSubcommandGroup() === 'credits') { await credits(interaction); diff --git a/src/commands/credits/addons/balance.js b/src/commands/credits/addons/balance.js index f6e9742..d5bdb69 100644 --- a/src/commands/credits/addons/balance.js +++ b/src/commands/credits/addons/balance.js @@ -10,14 +10,10 @@ module.exports = async (interaction) => { const user = await interaction.options.getUser('user'); await credits - .findOne( - { - userId: user - ? user.id - : interaction.user.id, - guildId: interaction.member.guild.id, - }, - ) + .findOne({ + userId: user ? user.id : interaction.user.id, + guildId: interaction.member.guild.id, + }) .then(async (data) => { if (!data) { const embed = { diff --git a/src/commands/credits/addons/gift.js b/src/commands/credits/addons/gift.js index 9d43cec..0cb8f1a 100644 --- a/src/commands/credits/addons/gift.js +++ b/src/commands/credits/addons/gift.js @@ -11,7 +11,7 @@ module.exports = async (interaction) => { const user = await interaction.options.getUser('user'); const amount = await interaction.options.getInteger('amount'); const reason = await interaction.options.getString('reason'); - // eslint-disable-next-line max-len + const data = await credits.findOne({ userId: interaction.user.id, guildId: interaction.member.guild.id, diff --git a/src/commands/credits/addons/work.js b/src/commands/credits/addons/work.js index f9be4ca..7054526 100644 --- a/src/commands/credits/addons/work.js +++ b/src/commands/credits/addons/work.js @@ -11,13 +11,11 @@ module.exports = async (interaction) => { // Check if user has a timeout - const isTimeout = await timeouts.findOne( - { - guildId: member.guild.id, - userId: member.id, - timeoutId: 3, - }, - ); + const isTimeout = await timeouts.findOne({ + guildId: member.guild.id, + userId: member.id, + timeoutId: 3, + }); // If user is not on timeout @@ -32,7 +30,7 @@ module.exports = async (interaction) => { guildId: interaction.member.guild.id, }, { $inc: { balance: creditsEarned } }, - { new: true, upsert: true }, + { new: true, upsert: true } ) .then(async () => { logger.debug(`Credits added to user: ${interaction.member.id}`); @@ -49,17 +47,17 @@ module.exports = async (interaction) => { // Create a timeout for the user - await timeouts.create( - { - guildId: member.guild.id, - userId: member.id, - timeoutId: 3, - }, - ); + await timeouts.create({ + guildId: member.guild.id, + userId: member.id, + timeoutId: 3, + }); setTimeout(async () => { await logger.debug( - `Guild: ${member.guild.id} User: ${member.id} has not worked within the last ${guild.work.timeout / 1000} seconds, work can be done`, + `Guild: ${member.guild.id} User: ${member.id} has not worked within the last ${ + guild.work.timeout / 1000 + } seconds, work can be done` ); // When timeout is out, remove it from the database @@ -73,7 +71,9 @@ module.exports = async (interaction) => { } else { const embed = { title: 'Work', - description: `You have worked within the last ${guild.work.timeout / 1000} seconds, you can not work now!`, + description: `You have worked within the last ${ + guild.work.timeout / 1000 + } seconds, you can not work now!`, timestamp: new Date(), color: config.colors.error, footer: { iconURL: config.footer.icon, text: config.footer.text }, @@ -82,7 +82,7 @@ module.exports = async (interaction) => { await interaction.editReply({ embeds: [embed] }); await logger.debug( - `Guild: ${member.guild.id} User: ${member.id} has worked within last day, no work can be done`, + `Guild: ${member.guild.id} User: ${member.id} has worked within last day, no work can be done` ); } }; diff --git a/src/commands/credits/index.js b/src/commands/credits/index.js index bb78fbd..ddef79d 100644 --- a/src/commands/credits/index.js +++ b/src/commands/credits/index.js @@ -11,33 +11,43 @@ const top = require('./addons/top'); const work = require('./addons/work'); module.exports = { - permissions: new Permissions([ - Permissions.FLAGS.MANAGE_MESSAGES, - Permissions.FLAGS.ADMINISTRATOR, - ]), - guildOnly: true, - botAdminOnly: false, data: new SlashCommandBuilder() .setName('credits') .setDescription('Manage your credits.') - .addSubcommand((subcommand) => subcommand - .setName('balance') - .setDescription("Check a user's balance.") - .addUserOption((option) => option - .setName('user') - .setDescription('The user whose balance you want to check.') - .setRequired(false))) - .addSubcommand((subcommand) => subcommand - .setName('redeem') - .setDescription('Redeem your credits.') - .addIntegerOption((option) => option.setName('amount').setDescription('How much credit you want to withdraw.'))) - .addSubcommand((subcommand) => subcommand - .setName('gift') - .setDescription('Gift someone credits from your credits.') - .addUserOption((option) => option.setName('user').setDescription('The user you want to pay.').setRequired(true)) - .addIntegerOption((option) => option.setName('amount').setDescription('The amount you will pay.').setRequired(true)) - .addStringOption((option) => option.setName('reason').setDescription('Your reason.'))) - .addSubcommand((subcommand) => subcommand.setName('top').setDescription('Check the top balance.')) + .addSubcommand((subcommand) => + subcommand + .setName('balance') + .setDescription("Check a user's balance.") + .addUserOption((option) => + option + .setName('user') + .setDescription('The user whose balance you want to check.') + .setRequired(false) + ) + ) + .addSubcommand((subcommand) => + subcommand + .setName('redeem') + .setDescription('Redeem your credits.') + .addIntegerOption((option) => + option.setName('amount').setDescription('How much credit you want to withdraw.') + ) + ) + .addSubcommand((subcommand) => + subcommand + .setName('gift') + .setDescription('Gift someone credits from your credits.') + .addUserOption((option) => + option.setName('user').setDescription('The user you want to pay.').setRequired(true) + ) + .addIntegerOption((option) => + option.setName('amount').setDescription('The amount you will pay.').setRequired(true) + ) + .addStringOption((option) => option.setName('reason').setDescription('Your reason.')) + ) + .addSubcommand((subcommand) => + subcommand.setName('top').setDescription('Check the top balance.') + ) .addSubcommand((subcommand) => subcommand.setName('work').setDescription('Work for credits.')), async execute(interaction) { const guild = await guilds.findOne({ guildId: interaction.member.guild.id }); diff --git a/src/commands/profile/addons/view.js b/src/commands/profile/addons/view.js index 7f1e13c..d3dacda 100644 --- a/src/commands/profile/addons/view.js +++ b/src/commands/profile/addons/view.js @@ -15,30 +15,26 @@ module.exports = async (interaction) => { // Databases // Fetch user from user - const user = await users.findOne( - { userId: await discordUser.id }, - ); + const user = await users.findOne({ userId: await discordUser.id }); // Fetch credit from user and guild - const experience = await experiences.findOne( - { - userId: await discordUser.id, - guildId: await member.guild.id, - }, - ); + const experience = await experiences.findOne({ + userId: await discordUser.id, + guildId: await member.guild.id, + }); // Fetch credit from user and guild - const credit = await credits.findOne( - { - userId: await discordUser.id, - guildId: await member.guild.id, - }, - ); + const credit = await credits.findOne({ + userId: await discordUser.id, + guildId: await member.guild.id, + }); if (user === null || experience === null || credit === null) { const embed = { title: 'Profile', - description: `${target || 'You'} have to write something before viewing ${target ? 'their' : 'your'} profile!`, + description: `${target || 'You'} have to write something before viewing ${ + target ? 'their' : 'your' + } profile!`, timestamp: new Date(), color: config.colors.error, footer: { iconURL: config.footer.icon, text: config.footer.text }, @@ -49,11 +45,21 @@ module.exports = async (interaction) => { // Language variables const notAvailableText = i18next.t('general:not_available', { lng: await user.language }); - const reputationText = i18next.t('commands:profile:addons:view:embed:reputation', { lng: await user.language }); - const levelText = i18next.t('commands:profile:addons:view:embed:level', { lng: await user.language }); - const pointsText = i18next.t('commands:profile:addons:view:embed:points', { lng: await user.language }); - const creditsText = i18next.t('commands:profile:addons:view:embed:credits', { lng: await user.language }); - const languageCodeText = i18next.t('commands:profile:addons:view:embed:language_code', { lng: await user.language }); + const reputationText = i18next.t('commands:profile:addons:view:embed:reputation', { + lng: await user.language, + }); + const levelText = i18next.t('commands:profile:addons:view:embed:level', { + lng: await user.language, + }); + const pointsText = i18next.t('commands:profile:addons:view:embed:points', { + lng: await user.language, + }); + const creditsText = i18next.t('commands:profile:addons:view:embed:credits', { + lng: await user.language, + }); + const languageCodeText = i18next.t('commands:profile:addons:view:embed:language_code', { + lng: await user.language, + }); // Create embed const embed = { @@ -63,11 +69,31 @@ module.exports = async (interaction) => { }, color: config.colors.success, fields: [ - { name: `:money_with_wings: ${creditsText}`, value: `${await credit.balance || `${notAvailableText}`}`, inline: true }, - { name: `:squeeze_bottle: ${levelText}`, value: `${await experience.level || `${notAvailableText}`}`, inline: true }, - { name: `:squeeze_bottle: ${pointsText}`, value: `${await experience.points || `${notAvailableText}`}`, inline: true }, - { name: `:loudspeaker: ${reputationText}`, value: `${await user.reputation || `${notAvailableText}`}`, inline: true }, - { name: `:rainbow_flag: ${languageCodeText}`, value: `${await user.language || `${notAvailableText}`}`, inline: true }, + { + name: `:money_with_wings: ${creditsText}`, + value: `${(await credit.balance) || `${notAvailableText}`}`, + inline: true, + }, + { + name: `:squeeze_bottle: ${levelText}`, + value: `${(await experience.level) || `${notAvailableText}`}`, + inline: true, + }, + { + name: `:squeeze_bottle: ${pointsText}`, + value: `${(await experience.points) || `${notAvailableText}`}`, + inline: true, + }, + { + name: `:loudspeaker: ${reputationText}`, + value: `${(await user.reputation) || `${notAvailableText}`}`, + inline: true, + }, + { + name: `:rainbow_flag: ${languageCodeText}`, + value: `${(await user.language) || `${notAvailableText}`}`, + inline: true, + }, ], timestamp: new Date(), footer: { iconURL: config.footer.icon, text: config.footer.text }, diff --git a/src/commands/profile/index.js b/src/commands/profile/index.js index a4d9afb..6cdb8a6 100644 --- a/src/commands/profile/index.js +++ b/src/commands/profile/index.js @@ -6,8 +6,14 @@ module.exports = { data: new SlashCommandBuilder() .setName('profile') .setDescription('Your profile.') - .addSubcommand((subcommand) => subcommand.setName('view').setDescription('View a profile.').addUserOption((option) => option.setName('target') - .setDescription('The profile you wish to view'))), + .addSubcommand((subcommand) => + subcommand + .setName('view') + .setDescription('View a profile.') + .addUserOption((option) => + option.setName('target').setDescription('The profile you wish to view') + ) + ), async execute(interaction) { if (interaction.options.getSubcommand() === 'view') { await view(interaction); diff --git a/src/commands/reputation/addons/give.js b/src/commands/reputation/addons/give.js index 1de992d..2029815 100644 --- a/src/commands/reputation/addons/give.js +++ b/src/commands/reputation/addons/give.js @@ -84,7 +84,7 @@ module.exports = async (interaction) => { // Send debug message await logger.debug( - `Guild: ${member.guild.id} User: ${member.id} has given ${target.id} a ${type} reputation.`, + `Guild: ${member.guild.id} User: ${member.id} has given ${target.id} a ${type} reputation.` ); // Create a timeout for the user @@ -97,7 +97,7 @@ module.exports = async (interaction) => { setTimeout(async () => { await logger.debug( - `Guild: ${member.guild.id} User: ${member.id} has not repute within last day, reputation can be given`, + `Guild: ${member.guild.id} User: ${member.id} has not repute within last day, reputation can be given` ); // When timeout is out, remove it from the database @@ -124,7 +124,7 @@ module.exports = async (interaction) => { await interaction.editReply({ embeds: [embed] }); await logger.debug( - `Guild: ${member.guild.id} User: ${member.id} has repute within last day, no reputation can be given`, + `Guild: ${member.guild.id} User: ${member.id} has repute within last day, no reputation can be given` ); } }; diff --git a/src/commands/reputation/index.js b/src/commands/reputation/index.js index 30bc41a..6dfb014 100644 --- a/src/commands/reputation/index.js +++ b/src/commands/reputation/index.js @@ -8,14 +8,22 @@ module.exports = { data: new SlashCommandBuilder() .setName('reputation') .setDescription('Manage reputation.') - .addSubcommand((subcommand) => subcommand - .setName('give') - .setDescription('Give reputation for a user') - .addUserOption((option) => option.setName('target').setDescription('The user you want to repute.').setRequired(true)) - .addStringOption((option) => option.setName('type') - .setDescription('What type of reputation you want to repute').setRequired(true) - .addChoice('Positive', 'positive') - .addChoice('Negative', 'negative'))), + .addSubcommand((subcommand) => + subcommand + .setName('give') + .setDescription('Give reputation for a user') + .addUserOption((option) => + option.setName('target').setDescription('The user you want to repute.').setRequired(true) + ) + .addStringOption((option) => + option + .setName('type') + .setDescription('What type of reputation you want to repute') + .setRequired(true) + .addChoice('Positive', 'positive') + .addChoice('Negative', 'negative') + ) + ), async execute(interaction) { // Destructure member @@ -24,12 +32,16 @@ module.exports = { // Command handler if (interaction.options.getSubcommand() === 'give') { - // Execute give addon + // Execute give addon await give(interaction); } // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} executed /${interaction.commandName} ${interaction.options.getSubcommand()}`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} executed /${ + interaction.commandName + } ${interaction.options.getSubcommand()}` + ); }, }; diff --git a/src/commands/settings/guild/addons/credits.js b/src/commands/settings/guild/addons/credits.js index 4917cdd..764fb5a 100644 --- a/src/commands/settings/guild/addons/credits.js +++ b/src/commands/settings/guild/addons/credits.js @@ -39,24 +39,13 @@ module.exports = async (interaction) => { // Modify values - 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.minimumLength = minimumLength !== null - ? minimumLength - : guild.credits.minimumLength; + 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.minimumLength = + minimumLength !== null ? minimumLength : guild.credits.minimumLength; // Save guild diff --git a/src/commands/settings/guild/addons/pterodactyl.js b/src/commands/settings/guild/addons/pterodactyl.js index cc1b1a7..2057b0c 100644 --- a/src/commands/settings/guild/addons/pterodactyl.js +++ b/src/commands/settings/guild/addons/pterodactyl.js @@ -31,27 +31,27 @@ module.exports = async (interaction) => { // Update API credentials - await apis.findOneAndUpdate( - { guildId: member.guild.id }, - { url, token }, - { new: true, upsert: true }, - ).then(async () => { - // Build embed + await apis + .findOneAndUpdate({ guildId: member.guild.id }, { url, token }, { new: true, upsert: true }) + .then(async () => { + // Build embed - const embed = { - title: 'Settings', - color: config.colors.success, - description: 'Pterodactyl settings is saved!', - timestamp: new Date(), - footer: { iconURL: config.footer.icon, text: config.footer.text }, - }; + const embed = { + title: 'Settings', + color: config.colors.success, + description: 'Pterodactyl settings is saved!', + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; - // Send reply + // Send reply - await interaction.editReply({ embeds: [embed], ephemeral: true }); + await interaction.editReply({ embeds: [embed], ephemeral: true }); - // Send debug message + // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} has changed api credentials.`); - }); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} has changed api credentials.` + ); + }); }; diff --git a/src/commands/settings/guild/index.js b/src/commands/settings/guild/index.js index 22d60a1..3a498c6 100644 --- a/src/commands/settings/guild/index.js +++ b/src/commands/settings/guild/index.js @@ -36,5 +36,9 @@ module.exports = async (interaction) => { // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} executed /${interaction.commandName} ${interaction.options.getSubcommandGroup()} ${interaction.options.getSubcommand()}`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} executed /${ + interaction.commandName + } ${interaction.options.getSubcommandGroup()} ${interaction.options.getSubcommand()}` + ); }; diff --git a/src/commands/settings/index.js b/src/commands/settings/index.js index d2c5fb0..dc024b0 100644 --- a/src/commands/settings/index.js +++ b/src/commands/settings/index.js @@ -8,40 +8,68 @@ module.exports = { data: new SlashCommandBuilder() .setName('settings') .setDescription('Manage settings.') - .addSubcommandGroup((group) => group - .setName('guild') - .setDescription('Manage guild settings.') - .addSubcommand((command) => command - .setName('pterodactyl') - .setDescription('Controlpanel.gg') - .addStringOption((option) => option.setName('url').setDescription('The api url').setRequired(true)) - .addStringOption((option) => option.setName('token').setDescription('The api token').setRequired(true))) - .addSubcommand((command) => command - .setName('credits') - .setDescription('Credits') - .addBooleanOption((option) => option.setName('status').setDescription('Should credits be enabled?')) - .addNumberOption((option) => option.setName('rate').setDescription('Amount of credits per message.')) - .addNumberOption((option) => option - .setName('minimum-length') - .setDescription('Minimum length of message to earn credits.')) - .addNumberOption((option) => option.setName('work-rate').setDescription('Maximum amount of credits on work.')) - .addNumberOption((option) => option - .setName('work-timeout') - .setDescription('Timeout between work schedules (milliseconds).')) - .addNumberOption((option) => option - .setName('timeout') - .setDescription('Timeout between earning credits (milliseconds).')))) - .addSubcommandGroup((group) => group - .setName('user') - .setDescription('Manage user settings.') - .addSubcommand((command) => command - .setName('appearance') - .setDescription('Manage your appearance') - .addStringOption((option) => option - .setName('language') - .setDescription('Configure your language') - .addChoice('English', 'en') - .addChoice('Swedish', 'sv')))), + .addSubcommandGroup((group) => + group + .setName('guild') + .setDescription('Manage guild settings.') + .addSubcommand((command) => + command + .setName('pterodactyl') + .setDescription('Controlpanel.gg') + .addStringOption((option) => + option.setName('url').setDescription('The api url').setRequired(true) + ) + .addStringOption((option) => + option.setName('token').setDescription('The api token').setRequired(true) + ) + ) + .addSubcommand((command) => + command + .setName('credits') + .setDescription('Credits') + .addBooleanOption((option) => + option.setName('status').setDescription('Should credits be enabled?') + ) + .addNumberOption((option) => + option.setName('rate').setDescription('Amount of credits per message.') + ) + .addNumberOption((option) => + option + .setName('minimum-length') + .setDescription('Minimum length of message to earn credits.') + ) + .addNumberOption((option) => + option.setName('work-rate').setDescription('Maximum amount of credits on work.') + ) + .addNumberOption((option) => + option + .setName('work-timeout') + .setDescription('Timeout between work schedules (milliseconds).') + ) + .addNumberOption((option) => + option + .setName('timeout') + .setDescription('Timeout between earning credits (milliseconds).') + ) + ) + ) + .addSubcommandGroup((group) => + group + .setName('user') + .setDescription('Manage user settings.') + .addSubcommand((command) => + command + .setName('appearance') + .setDescription('Manage your appearance') + .addStringOption((option) => + option + .setName('language') + .setDescription('Configure your language') + .addChoice('English', 'en') + .addChoice('Swedish', 'sv') + ) + ) + ), async execute(interaction) { if (interaction.options.getSubcommandGroup() === 'guild') { await guild(interaction); diff --git a/src/commands/settings/user/addons/appearance.js b/src/commands/settings/user/addons/appearance.js index 6ee3571..3ebaf82 100644 --- a/src/commands/settings/user/addons/appearance.js +++ b/src/commands/settings/user/addons/appearance.js @@ -49,6 +49,8 @@ module.exports = async (interaction) => { // Send debug message - await logger.debug(`Guild: ${member.guild.id} User: ${member.id} has changed appearance settings.`); + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} has changed appearance settings.` + ); }); }; diff --git a/src/commands/utilities/addons/users.js b/src/commands/utilities/addons/users.js index a879777..b461ff2 100644 --- a/src/commands/utilities/addons/users.js +++ b/src/commands/utilities/addons/users.js @@ -16,7 +16,9 @@ module.exports = async (interaction) => { // eslint-disable-next-line max-len const userList = await interaction.client.users.cache.filter((user) => !user.bot); - userList.map((user) => { logger.info(user); }); + userList.map((user) => { + logger.info(user); + }); // await interaction.client.guilds.cache.get(interaction.member.guild.id).then((user) => logger.info(user)); diff --git a/src/commands/utilities/index.js b/src/commands/utilities/index.js index 2c455fc..bf748aa 100644 --- a/src/commands/utilities/index.js +++ b/src/commands/utilities/index.js @@ -5,25 +5,23 @@ const lookup = require('./addons/lookup'); const users = require('./addons/users'); module.exports = { - permissions: new Permissions([ - Permissions.FLAGS.MANAGE_MESSAGES, - Permissions.FLAGS.ADMINISTRATOR, - ]), - guildOnly: true, - botAdminOnly: false, data: new SlashCommandBuilder() .setName('utilities') .setDescription('Common utilities.') - .addSubcommand((subcommand) => subcommand - .setName('lookup') - .setDescription('Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)') - .addStringOption((option) => option - .setName('target') - .setDescription('The target you want to look up.') - .setRequired(true))) - .addSubcommand((subcommand) => subcommand - .setName('users') - .setDescription('Iterate all users (ADMIN)')), + .addSubcommand((subcommand) => + subcommand + .setName('lookup') + .setDescription('Lookup a domain or ip. (Request sent over HTTP, proceed with caution!)') + .addStringOption((option) => + option + .setName('target') + .setDescription('The target you want to look up.') + .setRequired(true) + ) + ) + .addSubcommand((subcommand) => + subcommand.setName('users').setDescription('Iterate all users (ADMIN)') + ), async execute(interaction) { if (interaction.options.getSubcommand() === 'lookup') { await lookup(interaction); diff --git a/src/deploy-commands.js b/src/deploy-commands.js index 352c3dd..bbe8d8d 100644 --- a/src/deploy-commands.js +++ b/src/deploy-commands.js @@ -22,10 +22,7 @@ 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), { diff --git a/src/events/guildCreate.js b/src/events/guildCreate.js index 8aa9e5d..a132aee 100644 --- a/src/events/guildCreate.js +++ b/src/events/guildCreate.js @@ -4,11 +4,10 @@ module.exports = { name: 'guildCreate', async execute(guild) { 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` }], status: 'online' }); + await guilds.findOne({ guildId: guild.id }, { new: true, upsert: true }); + await client.user.setPresence({ + activities: [{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }], + status: 'online', + }); }, }; diff --git a/src/events/interactionCreate.js b/src/events/interactionCreate.js index c620db6..54d368f 100644 --- a/src/events/interactionCreate.js +++ b/src/events/interactionCreate.js @@ -13,10 +13,7 @@ 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/memberCreate.js b/src/events/memberCreate.js index ea6bc42..7ff7ae2 100644 --- a/src/events/memberCreate.js +++ b/src/events/memberCreate.js @@ -9,7 +9,6 @@ module.exports = { // .findOne({ guildId: guild.id }) // .then(logger.debug(`Found guild: ${guild.id}`)) // .catch(logger.error); - // if (!guildExist) { // await guilds // .create({ guildId: guild.id }) diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index 52c044e..fef2cc5 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -1,8 +1,6 @@ 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', @@ -17,10 +15,7 @@ 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 @@ -31,13 +26,11 @@ module.exports = { // Check if user has a timeout - const isTimeout = await timeouts.findOne( - { - guildId: message.guild.id, - userId: message.author.id, - timeoutId: 1, - }, - ); + const isTimeout = await timeouts.findOne({ + guildId: message.guild.id, + userId: message.author.id, + timeoutId: 1, + }); // If user is not on timeout @@ -48,9 +41,11 @@ module.exports = { .findOneAndUpdate( { userId: message.author.id, guildId: message.guild.id }, { $inc: { balance: guild.credits.rate } }, - { new: true, upsert: true }, + { new: true, upsert: true } + ) + .then(async () => + logger.debug(`Guild: ${message.guild.id} Credits added to user: ${message.author.id}`) ) - .then(async () => logger.debug(`Guild: ${message.guild.id} Credits added to user: ${message.author.id}`)) .catch(async (err) => { await logger.error(err); }); @@ -61,28 +56,28 @@ module.exports = { .findOneAndUpdate( { userId: message.author.id, guildId: message.guild.id }, { $inc: { points: guild.points.rate } }, - { new: true, upsert: true }, + { new: true, upsert: true } + ) + .then(async () => + logger.debug(`Guild: ${message.guild.id} Points added to user: ${message.author.id}`) ) - .then(async () => logger.debug(`Guild: ${message.guild.id} Points added to user: ${message.author.id}`)) .catch(async (err) => { await logger.error(err); }); // Create a timeout for the user - await timeouts.create( - { - guildId: message.guild.id, - userId: message.author.id, - timeoutId: 1, - }, - ); + await timeouts.create({ + guildId: message.guild.id, + userId: message.author.id, + timeoutId: 1, + }); setTimeout(async () => { await logger.debug( `Guild: ${message.guild.id} User: ${message.author.id} has not talked within last ${ guild.credits.timeout / 1000 - } seconds, credits can be given`, + } seconds, credits can be given` ); // When timeout is out, remove it from the database @@ -97,7 +92,7 @@ module.exports = { await logger.debug( `Guild: ${message.guild.id} User: ${message.author.id} has talked within last ${ guild.credits.timeout / 1000 - } seconds, no credits given`, + } seconds, no credits given` ); } }, diff --git a/src/events/ready.js b/src/events/ready.js index 9987aa9..506856e 100644 --- a/src/events/ready.js +++ b/src/events/ready.js @@ -5,6 +5,9 @@ module.exports = { once: true, 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` }], status: 'online' }); + await client.user.setPresence({ + activities: [{ type: 'WATCHING', name: `${client.guilds.cache.size} guilds` }], + status: 'online', + }); }, }; diff --git a/src/handlers/locale.js b/src/handlers/locale.js index 9faec38..390de2a 100644 --- a/src/handlers/locale.js +++ b/src/handlers/locale.js @@ -29,8 +29,15 @@ module.exports = async () => { 'You have given reputation within the last day, you can not repute now!', }, }, - version02: { embed: { title: 'Reputation', description: 'You have given {{user}} a {{type}} reputation!' } }, - version03: { embed: { title: 'Reputation', description: 'You can not repute yourself.' } }, + version02: { + embed: { + title: 'Reputation', + description: 'You have given {{user}} a {{type}} reputation!', + }, + }, + version03: { + embed: { title: 'Reputation', description: 'You can not repute yourself.' }, + }, }, }, }, @@ -80,8 +87,15 @@ module.exports = async () => { 'Du har redan gett omdöme inom den senaste dagen, du kan inte ge ett omdöme just nu!', }, }, - version02: { embed: { title: 'Omdöme', description: 'Du har gett {{user}} ett {{type}} omdöme!' } }, - version03: { embed: { title: 'Omdöme', description: 'Du kan inte ge dig själv ett omdöme.' } }, + version02: { + embed: { + title: 'Omdöme', + description: 'Du har gett {{user}} ett {{type}} omdöme!', + }, + }, + version03: { + embed: { title: 'Omdöme', description: 'Du kan inte ge dig själv ett omdöme.' }, + }, }, }, }, diff --git a/src/helpers/database/models/apiSchema.js b/src/helpers/database/models/apiSchema.js index bdd3345..b3975f4 100644 --- a/src/helpers/database/models/apiSchema.js +++ b/src/helpers/database/models/apiSchema.js @@ -2,7 +2,6 @@ const mongoose = require('mongoose'); const apiSchema = new mongoose.Schema( { - guildId: { type: mongoose.SchemaTypes.Decimal128, required: true, @@ -22,7 +21,7 @@ const apiSchema = new mongoose.Schema( index: true, }, }, - { timestamps: true }, + { timestamps: true } ); module.exports = mongoose.model('api', apiSchema); diff --git a/src/helpers/database/models/creditSchema.js b/src/helpers/database/models/creditSchema.js index c00740c..34a510c 100644 --- a/src/helpers/database/models/creditSchema.js +++ b/src/helpers/database/models/creditSchema.js @@ -22,7 +22,7 @@ const creditSchema = new mongoose.Schema( index: false, }, }, - { timestamps: true }, + { timestamps: true } ); module.exports = mongoose.model('credit', creditSchema); diff --git a/src/helpers/database/models/experienceSchema.js b/src/helpers/database/models/experienceSchema.js index e139073..2da6d4b 100644 --- a/src/helpers/database/models/experienceSchema.js +++ b/src/helpers/database/models/experienceSchema.js @@ -29,7 +29,7 @@ const experienceSchema = new mongoose.Schema( index: false, }, }, - { timestamps: true }, + { timestamps: true } ); module.exports = mongoose.model('experience', experienceSchema); diff --git a/src/helpers/database/models/guildSchema.js b/src/helpers/database/models/guildSchema.js index 1c03097..ca8c5c2 100644 --- a/src/helpers/database/models/guildSchema.js +++ b/src/helpers/database/models/guildSchema.js @@ -73,7 +73,7 @@ const guildSchema = new mongoose.Schema( }, }, }, - { timestamps: true }, + { timestamps: true } ); module.exports = mongoose.model('guild', guildSchema); diff --git a/src/helpers/database/models/index.js b/src/helpers/database/models/index.js index b79468b..d1a2a82 100644 --- a/src/helpers/database/models/index.js +++ b/src/helpers/database/models/index.js @@ -6,5 +6,10 @@ const apis = require('./apiSchema'); const timeouts = require('./timeoutSchema'); module.exports = { - credits, experiences, users, guilds, apis, timeouts, + credits, + experiences, + users, + guilds, + apis, + timeouts, }; diff --git a/src/helpers/database/models/timeoutSchema.js b/src/helpers/database/models/timeoutSchema.js index 9dd012a..ef312e9 100644 --- a/src/helpers/database/models/timeoutSchema.js +++ b/src/helpers/database/models/timeoutSchema.js @@ -16,7 +16,7 @@ const timeoutSchema = new mongoose.Schema( }, timeoutId: { type: mongoose.SchemaTypes.Number }, }, - { timestamps: true }, + { timestamps: true } ); module.exports = mongoose.model('timeout', timeoutSchema); diff --git a/src/helpers/database/models/userSchema.js b/src/helpers/database/models/userSchema.js index 41b42cd..7e95e7c 100644 --- a/src/helpers/database/models/userSchema.js +++ b/src/helpers/database/models/userSchema.js @@ -14,7 +14,7 @@ const userSchema = new mongoose.Schema( }, reputation: { type: mongoose.SchemaTypes.Number, default: 0 }, }, - { timestamps: true }, + { timestamps: true } ); module.exports = mongoose.model('user', userSchema); diff --git a/src/helpers/saveUser.js b/src/helpers/saveUser.js index 0a1790a..1933987 100644 --- a/src/helpers/saveUser.js +++ b/src/helpers/saveUser.js @@ -6,24 +6,28 @@ module.exports = async function saveUser(data, data2) { process.nextTick( async () => { await sleep(Math.floor(Math.random() * 10 + 1) * 100); // 100 - 1000 random Number generator - data.save((_) => (_ - ? logger.error( - `ERROR Occurred while saving data (saveUser) \n${'='.repeat(50)}\n${ - `${_}\n${'='.repeat(50)}` - }`, - ) - : 'No Error')); - if (data2) { - data2.save((_) => (_ + data.save((_) => + _ ? logger.error( - `ERROR Occurred while saving data (saveUser) \n${'='.repeat(50)}\n${ - `${_}\n${'='.repeat(50)}` - }`, - ) - : 'No Error')); + `ERROR Occurred while saving data (saveUser) \n${'='.repeat( + 50 + )}\n${`${_}\n${'='.repeat(50)}`}` + ) + : 'No Error' + ); + if (data2) { + data2.save((_) => + _ + ? logger.error( + `ERROR Occurred while saving data (saveUser) \n${'='.repeat( + 50 + )}\n${`${_}\n${'='.repeat(50)}`}` + ) + : 'No Error' + ); } }, data, - data2, + data2 ); };