diff --git a/package.json b/package.json index 9c5e242..0c65bf8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "borobot", - "version": "1.35.1", + "version": "1.35.2", "description": "A simple Discord Bot build with Discord.js", "displayName": "Borobot", "bugs": { @@ -42,7 +42,6 @@ "@napi-rs/canvas": "^0.1.30", "@vitalets/google-translate-api": "^9.0.0", "anime-images-api": "^2.0.0", - "ascii-table": "^0.0.9", "axios": "^1.1.3", "canvas": "^2.10.2", "change-case": "^4.1.2", diff --git a/src/commands/misc/info.js b/src/commands/misc/info.js index c58db23..0b972af 100644 --- a/src/commands/misc/info.js +++ b/src/commands/misc/info.js @@ -2101,11 +2101,11 @@ module.exports = { name: '🐣 Spawn', value: entity.spawns ? entity.spawns - .map((spawn) => - !/^[A-Z|\d+]/.test(spawn) + .map((spawn) => { + return !/^[A-Z|\d+]/.test(spawn) ? capitalCase(spawn) - : spawn, - ) + : spawn; + }) .join(', ') : italic('Unknown'), }, diff --git a/src/commands/mod/ban.js b/src/commands/mod/ban.js index 5a3ff9b..7a30f70 100644 --- a/src/commands/mod/ban.js +++ b/src/commands/mod/ban.js @@ -203,13 +203,13 @@ module.exports = { if (!bannedUser) throw "This user isn't banned."; - const u = await guild.members.unban( + const banUser = await guild.members.unban( bannedUser, 'ban temporary duration has passed.', ); - if (!u.bot) { - return u + if (!banUser.bot) { + return banUser .send({ content: `Congratulations! You have been unbanned from ${bold( guild, @@ -218,7 +218,7 @@ module.exports = { .catch( async () => await interaction.followUp({ - content: `Could not send a DM to ${u}.`, + content: `Could not send a DM to ${banUser}.`, ephemeral: true, }), ); @@ -237,14 +237,14 @@ module.exports = { if (!bannedUser) throw "This user isn't banned."; - const u = await guild.members.unban(bannedUser, reason); + const banUser = await guild.members.unban(bannedUser, reason); await interaction.editReply({ - content: `Successfully ${bold('unbanned')} ${u.tag}.`, + content: `Successfully ${bold('unbanned')} ${banUser.tag}.`, }); - if (!u.bot) { - return u + if (!banUser.bot) { + return banUser .send({ content: `Congratulations! You have been unbanned from ${bold( guild, @@ -253,7 +253,7 @@ module.exports = { .catch( async () => await interaction.followUp({ - content: `Could not send a DM to ${u}.`, + content: `Could not send a DM to ${banUser}.`, ephemeral: true, }), ); diff --git a/src/commands/mod/clear.js b/src/commands/mod/clear.js index a5474ae..52411c0 100644 --- a/src/commands/mod/clear.js +++ b/src/commands/mod/clear.js @@ -101,10 +101,11 @@ module.exports = { { messages.filter((message) => { if (message.author.id === member.id && amount > i) { + filteredMessages.set(message.id, message); i++; - - return filteredMessages.set(message.id, message); } + + return message; }); if (!filteredMessages.size) { @@ -121,10 +122,11 @@ module.exports = { messages.filter((message) => { if (membersWithRole.includes(message.author.id) && amount > i) { + filteredMessages.set(message.id, message); i++; - - return filteredMessages.set(message.id, message); } + + return message; }); if (!filteredMessages.size) { diff --git a/src/commands/systems/music.js b/src/commands/systems/music.js index da2aa56..7b3174c 100644 --- a/src/commands/systems/music.js +++ b/src/commands/systems/music.js @@ -420,7 +420,7 @@ module.exports = { .then(async (messages) => { await distube.play( voiceChannel, - searchResults[+messages.first().content - 1].name, + searchResults[Number(messages.first().content) - 1].name, { textChannel, member }, ); diff --git a/src/functions/handlers/handleCommands.js b/src/functions/handlers/handleCommands.js index 4e5c94c..5fee143 100644 --- a/src/functions/handlers/handleCommands.js +++ b/src/functions/handlers/handleCommands.js @@ -1,4 +1,3 @@ -const AsciiTable = require('ascii-table'); const { REST, Routes } = require('discord.js'); const fs = require('fs'); const path = require('path'); @@ -9,18 +8,11 @@ const path = require('path'); */ module.exports = (client) => { client.handleCommands = async () => { - const table = new AsciiTable(); - - table.setHeading('Name', 'Category', 'Type', 'Status'); - /** @type {{ commands: import('discord.js').Collection }>, commandArray: import('discord.js').RESTPostAPIChatInputApplicationCommandsJSONBody[] }} */ const { commands, commandArray } = client; const commandPath = path.join(__dirname, '..', '..', 'commands'); const commandFolders = fs.readdirSync(commandPath); - /** @type {String[]} */ - const arr = []; - for (const folder of commandFolders) { const commandSubPath = path.join(commandPath, folder); const commandFiles = fs @@ -35,17 +27,8 @@ module.exports = (client) => { commands.set(command.data.name, command); commandArray.push(command.data.toJSON()); - table.addRow( - command?.data.name ?? file, - folder, - command?.type ?? 'None', - '✅', - ); - table.sort((a, b) => a[0].localeCompare(b[0])); - arr.push(file); } } - table.setTitle(`Commands${arr.length ? ` (${arr.length})` : ''}`); const rest = new REST({ version: '10' }).setToken(process.env.TOKEN); diff --git a/src/functions/handlers/handleComponents.js b/src/functions/handlers/handleComponents.js index aac181c..b16f016 100644 --- a/src/functions/handlers/handleComponents.js +++ b/src/functions/handlers/handleComponents.js @@ -1,4 +1,3 @@ -const AsciiTable = require('ascii-table'); const fs = require('fs'); const path = require('path'); @@ -8,10 +7,6 @@ const path = require('path'); */ module.exports = (client) => { client.handleComponents = () => { - const table = new AsciiTable('Components'); - - table.setHeading('Name', 'Status'); - const componentPath = path.join(__dirname, '..', '..', 'components'); if (fs.existsSync(componentPath)) { @@ -24,10 +19,6 @@ module.exports = (client) => { const filePath = path.join(componentPath, file); const component = require(filePath); - table.setTitle( - `Components${componentFiles.length && ` (${componentFiles.length})`}`, - ); - table.addRow(component.data.name, '✅'); components.set(component.data.name, component); } } diff --git a/src/functions/handlers/handleEvents.js b/src/functions/handlers/handleEvents.js index 67c316a..44962e3 100644 --- a/src/functions/handlers/handleEvents.js +++ b/src/functions/handlers/handleEvents.js @@ -1,6 +1,3 @@ -const AsciiTable = require('ascii-table'); -const { Events } = require('discord.js'); -const { Events: DistubeEvents } = require('distube'); const fs = require('fs'); const path = require('path'); @@ -10,11 +7,6 @@ const path = require('path'); */ module.exports = (client) => { client.handleEvents = () => { - const table = new AsciiTable('Events'); - - table.setHeading('Name', 'Instance', 'Status'); - - let total; const eventPath = path.join(__dirname, '..', '..', 'events'); const eventFolders = fs.readdirSync(eventPath); @@ -30,16 +22,6 @@ module.exports = (client) => { const filePath = path.join(eventSubPath, file); const event = require(filePath); - if (!Object.values(Events).includes(event.name)) { - table.addRow( - event?.name ?? file, - `${folder.charAt(0).toUpperCase()}${folder.slice(1)}`, - '❌ -> invalid event name.', - ); - - continue; - } - event.once ? client.once( event.name, @@ -49,15 +31,8 @@ module.exports = (client) => { event.name, async (...args) => await event.execute(...args, client), ); - - table.addRow( - event.name, - `${folder.charAt(0).toUpperCase()}${folder.slice(1)}`, - '✅', - ); } - total = eventFiles.length; break; case 'distube': @@ -65,33 +40,14 @@ module.exports = (client) => { const filePath = path.join(eventSubPath, file); const event = require(filePath); - if (!Object.values(DistubeEvents).includes(event.name)) { - table.addRow( - event?.name ?? file, - `${folder.charAt(0).toUpperCase()}${folder.slice(1)}`, - '❌ -> invalid event name.', - ); - - continue; - } - client.distube.on( event.name, async (...args) => await event.execute(...args, client), ); - - table.addRow( - event.name, - `${folder.charAt(0).toUpperCase()}${folder.slice(1)}`, - '✅', - ); } - total += eventFiles.length; break; } } - - table.setTitle(`Events ${total > 0 ? `(${total})` : ''}`); }; }; diff --git a/src/utils/applyHexColor.js b/src/utils/applyHexColor.js index 815c7a4..09bd7f8 100644 --- a/src/utils/applyHexColor.js +++ b/src/utils/applyHexColor.js @@ -5,9 +5,10 @@ const convert = require('color-convert'); * @param {String} color * @returns {String} The hex color code. */ -module.exports = (color) => - !/^[#]?[0-9A-F]{6}$/i.test(color) +module.exports = (color) => { + return !/^[#]?[0-9A-F]{6}$/i.test(color) ? convert.keyword.hex(color) : !color.startsWith('#') ? `#${color}` : color; +}; diff --git a/src/utils/applyTitleCase.js b/src/utils/applyTitleCase.js index d4640fe..4b62a4e 100644 --- a/src/utils/applyTitleCase.js +++ b/src/utils/applyTitleCase.js @@ -6,8 +6,8 @@ module.exports = (string) => string .split(' ') - .map((word) => - ![ + .map((word) => { + return ![ 'of', 'the', 'and', @@ -21,6 +21,6 @@ module.exports = (string) => 'but', ].includes(word) ? word.charAt(0).toUpperCase() + word.slice(1) - : word, - ) + : word; + }) .join(' '); diff --git a/src/utils/getFormattedParam.js b/src/utils/getFormattedParam.js index 42ddccc..60c3b4c 100644 --- a/src/utils/getFormattedParam.js +++ b/src/utils/getFormattedParam.js @@ -5,8 +5,8 @@ const { paramCase } = require('change-case'); * @param {String} query * @returns {String} The formatted query param. */ -module.exports = (query) => - query.toLowerCase().includes('itto') +module.exports = (query) => { + return query.toLowerCase().includes('itto') ? 'arataki-itto' : query.toLowerCase() === 'hutao' ? 'hu-tao' @@ -29,3 +29,4 @@ module.exports = (query) => : query.toLowerCase() === 'yunjin' ? 'yun-jin' : paramCase(query); +}; diff --git a/src/utils/serverMute.js b/src/utils/serverMute.js index 9a234cb..0421d85 100644 --- a/src/utils/serverMute.js +++ b/src/utils/serverMute.js @@ -133,7 +133,7 @@ const findOrCreateRole = async (interaction) => { ); }); - return new Promise((resolve) => resolve(mutedRole)); + return Promise.resolve(mutedRole); }; /** diff --git a/src/utils/truncate.js b/src/utils/truncate.js index 8b4e542..3d956ac 100644 --- a/src/utils/truncate.js +++ b/src/utils/truncate.js @@ -5,5 +5,10 @@ * @param {Number} [trim=3] * @returns {String} The truncated string. */ -module.exports = (str, max, trim = 3) => - str ? (str.length > max ? `${str.slice(0, max - trim)}...` : str) : null; +module.exports = (str, max, trim = 3) => { + return str + ? str.length > max + ? `${str.slice(0, max - trim)}...` + : str + : null; +};