From 1597f8f93863e8e62345489ee436e5f6a8987090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Olausson=20Holten=C3=A4s?= Date: Sun, 13 Mar 2022 12:11:56 +0100 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20changed?= =?UTF-8?q?=20some=20vscode=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b8528ea..44ec5dd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,26 +1,8 @@ { "editor.wordWrapColumn": 100, "editor.tabSize": 2, - // "workbench.colorCustomizations": { - // "titleBar.activeBackground": "#336699", - // "titleBar.inactiveBackground": "#33669999", - // "titleBar.activeForeground": "#e7e7e7", - // "titleBar.inactiveForeground": "#e7e7e799", - // "statusBarItem.hoverBackground": "#407fbf", - // "activityBar.activeBackground": "#407fbf", - // "activityBar.activeBorder": "#77284f", - // "activityBar.background": "#407fbf", - // "activityBar.foreground": "#e7e7e7", - // "activityBar.inactiveForeground": "#e7e7e799", - // "activityBarBadge.background": "#77284f", - // "activityBarBadge.foreground": "#e7e7e7", - // "sash.hoverBorder": "#407fbf", - // "statusBarItem.remoteBackground": "#336699", - // "statusBarItem.remoteForeground": "#e7e7e7" - // }, "editor.formatOnSave": true, "javascript.format.enable": false, - "eslint.autoFixOnSave": true, "files.eol": "\n", "prettier.endOfLine": "lf", "prettier.singleQuote": true, @@ -29,23 +11,6 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, - "workbench.colorCustomizations": { - "activityBar.activeBackground": "#407fbf", - "activityBar.activeBorder": "#77284f", - "activityBar.background": "#407fbf", - "activityBar.foreground": "#e7e7e7", - "activityBar.inactiveForeground": "#e7e7e799", - "activityBarBadge.background": "#77284f", - "activityBarBadge.foreground": "#e7e7e7", - "sash.hoverBorder": "#407fbf", - "statusBarItem.hoverBackground": "#407fbf", - "statusBarItem.remoteBackground": "#336699", - "statusBarItem.remoteForeground": "#e7e7e7", - "titleBar.activeBackground": "#336699", - "titleBar.activeForeground": "#e7e7e7", - "titleBar.inactiveBackground": "#33669999", - "titleBar.inactiveForeground": "#e7e7e799" - }, "cSpell.words": [ "Controlpanel", "discordjs", @@ -55,5 +20,7 @@ "upsert", "uuidv" ], + "editor.fontFamily": "Cascadia Code", + "editor.fontLigatures": true, "git.enableCommitSigning": true } From 4eb808e921a113e2d635973f35640b4acd2aa217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Olausson=20Holten=C3=A4s?= Date: Sun, 13 Mar 2022 12:13:22 +0100 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20added?= =?UTF-8?q?=20recommended=20extensions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/extensions.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 758fa96..cdc6a09 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -32,7 +32,15 @@ "ms-vscode.js-debug-companion", "ms-vscode.references-view", "ms-vscode.vscode-js-profile-table", - "pflannery.vscode-versionlens" + "pflannery.vscode-versionlens", + "adpyke.codesnap", + "Anan.devdocstab", + "axosoft.gitkraken-glo", + "Gruntfuggly.todo-tree", + "kiteco.kite", + "lkytal.pomodoro", + "wayou.vscode-todo-highlight", + "johnpapa.vscode-peacock" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] From f4be4416f8a306b89bd05603646a8242f3b7b973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Olausson=20Holten=C3=A4s?= Date: Sun, 13 Mar 2022 12:53:09 +0100 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=8E=A8=20index.js=20is=20now=20splitt?= =?UTF-8?q?ed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/ready.js | 4 ++ src/handlers/commands.js | 13 +++++ src/handlers/events.js | 16 +++++++ src/handlers/index.js | 5 ++ .../deployCommands.js} | 18 +++---- src/helpers/index.js | 4 ++ src/index.js | 48 +++++++------------ 7 files changed, 64 insertions(+), 44 deletions(-) create mode 100644 src/handlers/commands.js create mode 100644 src/handlers/events.js create mode 100644 src/handlers/index.js rename src/{deploy-commands.js => helpers/deployCommands.js} (62%) create mode 100644 src/helpers/index.js diff --git a/src/events/ready.js b/src/events/ready.js index 0a32014..8bf54d7 100644 --- a/src/events/ready.js +++ b/src/events/ready.js @@ -1,5 +1,7 @@ const logger = require('../handlers/logger'); +const { database, deployCommands } = require('../helpers'); + module.exports = { name: 'ready', once: true, @@ -14,5 +16,7 @@ module.exports = { ], status: 'online', }); + + await deployCommands(); }, }; diff --git a/src/handlers/commands.js b/src/handlers/commands.js new file mode 100644 index 0000000..2f91cee --- /dev/null +++ b/src/handlers/commands.js @@ -0,0 +1,13 @@ +const fs = require('fs'); // fs +const { Collection } = require('discord.js'); // discord.js + +module.exports = async (client) => { + client.commands = new Collection(); + const commandFiles = fs.readdirSync('./src/commands'); + + for (const file of commandFiles) { + // eslint-disable-next-line import/no-dynamic-require, global-require + const command = require(`../commands/${file}`); + client.commands.set(command.data.name, command); + } +}; diff --git a/src/handlers/events.js b/src/handlers/events.js new file mode 100644 index 0000000..175e9ba --- /dev/null +++ b/src/handlers/events.js @@ -0,0 +1,16 @@ +const fs = require('fs'); // fs + +module.exports = async (client) => { + const eventFiles = fs + .readdirSync('./src/events') + .filter((file) => file.endsWith('.js')); + + for (const file of eventFiles) { + const event = require(`../events/${file}`); + if (event.once) { + client.once(event.name, (...args) => event.execute(...args)); + } else { + client.on(event.name, (...args) => event.execute(...args)); + } + } +}; diff --git a/src/handlers/index.js b/src/handlers/index.js new file mode 100644 index 0000000..ab4a615 --- /dev/null +++ b/src/handlers/index.js @@ -0,0 +1,5 @@ +const events = require('./events'); +const commands = require('./commands'); +const locale = require('./locale'); + +module.exports = { events, commands, locale }; diff --git a/src/deploy-commands.js b/src/helpers/deployCommands.js similarity index 62% rename from src/deploy-commands.js rename to src/helpers/deployCommands.js index 1b64f2c..d488470 100644 --- a/src/deploy-commands.js +++ b/src/helpers/deployCommands.js @@ -1,22 +1,16 @@ -/* eslint-disable no-restricted-syntax */ -const config = require('../config.json'); - -const logger = require('./handlers/logger'); +const config = require('../../config.json'); +const logger = require('../handlers/logger'); +const fs = require('fs'); +const { REST } = require('@discordjs/rest'); +const { Routes } = require('discord-api-types/v9'); module.exports = async () => { - // eslint-disable-next-line global-require - const fs = require('fs'); - // eslint-disable-next-line global-require - const { REST } = require('@discordjs/rest'); - // eslint-disable-next-line global-require - const { Routes } = require('discord-api-types/v9'); - const commands = []; const commandFiles = fs.readdirSync('./src/commands'); for (const file of commandFiles) { // eslint-disable-next-line import/no-dynamic-require, global-require - const command = require(`./commands/${file}`); + const command = require(`../commands/${file}`); commands.push(command.data.toJSON()); } diff --git a/src/helpers/index.js b/src/helpers/index.js new file mode 100644 index 0000000..b63f4e0 --- /dev/null +++ b/src/helpers/index.js @@ -0,0 +1,4 @@ +const database = require('./database'); +const deployCommands = require('./deployCommands'); + +module.exports = { database, deployCommands }; diff --git a/src/index.js b/src/index.js index 75a879e..e5c563c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,37 +1,21 @@ -const fs = require('fs'); -const { Client, Collection, Intents } = require('discord.js'); +// Dependencies +const { Client, Intents } = require('discord.js'); // discord.js -require('./deploy-commands')(); -require('./helpers/database')(); -require('./handlers/locale')(); +const { database } = require('./helpers'); // helpers +const { events, commands, locale } = require('./handlers'); // handlers -const config = require('../config.json'); +const config = require('../config.json'); // config.json -const client = new Client({ - intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES], -}); +(async () => { + // Initialize discord.js client + const client = new Client({ + intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES], + }); -const eventFiles = fs - .readdirSync('./src/events') - .filter((file) => file.endsWith('.js')); + await database(); + await locale(); + await events(client); + await commands(client); -client.commands = new Collection(); -const commandFiles = fs.readdirSync('./src/commands'); - -for (const file of commandFiles) { - // eslint-disable-next-line import/no-dynamic-require, global-require - const command = require(`./commands/${file}`); - client.commands.set(command.data.name, command); -} - -for (const file of eventFiles) { - // eslint-disable-next-line import/no-dynamic-require, global-require - const event = require(`./events/${file}`); - if (event.once) { - client.once(event.name, (...args) => event.execute(...args)); - } else { - client.on(event.name, (...args) => event.execute(...args)); - } -} - -client.login(config.bot.token); + await client.login(config.bot.token); +})(); From 7aae20619f655b845c55a147626e6921dcbf8bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Olausson=20Holten=C3=A4s?= Date: Sun, 13 Mar 2022 18:54:42 +0100 Subject: [PATCH 4/6] =?UTF-8?q?=E2=9C=A8=20counter=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/admin/counter/addons/add.js | 93 ++++++++++++++++++++ src/commands/admin/counter/addons/index.js | 4 + src/commands/admin/counter/addons/remove.js | 43 +++++++++ src/commands/admin/counter/index.js | 44 +++++++++ src/commands/admin/index.js | 43 +++++++++ src/commands/counter/addons/view.js | 48 ++++++++++ src/commands/counter/index.js | 26 ++++++ src/events/messageCreate.js | 25 ++++++ src/helpers/database/models/counterSchema.js | 34 +++++++ src/helpers/database/models/index.js | 2 + 10 files changed, 362 insertions(+) create mode 100644 src/commands/admin/counter/addons/add.js create mode 100644 src/commands/admin/counter/addons/index.js create mode 100644 src/commands/admin/counter/addons/remove.js create mode 100644 src/commands/admin/counter/index.js create mode 100644 src/commands/counter/addons/view.js create mode 100644 src/commands/counter/index.js create mode 100644 src/helpers/database/models/counterSchema.js diff --git a/src/commands/admin/counter/addons/add.js b/src/commands/admin/counter/addons/add.js new file mode 100644 index 0000000..731638a --- /dev/null +++ b/src/commands/admin/counter/addons/add.js @@ -0,0 +1,93 @@ +const { Permissions } = require('discord.js'); +const config = require('../../../../../config.json'); +const logger = require('../../../../handlers/logger'); + +// Database models +const { counters } = require('../../../../helpers/database/models'); + +const creditNoun = require('../../../../helpers/creditNoun'); +const { count } = require('../../../../helpers/database/models/apiSchema'); + +module.exports = async (interaction) => { + // Destructure member + const { member } = interaction; + + // Check permission + if (!member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) { + // Create embed object + const embed = { + title: 'Admin', + color: config.colors.error, + description: 'You do not have permission to manage this!', + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send interaction reply + return interaction.editReply({ embeds: [embed], ephemeral: true }); + } + + // Get options + const channel = await interaction.options.getChannel('channel'); + const word = await interaction.options.getString('word'); + const start = await interaction.options.getNumber('start'); + + if (channel.type !== 'GUILD_TEXT') { + // Create embed object + const embed = { + title: 'Admin - Counter', + description: `That channel is not supported, it needs to be a text channel.`, + timestamp: new Date(), + color: config.colors.error, + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send interaction reply + return await interaction.editReply({ embeds: [embed] }); + } + + const counterExist = await counters.findOne({ + guildId: member.guild.id, + channelId: channel.id, + word: word, + }); + + if (!counterExist) { + await counters.create({ + guildId: member.guild.id, + channelId: channel.id, + word: word, + counter: start || 0, + }); + // Create embed object + const embed = { + title: 'Admin - Counter', + description: `${channel} is now counting when hearing word ${word} and it starts at number ${ + start || 0 + }.`, + timestamp: new Date(), + color: config.colors.success, + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send debug message + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} added ${channel.id} as a counter using word "${word}" for counting.` + ); + + // Send interaction reply + return await interaction.editReply({ embeds: [embed] }); + } else { + // Create embed object + const embed = { + title: 'Admin - Counter', + description: `${channel} is already a counting channel.`, + timestamp: new Date(), + color: config.colors.error, + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send interaction reply + return await interaction.editReply({ embeds: [embed] }); + } +}; diff --git a/src/commands/admin/counter/addons/index.js b/src/commands/admin/counter/addons/index.js new file mode 100644 index 0000000..6b1d08d --- /dev/null +++ b/src/commands/admin/counter/addons/index.js @@ -0,0 +1,4 @@ +const add = require('./add'); +const remove = require('./remove'); + +module.exports = { add, remove }; diff --git a/src/commands/admin/counter/addons/remove.js b/src/commands/admin/counter/addons/remove.js new file mode 100644 index 0000000..1d4d855 --- /dev/null +++ b/src/commands/admin/counter/addons/remove.js @@ -0,0 +1,43 @@ +const { Permissions } = require('discord.js'); +const config = require('../../../../../config.json'); +const logger = require('../../../../handlers/logger'); + +// Database models +const { counters } = require('../../../../helpers/database/models'); + +const creditNoun = require('../../../../helpers/creditNoun'); +const { count } = require('../../../../helpers/database/models/apiSchema'); + +module.exports = async (interaction) => { + // Destructure member + const { member } = interaction; + + // Check permission + if (!member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) { + // Create embed object + const embed = { + title: 'Admin', + color: config.colors.error, + description: 'You do not have permission to manage this!', + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send interaction reply + return interaction.editReply({ embeds: [embed], ephemeral: true }); + } + + // Get options + const channel = await interaction.options.getChannel('channel'); + + await counters + .deleteOne({ guildId: member.guild.id, channelId: channel.id }) + .then(async () => { + interaction.editReply({ content: 'Removed' }); + }); + + // Send debug message + await logger.debug( + `Guild: ${member.guild.id} User: ${member.id} executed remove counter.` + ); +}; diff --git a/src/commands/admin/counter/index.js b/src/commands/admin/counter/index.js new file mode 100644 index 0000000..0dfa61a --- /dev/null +++ b/src/commands/admin/counter/index.js @@ -0,0 +1,44 @@ +const { Permissions } = require('discord.js'); +const config = require('../../../../config.json'); +const logger = require('../../../handlers/logger'); + +const { add, remove } = require('./addons'); + +module.exports = async (interaction) => { + // Destructure member + const { member } = interaction; + + // Check permission + if (!member.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) { + // Create embed object + const embed = { + title: 'Admin', + color: config.colors.error, + description: 'You do not have permission to manage this!', + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send interaction reply + await interaction.editReply({ embeds: [embed], ephemeral: true }); + } + + // If subcommand is give + if (interaction.options.getSubcommand() === 'add') { + // Execute give addon + await add(interaction); + } + + // If subcommand is take + else if (interaction.options.getSubcommand() === 'remove') { + // Execute take addon + await remove(interaction); + } + + // Send debug message + 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 ed098cf..7f9f2c5 100644 --- a/src/commands/admin/index.js +++ b/src/commands/admin/index.js @@ -1,6 +1,7 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); const credits = require('./credits'); +const counter = require('./counter'); module.exports = { data: new SlashCommandBuilder() @@ -84,6 +85,42 @@ module.exports = { .setRequired(true) ) ) + ) + .addSubcommandGroup((group) => + group + .setName('counter') + .setDescription('Manage counters.') + .addSubcommand((command) => + command + .setName('add') + .setDescription('Add a counter') + .addChannelOption((option) => + option + .setName('channel') + .setDescription('The counter channel.') + .setRequired(true) + ) + .addStringOption((option) => + option + .setName('word') + .setDescription('The counter word.') + .setRequired(true) + ) + .addNumberOption((option) => + option.setName('start').setDescription('Start at number X.') + ) + ) + .addSubcommand((command) => + command + .setName('remove') + .setDescription('Remove a counter') + .addChannelOption((option) => + option + .setName('channel') + .setDescription('The counter channel.') + .setRequired(true) + ) + ) ), async execute(interaction) { // If subcommand group is credits @@ -91,5 +128,11 @@ module.exports = { // Execute credits group await credits(interaction); } + + // If subcommand group is credits + else if (interaction.options.getSubcommandGroup() === 'counter') { + // Execute credits group + await counter(interaction); + } }, }; diff --git a/src/commands/counter/addons/view.js b/src/commands/counter/addons/view.js new file mode 100644 index 0000000..54cf258 --- /dev/null +++ b/src/commands/counter/addons/view.js @@ -0,0 +1,48 @@ +const config = require('../../../../config.json'); +const logger = require('../../../handlers/logger'); + +const { counters } = require('../../../helpers/database/models'); + +module.exports = async (interaction) => { + try { + // Destructure member + const { member } = await interaction; + + // Get options + const channel = await interaction.options.getChannel('channel'); + + const counter = await counters.findOne({ + guildId: member.guild.id, + channelId: channel.id, + }); + + if (!counter) { + // Create embed object + const embed = { + title: 'Counter - View', + description: `${channel} is not a counting channel.`, + timestamp: new Date(), + color: config.colors.error, + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send interaction reply + return await interaction.editReply({ embeds: [embed] }); + } + + // Create embed object + const embed = { + title: 'Counter - View', + color: config.colors.success, + description: `${channel} is currently at number ${counter.counter}.`, + timestamp: new Date(), + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send interaction reply + return await interaction.editReply({ embeds: [embed], ephemeral: true }); + } catch (e) { + // Send debug message + await logger.error(e); + } +}; diff --git a/src/commands/counter/index.js b/src/commands/counter/index.js new file mode 100644 index 0000000..d5e3f23 --- /dev/null +++ b/src/commands/counter/index.js @@ -0,0 +1,26 @@ +const { SlashCommandBuilder } = require('@discordjs/builders'); + +const view = require('./addons/view'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('counter') + .setDescription('Manage counters.') + .addSubcommand((subcommand) => + subcommand + .setName('view') + .setDescription('View a counter.') + .addChannelOption((option) => + option + .setName('channel') + .setDescription('The counter channel you want to view') + ) + ), + async execute(interaction) { + // If subcommand is view + if (interaction.options.getSubcommand() === 'view') { + // Execute view addon + await view(interaction); + } + }, +}; diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index 1df6235..f416cee 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -5,6 +5,7 @@ const { guilds, experiences, credits, + counters, timeouts, } = require('../helpers/database/models'); @@ -17,6 +18,30 @@ module.exports = { // If message author is bot if (message.author.bot) return; + // Get counter object + const counter = await counters.findOne({ + guildId: message.guild.id, + channelId: message.channel.id, + }); + + // If counter for the message channel + if (counter) { + // If message content is not strictly the same as counter word + if (message.content !== counter.word) { + // Delete the message + await message.delete(); + } else { + // Add 1 to the counter object + await counters.findOneAndUpdate( + { + guildId: message.guild.id, + channelId: message.channel.id, + }, + { $inc: { counter: 1 } } + ); + } + } + // Create user if not already created await users.findOne( { userId: message.author.id }, diff --git a/src/helpers/database/models/counterSchema.js b/src/helpers/database/models/counterSchema.js new file mode 100644 index 0000000..9ebef31 --- /dev/null +++ b/src/helpers/database/models/counterSchema.js @@ -0,0 +1,34 @@ +const mongoose = require('mongoose'); + +const counterSchema = new mongoose.Schema( + { + guildId: { + type: mongoose.SchemaTypes.Decimal128, + required: true, + unique: false, + index: true, + }, + channelId: { + type: mongoose.SchemaTypes.String, + required: true, + unique: true, + index: true, + }, + word: { + type: mongoose.SchemaTypes.String, + required: true, + unique: false, + index: true, + }, + counter: { + type: mongoose.SchemaTypes.Number, + required: true, + unique: false, + index: true, + default: 0, + }, + }, + { timestamps: true } +); + +module.exports = mongoose.model('counter', counterSchema); diff --git a/src/helpers/database/models/index.js b/src/helpers/database/models/index.js index d1a2a82..564c89d 100644 --- a/src/helpers/database/models/index.js +++ b/src/helpers/database/models/index.js @@ -4,6 +4,7 @@ const users = require('./userSchema'); const guilds = require('./guildSchema'); const apis = require('./apiSchema'); const timeouts = require('./timeoutSchema'); +const counters = require('./counterSchema'); module.exports = { credits, @@ -12,4 +13,5 @@ module.exports = { guilds, apis, timeouts, + counters, }; From 0bc211326dbe73a9ef4dfcaafbb7604f9a9135bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Olausson=20Holten=C3=A4s?= Date: Sun, 13 Mar 2022 18:57:54 +0100 Subject: [PATCH 5/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20counter=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/admin/counter/addons/add.js | 3 --- src/commands/admin/counter/addons/remove.js | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/commands/admin/counter/addons/add.js b/src/commands/admin/counter/addons/add.js index 731638a..98a5a99 100644 --- a/src/commands/admin/counter/addons/add.js +++ b/src/commands/admin/counter/addons/add.js @@ -5,9 +5,6 @@ const logger = require('../../../../handlers/logger'); // Database models const { counters } = require('../../../../helpers/database/models'); -const creditNoun = require('../../../../helpers/creditNoun'); -const { count } = require('../../../../helpers/database/models/apiSchema'); - module.exports = async (interaction) => { // Destructure member const { member } = interaction; diff --git a/src/commands/admin/counter/addons/remove.js b/src/commands/admin/counter/addons/remove.js index 1d4d855..9c42959 100644 --- a/src/commands/admin/counter/addons/remove.js +++ b/src/commands/admin/counter/addons/remove.js @@ -5,9 +5,6 @@ const logger = require('../../../../handlers/logger'); // Database models const { counters } = require('../../../../helpers/database/models'); -const creditNoun = require('../../../../helpers/creditNoun'); -const { count } = require('../../../../helpers/database/models/apiSchema'); - module.exports = async (interaction) => { // Destructure member const { member } = interaction; From b852a2732557983365a03fffb2e6e89169d80c0b Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 13 Mar 2022 18:01:24 +0000 Subject: [PATCH 6/6] [CodeFactor] Apply fixes --- src/commands/admin/counter/addons/add.js | 27 ++++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/commands/admin/counter/addons/add.js b/src/commands/admin/counter/addons/add.js index 98a5a99..154adfc 100644 --- a/src/commands/admin/counter/addons/add.js +++ b/src/commands/admin/counter/addons/add.js @@ -46,14 +46,14 @@ module.exports = async (interaction) => { const counterExist = await counters.findOne({ guildId: member.guild.id, channelId: channel.id, - word: word, + word, }); if (!counterExist) { await counters.create({ guildId: member.guild.id, channelId: channel.id, - word: word, + word, counter: start || 0, }); // Create embed object @@ -72,19 +72,18 @@ module.exports = async (interaction) => { `Guild: ${member.guild.id} User: ${member.id} added ${channel.id} as a counter using word "${word}" for counting.` ); - // Send interaction reply - return await interaction.editReply({ embeds: [embed] }); - } else { - // Create embed object - const embed = { - title: 'Admin - Counter', - description: `${channel} is already a counting channel.`, - timestamp: new Date(), - color: config.colors.error, - footer: { iconURL: config.footer.icon, text: config.footer.text }, - }; - // Send interaction reply return await interaction.editReply({ embeds: [embed] }); } + // Create embed object + const embed = { + title: 'Admin - Counter', + description: `${channel} is already a counting channel.`, + timestamp: new Date(), + color: config.colors.error, + footer: { iconURL: config.footer.icon, text: config.footer.text }, + }; + + // Send interaction reply + return await interaction.editReply({ embeds: [embed] }); };