From bc84a8ddf6cb4b3d4e53dd1d8ca3d0528a4425c1 Mon Sep 17 00:00:00 2001 From: Alexander Ballauf Date: Mon, 15 May 2023 22:51:43 +0200 Subject: [PATCH] Chore: eslint:fix --- commands/Music/autoplay.js | 108 +++++++++++----------- commands/Music/current.js | 126 ++++++++++++------------- commands/Music/join.js | 61 ++++++------ commands/Music/jump.js | 115 +++++++++++------------ commands/Music/leave.js | 84 ++++++++--------- commands/Music/loop.js | 104 ++++++++++----------- commands/Music/pause.js | 115 +++++++++++------------ commands/Music/play.js | 50 +++++----- commands/Music/previous.js | 73 +++++++-------- commands/Music/queue.js | 93 +++++++++---------- commands/Music/resume.js | 115 +++++++++++------------ commands/Music/shuffle.js | 64 ++++++------- commands/Music/skip.js | 109 +++++++++++----------- commands/Music/volume.js | 120 ++++++++++++------------ commands/games/connect4.js | 78 ++++++++-------- commands/games/minesweeper.js | 52 +++++------ commands/games/pokemon.js | 48 +++++----- commands/games/rps.js | 89 +++++++++--------- commands/games/slots.js | 40 ++++---- commands/games/snake.js | 66 ++++++------- commands/games/tictactoe.js | 82 ++++++++--------- commands/games/yugioh.js | 121 ++++++++++++------------ commands/misc/donate.js | 44 ++++----- commands/misc/github.js | 42 ++++----- commands/misc/guilds.js | 42 ++++----- commands/misc/invite.js | 42 ++++----- commands/misc/ping.js | 36 ++++---- commands/misc/uptime.js | 40 ++++---- commands/moderation/ban.js | 30 +++--- commands/moderation/clear.js | 20 ++-- commands/moderation/kick.js | 28 +++--- commands/moderation/log.js | 67 +++++++------- commands/moderation/nickname.js | 22 ++--- commands/moderation/role.js | 87 +++++++++--------- commands/owner/lvsv.js | 57 ++++++------ commands/owner/reload.js | 67 +++++++------- commands/util/about.js | 56 +++++------ commands/util/avatar.js | 2 +- commands/util/help.js | 114 ++++++++++++----------- commands/util/info.js | 158 ++++++++++++++++---------------- commands/util/poke.js | 94 +++++++++---------- events/deployCommands.js | 2 +- package-lock.json | 4 +- package.json | 2 +- version.json | 2 +- 45 files changed, 1492 insertions(+), 1479 deletions(-) diff --git a/commands/Music/autoplay.js b/commands/Music/autoplay.js index 6208078..7b8248c 100644 --- a/commands/Music/autoplay.js +++ b/commands/Music/autoplay.js @@ -1,56 +1,56 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("autoplay") - .setDescription("Enables or disables autoplay") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId - - if (!voiceChannelId) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } - - const botMember = interaction.guild.members.cache.get( - interaction.client.user.id - ) - - if (!botMember.voice?.channelId) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } - - const botVoiceChannelId = botMember.voice.channelId - - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ - content: - "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } - - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently nothing to autoplay!") - .setColor("#FF0000") - - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } - - const mode = distube.toggleAutoplay(interaction) - return interaction.reply( - `Set autoplay mode to \`${mode ? "On" : "Off"}\`` - ) - } -} + data: new SlashCommandBuilder() + .setName('autoplay') + .setDescription('Enables or disables autoplay') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; + + if (!voiceChannelId) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } + + const botMember = interaction.guild.members.cache.get( + interaction.client.user.id, + ); + + if (!botMember.voice?.channelId) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } + + const botVoiceChannelId = botMember.voice.channelId; + + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ + content: + 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } + + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is currently nothing to autoplay!') + .setColor('#FF0000'); + + return interaction.reply({ embeds: [queueError], ephemeral: true }); + } + + const mode = distube.toggleAutoplay(interaction); + return interaction.reply( + `Set autoplay mode to \`${mode ? 'On' : 'Off'}\``, + ); + }, +}; diff --git a/commands/Music/current.js b/commands/Music/current.js index f966440..c375d97 100644 --- a/commands/Music/current.js +++ b/commands/Music/current.js @@ -1,76 +1,76 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); const status = (queue) => { - const filterText = Array.isArray(queue.filters) ? queue.filters.join(", ") : "Off" - return `Volume: \`${queue.volume}%\` | Loop: \`${queue.repeatMode ? queue.repeatMode === 2 ? "All Queue" : "This Song" : "Off"}\` | Autoplay: \`${queue.autoplay ? "On" : "Off"}\` | Filter: \`${filterText}\`` -} + const filterText = Array.isArray(queue.filters) ? queue.filters.join(', ') : 'Off'; + return `Volume: \`${queue.volume}%\` | Loop: \`${queue.repeatMode ? queue.repeatMode === 2 ? 'All Queue' : 'This Song' : 'Off'}\` | Autoplay: \`${queue.autoplay ? 'On' : 'Off'}\` | Filter: \`${filterText}\``; +}; module.exports = { - data: new SlashCommandBuilder() - .setName("current") - .setDescription("Displays information about the current track is playing") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId + data: new SlashCommandBuilder() + .setName('current') + .setDescription('Displays information about the current track is playing') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; - if (!voiceChannelId) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } + if (!voiceChannelId) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } - const botMember = interaction.guild.members.cache.get( - interaction.client.user.id - ) + const botMember = interaction.guild.members.cache.get( + interaction.client.user.id, + ); - if (!botMember.voice?.channelId) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } + if (!botMember.voice?.channelId) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } - const botVoiceChannelId = botMember.voice.channelId + const botVoiceChannelId = botMember.voice.channelId; - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ - content: - "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ + content: + 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently nothing playing!") - .setColor("#FF0000") + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is currently nothing playing!') + .setColor('#FF0000'); - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } + return interaction.reply({ embeds: [queueError], ephemeral: true }); + } - const song = queue.songs[0] - const embed = new EmbedBuilder() - .setColor("#7200FF") - .setAuthor({ - name: "Now Playing", - iconURL: - "https://raw.githubusercontent.com/ballaual/DiCoBo/master/assets/music.gif" - }) - .setThumbnail(song.thumbnail) - .setDescription(`[${song.name}](${song.url})`) - .addFields( - { name: "**Views:**", value: song.views.toString(), inline: true }, - { name: "**Likes:**", value: song.likes.toString(), inline: true }, - { name: "**Duration:**", value: song.formattedDuration.toString(), inline: true }, - { name: "**Status**", value: status(queue).toString() }) - .setFooter({ text: `Requested by ${song.user.username}`, iconURL: song.user.avatarURL() }) - .setTimestamp() + const song = queue.songs[0]; + const embed = new EmbedBuilder() + .setColor('#7200FF') + .setAuthor({ + name: 'Now Playing', + iconURL: + 'https://raw.githubusercontent.com/ballaual/DiCoBo/master/assets/music.gif', + }) + .setThumbnail(song.thumbnail) + .setDescription(`[${song.name}](${song.url})`) + .addFields( + { name: '**Views:**', value: song.views.toString(), inline: true }, + { name: '**Likes:**', value: song.likes.toString(), inline: true }, + { name: '**Duration:**', value: song.formattedDuration.toString(), inline: true }, + { name: '**Status**', value: status(queue).toString() }) + .setFooter({ text: `Requested by ${song.user.username}`, iconURL: song.user.avatarURL() }) + .setTimestamp(); - return interaction.reply({ embeds: [embed] }) - } -} + return interaction.reply({ embeds: [embed] }); + }, +}; diff --git a/commands/Music/join.js b/commands/Music/join.js index d968677..89d35a8 100644 --- a/commands/Music/join.js +++ b/commands/Music/join.js @@ -1,33 +1,34 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { joinVoiceChannel } = require("@discordjs/voice") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { joinVoiceChannel } = require('@discordjs/voice'); module.exports = { - data: new SlashCommandBuilder() - .setName("join") - .setDescription("The bot joins the users voice channel to play music") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const voiceChannel = interaction.member.voice.channel - if (!voiceChannel) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } + data: new SlashCommandBuilder() + .setName('join') + .setDescription('The bot joins the users voice channel to play music') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const voiceChannel = interaction.member.voice.channel; + if (!voiceChannel) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } - try { - joinVoiceChannel({ - channelId: voiceChannel.id, - guildId: interaction.guildId, - adapterCreator: interaction.guild.voiceAdapterCreator - }) - await interaction.reply(`✅ | ***Successfully joined the voice channel "${voiceChannel.name}"***`) - } catch (error) { - return interaction.reply({ - content: `There was an error connecting to the voice channel: ${error}`, - ephemeral: true - }) - } - } -} + try { + joinVoiceChannel({ + channelId: voiceChannel.id, + guildId: interaction.guildId, + adapterCreator: interaction.guild.voiceAdapterCreator, + }); + await interaction.reply(`✅ | ***Successfully joined the voice channel "${voiceChannel.name}"***`); + } + catch (error) { + return interaction.reply({ + content: `There was an error connecting to the voice channel: ${error}`, + ephemeral: true, + }); + } + }, +}; diff --git a/commands/Music/jump.js b/commands/Music/jump.js index ae8b836..524597f 100644 --- a/commands/Music/jump.js +++ b/commands/Music/jump.js @@ -1,59 +1,60 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("jump") - .setDescription("Jumps to a song number in the queue and skip the rest") - .setDMPermission(false) - .addIntegerOption(option => - option.setName("id") - .setDescription("The music's ID in the queue") - .setRequired(true)), - category: "music", - async execute (interaction) { - const musicId = interaction.options.getInteger("id") - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId - - if (!voiceChannelId) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } - - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is Nothing There is currently nothing to skip!") - .setColor("FF0000") - return interaction.reply({ embeds: [queueError] }) - } - - const botMember = interaction.guild.members.cache.get(interaction.client.user.id) - - if (!botMember.voice?.channelId) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } - - const botVoiceChannelId = botMember.voice.channelId - - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ - content: "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } - - try { - await distube.jump(interaction, parseInt(musicId)) - await interaction.reply(`⏩ | ***Jumped to song number ${musicId} in the queue***`) - } catch (error) { - return interaction.reply({ content: "Invalid song ID!)", ephemeral: true }) - } - } -} + data: new SlashCommandBuilder() + .setName('jump') + .setDescription('Jumps to a song number in the queue and skip the rest') + .setDMPermission(false) + .addIntegerOption(option => + option.setName('id') + .setDescription('The music\'s ID in the queue') + .setRequired(true)), + category: 'music', + async execute(interaction) { + const musicId = interaction.options.getInteger('id'); + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; + + if (!voiceChannelId) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } + + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is Nothing There is currently nothing to skip!') + .setColor('FF0000'); + return interaction.reply({ embeds: [queueError] }); + } + + const botMember = interaction.guild.members.cache.get(interaction.client.user.id); + + if (!botMember.voice?.channelId) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } + + const botVoiceChannelId = botMember.voice.channelId; + + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ + content: 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } + + try { + await distube.jump(interaction, parseInt(musicId)); + await interaction.reply(`⏩ | ***Jumped to song number ${musicId} in the queue***`); + } + catch (error) { + return interaction.reply({ content: 'Invalid song ID!)', ephemeral: true }); + } + }, +}; diff --git a/commands/Music/leave.js b/commands/Music/leave.js index 6b41742..caba463 100644 --- a/commands/Music/leave.js +++ b/commands/Music/leave.js @@ -1,47 +1,49 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { joinVoiceChannel } = require("@discordjs/voice") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { joinVoiceChannel } = require('@discordjs/voice'); module.exports = { - data: new SlashCommandBuilder() - .setName("leave") - .setDescription("The bot leaves the current voice channel") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const voiceChannel = interaction.member.voice.channel - const botMember = interaction.guild.members.cache.get(interaction.client.user.id) + data: new SlashCommandBuilder() + .setName('leave') + .setDescription('The bot leaves the current voice channel') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const voiceChannel = interaction.member.voice.channel; + const botMember = interaction.guild.members.cache.get(interaction.client.user.id); - if (!voiceChannel && !botMember.voice?.channelId) { - return interaction.reply({ - content: "The bot is currently not in a voice channel.", - ephemeral: true - }) - } else if (voiceChannel && !botMember.voice?.channelId) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } else if (!voiceChannel) { - return interaction.reply({ - content: "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } + if (!voiceChannel && !botMember.voice?.channelId) { + return interaction.reply({ + content: 'The bot is currently not in a voice channel.', + ephemeral: true, + }); + } + else if (voiceChannel && !botMember.voice?.channelId) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } + else if (!voiceChannel) { + return interaction.reply({ + content: 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } - const connection = joinVoiceChannel({ - channelId: voiceChannel.id, - guildId: interaction.guildId, - adapterCreator: interaction.guild.voiceAdapterCreator - }) + const connection = joinVoiceChannel({ + channelId: voiceChannel.id, + guildId: interaction.guildId, + adapterCreator: interaction.guild.voiceAdapterCreator, + }); - if (!connection) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } + if (!connection) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } - connection.destroy() - await interaction.reply(`❌ | ***Successfully left the voice channel "${voiceChannel.name}"***`) - } -} + connection.destroy(); + await interaction.reply(`❌ | ***Successfully left the voice channel "${voiceChannel.name}"***`); + }, +}; diff --git a/commands/Music/loop.js b/commands/Music/loop.js index 7d37a7f..e10ec51 100644 --- a/commands/Music/loop.js +++ b/commands/Music/loop.js @@ -1,54 +1,54 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("loop") - .setDescription("Loops through current song or the queue") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - const voiceChannel = interaction.member.voice.channel - const botMember = interaction.guild.members.cache.get( - interaction.client.user.id - ) - const botVoiceChannel = botMember?.voice.channel - - if (!voiceChannel) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } - - if (!botVoiceChannel) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } - - if (voiceChannel !== botVoiceChannel) { - return interaction.reply({ - content: "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } - - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently nothing to loop!") - .setColor("#FF0000") - - return interaction.reply({ embeds: [queueError] }) - } - - const repeatMode = distube.setRepeatMode(interaction) - const repeatMessage = - repeatMode === 2 ? "Repeat queue" : repeatMode ? "Repeat song" : "Off" - - return interaction.reply(`Set repeat mode to \`${repeatMessage}\``) - } -} + data: new SlashCommandBuilder() + .setName('loop') + .setDescription('Loops through current song or the queue') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + const voiceChannel = interaction.member.voice.channel; + const botMember = interaction.guild.members.cache.get( + interaction.client.user.id, + ); + const botVoiceChannel = botMember?.voice.channel; + + if (!voiceChannel) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } + + if (!botVoiceChannel) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } + + if (voiceChannel !== botVoiceChannel) { + return interaction.reply({ + content: 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } + + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is currently nothing to loop!') + .setColor('#FF0000'); + + return interaction.reply({ embeds: [queueError] }); + } + + const repeatMode = distube.setRepeatMode(interaction); + const repeatMessage = + repeatMode === 2 ? 'Repeat queue' : repeatMode ? 'Repeat song' : 'Off'; + + return interaction.reply(`Set repeat mode to \`${repeatMessage}\``); + }, +}; diff --git a/commands/Music/pause.js b/commands/Music/pause.js index 4ded185..395563d 100644 --- a/commands/Music/pause.js +++ b/commands/Music/pause.js @@ -1,68 +1,69 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("pause") - .setDescription("Pauses the currently playing track") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId + data: new SlashCommandBuilder() + .setName('pause') + .setDescription('Pauses the currently playing track') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; - if (!voiceChannelId) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } + if (!voiceChannelId) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } - const botMember = interaction.guild.members.cache.get( - interaction.client.user.id - ) + const botMember = interaction.guild.members.cache.get( + interaction.client.user.id, + ); - if (!botMember.voice?.channelId) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } + if (!botMember.voice?.channelId) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } - const botVoiceChannelId = botMember.voice.channelId + const botVoiceChannelId = botMember.voice.channelId; - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ - content: "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ + content: 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently nothing to pause!") - .setColor("#FF0000") + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is currently nothing to pause!') + .setColor('#FF0000'); - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } + return interaction.reply({ embeds: [queueError], ephemeral: true }); + } - if (queue.paused) { - return interaction.reply({ - content: "The track has been already paused!", - ephemeral: true - }) - } + if (queue.paused) { + return interaction.reply({ + content: 'The track has been already paused!', + ephemeral: true, + }); + } - try { - await distube.pause(interaction) - await interaction.reply("⏸️ | ***Paused the current track***") - } catch (error) { - console.error(error) - return interaction.reply({ - content: "An error occurred while pausing the queue", - ephemeral: true - }) - } - } -} + try { + await distube.pause(interaction); + await interaction.reply('⏸️ | ***Paused the current track***'); + } + catch (error) { + console.error(error); + return interaction.reply({ + content: 'An error occurred while pausing the queue', + ephemeral: true, + }); + } + }, +}; diff --git a/commands/Music/play.js b/commands/Music/play.js index 4b133cf..13a9ecd 100644 --- a/commands/Music/play.js +++ b/commands/Music/play.js @@ -1,28 +1,28 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("play") - .setDescription("Plays music from Youtube, Spotify, Soundcloud or Deezer") - .addStringOption(option => - option.setName("query") - .setDescription("Search the song you want to play | Supported url: Youtube, Spotify, Soundcloud, Deezer") - .setRequired(true)) - .setDMPermission(false), - category: "music", - async execute (interaction) { - const voiceChannel = interaction.member.voice.channel - const query = interaction.options.getString("query") - if (!voiceChannel) { - return interaction.reply({ content: "Please join a voice channel first!", ephemeral: true }) - } + data: new SlashCommandBuilder() + .setName('play') + .setDescription('Plays music from Youtube, Spotify, Soundcloud or Deezer') + .addStringOption(option => + option.setName('query') + .setDescription('Search the song you want to play | Supported url: Youtube, Spotify, Soundcloud, Deezer') + .setRequired(true)) + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const voiceChannel = interaction.member.voice.channel; + const query = interaction.options.getString('query'); + if (!voiceChannel) { + return interaction.reply({ content: 'Please join a voice channel first!', ephemeral: true }); + } - await interaction.reply("🔍 **Searching and attempting...**") - await interaction.editReply("Searching done :ok_hand: \nPlayback will start shortly!") - distube.play(voiceChannel, query, { - textChannel: interaction.channel, - member: interaction.member - }) - } -} + await interaction.reply('🔍 **Searching and attempting...**'); + await interaction.editReply('Searching done :ok_hand: \nPlayback will start shortly!'); + distube.play(voiceChannel, query, { + textChannel: interaction.channel, + member: interaction.member, + }); + }, +}; diff --git a/commands/Music/previous.js b/commands/Music/previous.js index 58234b5..eb32804 100644 --- a/commands/Music/previous.js +++ b/commands/Music/previous.js @@ -1,43 +1,44 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { MessageEmbed } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { MessageEmbed } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("previous") - .setDescription("Plays the previous song") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId + data: new SlashCommandBuilder() + .setName('previous') + .setDescription('Plays the previous song') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; - if (!voiceChannelId) { - return interaction.reply({ content: "Please join a voice channel first!", ephemeral: true }) - } + if (!voiceChannelId) { + return interaction.reply({ content: 'Please join a voice channel first!', ephemeral: true }); + } - const botMember = interaction.guild.members.cache.get(interaction.client.user.id) - if (!botMember.voice?.channelId) { - return interaction.reply({ content: "I am not currently in a voice channel!", ephemeral: true }) - } + const botMember = interaction.guild.members.cache.get(interaction.client.user.id); + if (!botMember.voice?.channelId) { + return interaction.reply({ content: 'I am not currently in a voice channel!', ephemeral: true }); + } - const botVoiceChannelId = botMember.voice.channelId - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ content: "You need to be in the same voice channel as the bot to use this command!", ephemeral: true }) - } + const botVoiceChannelId = botMember.voice.channelId; + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ content: 'You need to be in the same voice channel as the bot to use this command!', ephemeral: true }); + } - if (!queue) { - const queueError = new MessageEmbed() - .setDescription("There is currently nothing playing!") - .setColor("#FF0000") - return interaction.reply({ embeds: [queueError] }) - } + if (!queue) { + const queueError = new MessageEmbed() + .setDescription('There is currently nothing playing!') + .setColor('#FF0000'); + return interaction.reply({ embeds: [queueError] }); + } - try { - await distube.previous(interaction) - await interaction.reply("⏮️ | ***Previous song***") - } catch { - return interaction.reply({ content: "There is no previous song in this queue", ephemeral: true }) - } - } -} + try { + await distube.previous(interaction); + await interaction.reply('⏮️ | ***Previous song***'); + } + catch { + return interaction.reply({ content: 'There is no previous song in this queue', ephemeral: true }); + } + }, +}; diff --git a/commands/Music/queue.js b/commands/Music/queue.js index c33a4e0..0363f4e 100644 --- a/commands/Music/queue.js +++ b/commands/Music/queue.js @@ -1,48 +1,49 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("queue") - .setDescription("Displays the current songs in the music queue") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently no song in the queue!") - .setColor("#FF0000") - - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } - - const queueItems = queue.songs.map((song, i) => { - return `${i === 0 ? "Playing:" : `${i}.`} ${song.name} - \`${song.formattedDuration}\`` - }) - - const chunkSize = 10 // Number of items to print in each message - const chunkedQueue = [] - - for (let i = 0; i < queueItems.length; i += chunkSize) { - chunkedQueue.push(queueItems.slice(i, i + chunkSize)) - } - - for (let i = 0; i < chunkedQueue.length; i++) { - const currentPart = i + 1 - const totalParts = chunkedQueue.length - const embed = new EmbedBuilder() - .setTitle(`**Current queue (Part ${currentPart}/${totalParts})**`) - .setDescription(`\n\n${chunkedQueue[i].join("\n")}`) - .setColor("#FFFF00") - - if (i === 0) { - await interaction.reply({ embeds: [embed] }) - } else { - await interaction.followUp({ embeds: [embed] }) - } - } - } -} + data: new SlashCommandBuilder() + .setName('queue') + .setDescription('Displays the current songs in the music queue') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is currently no song in the queue!') + .setColor('#FF0000'); + + return interaction.reply({ embeds: [queueError], ephemeral: true }); + } + + const queueItems = queue.songs.map((song, i) => { + return `${i === 0 ? 'Playing:' : `${i}.`} ${song.name} - \`${song.formattedDuration}\``; + }); + + const chunkSize = 10; + const chunkedQueue = []; + + for (let i = 0; i < queueItems.length; i += chunkSize) { + chunkedQueue.push(queueItems.slice(i, i + chunkSize)); + } + + for (let i = 0; i < chunkedQueue.length; i++) { + const currentPart = i + 1; + const totalParts = chunkedQueue.length; + const embed = new EmbedBuilder() + .setTitle(`**Current queue (Part ${currentPart}/${totalParts})**`) + .setDescription(`\n\n${chunkedQueue[i].join('\n')}`) + .setColor('#FFFF00'); + + if (i === 0) { + await interaction.reply({ embeds: [embed] }); + } + else { + await interaction.followUp({ embeds: [embed] }); + } + } + }, +}; diff --git a/commands/Music/resume.js b/commands/Music/resume.js index 67f5ab9..cc04b51 100644 --- a/commands/Music/resume.js +++ b/commands/Music/resume.js @@ -1,68 +1,69 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("resume") - .setDescription("Resumes the paused track") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId + data: new SlashCommandBuilder() + .setName('resume') + .setDescription('Resumes the paused track') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; - if (!voiceChannelId) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } + if (!voiceChannelId) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } - const botMember = interaction.guild.members.cache.get( - interaction.client.user.id - ) + const botMember = interaction.guild.members.cache.get( + interaction.client.user.id, + ); - if (!botMember.voice?.channelId) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } + if (!botMember.voice?.channelId) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } - const botVoiceChannelId = botMember.voice.channelId + const botVoiceChannelId = botMember.voice.channelId; - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ - content: "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ + content: 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently nothing to resume!") - .setColor("#FF0000") + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is currently nothing to resume!') + .setColor('#FF0000'); - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } + return interaction.reply({ embeds: [queueError], ephemeral: true }); + } - if (queue.playing) { - return interaction.reply({ - content: "The track is already playing!", - ephemeral: true - }) - } + if (queue.playing) { + return interaction.reply({ + content: 'The track is already playing!', + ephemeral: true, + }); + } - try { - await distube.resume(interaction) - await interaction.reply("▶️ | ***Resumed the current track***") - } catch (error) { - console.error(error) - return interaction.reply({ - content: "An error occurred while pausing the queue", - ephemeral: true - }) - } - } -} + try { + await distube.resume(interaction); + await interaction.reply('▶️ | ***Resumed the current track***'); + } + catch (error) { + console.error(error); + return interaction.reply({ + content: 'An error occurred while pausing the queue', + ephemeral: true, + }); + } + }, +}; diff --git a/commands/Music/shuffle.js b/commands/Music/shuffle.js index 787a4da..a109d69 100644 --- a/commands/Music/shuffle.js +++ b/commands/Music/shuffle.js @@ -1,39 +1,39 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("shuffle") - .setDescription("Shuffles the song inside the queue") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId + data: new SlashCommandBuilder() + .setName('shuffle') + .setDescription('Shuffles the song inside the queue') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; - if (!voiceChannelId) { - return interaction.reply({ content: "Please join a voice channel first!", ephemeral: true }) - } + if (!voiceChannelId) { + return interaction.reply({ content: 'Please join a voice channel first!', ephemeral: true }); + } - const botMember = interaction.guild.members.cache.get(interaction.client.user.id) - if (!botMember.voice?.channelId) { - return interaction.reply({ content: "I am not currently in a voice channel!", ephemeral: true }) - } + const botMember = interaction.guild.members.cache.get(interaction.client.user.id); + if (!botMember.voice?.channelId) { + return interaction.reply({ content: 'I am not currently in a voice channel!', ephemeral: true }); + } - const botVoiceChannelId = botMember.voice.channelId - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ content: "You need to be in the same voice channel as the bot to use this command!", ephemeral: true }) - } + const botVoiceChannelId = botMember.voice.channelId; + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ content: 'You need to be in the same voice channel as the bot to use this command!', ephemeral: true }); + } - if (!queue || queue.songs.length === 0) { - const queueError = new EmbedBuilder() - .setDescription("There is currently nothing to shuffle!") - .setColor("#FF0000") - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } + if (!queue || queue.songs.length === 0) { + const queueError = new EmbedBuilder() + .setDescription('There is currently nothing to shuffle!') + .setColor('#FF0000'); + return interaction.reply({ embeds: [queueError], ephemeral: true }); + } - await distube.shuffle(interaction) - await interaction.reply("🔀 | ***Shuffled the songs in the queue***") - } -} + await distube.shuffle(interaction); + await interaction.reply('🔀 | ***Shuffled the songs in the queue***'); + }, +}; diff --git a/commands/Music/skip.js b/commands/Music/skip.js index 9163b9a..adf0737 100644 --- a/commands/Music/skip.js +++ b/commands/Music/skip.js @@ -1,56 +1,57 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("skip") - .setDescription("Skips the current song in the queue") - .setDMPermission(false), - category: "music", - async execute (interaction) { - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId - - if (!voiceChannelId) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } - - const botMember = interaction.guild.members.cache.get( - interaction.client.user.id - ) - - if (!botMember.voice?.channelId) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } - - const botVoiceChannelId = botMember.voice.channelId - - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ - content: "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } - - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently nothing to skip!") - .setColor("#FF0000") - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } - - try { - await distube.skip(interaction) - await interaction.reply("⏩ | ***Skipped***") - } catch { - interaction.reply({ content: "There is no next song in this queue", ephemeral: true }) - } - } -} + data: new SlashCommandBuilder() + .setName('skip') + .setDescription('Skips the current song in the queue') + .setDMPermission(false), + category: 'music', + async execute(interaction) { + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; + + if (!voiceChannelId) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } + + const botMember = interaction.guild.members.cache.get( + interaction.client.user.id, + ); + + if (!botMember.voice?.channelId) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } + + const botVoiceChannelId = botMember.voice.channelId; + + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ + content: 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } + + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is currently nothing to skip!') + .setColor('#FF0000'); + return interaction.reply({ embeds: [queueError], ephemeral: true }); + } + + try { + await distube.skip(interaction); + await interaction.reply('⏩ | ***Skipped***'); + } + catch { + interaction.reply({ content: 'There is no next song in this queue', ephemeral: true }); + } + }, +}; diff --git a/commands/Music/volume.js b/commands/Music/volume.js index c3afa00..f1c2396 100644 --- a/commands/Music/volume.js +++ b/commands/Music/volume.js @@ -1,73 +1,73 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") -const progressbar = require("string-progressbar") -const distube = require("../../distubeClient") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); +const progressbar = require('string-progressbar'); +const distube = require('../../distubeClient'); module.exports = { - data: new SlashCommandBuilder() - .setName("volume") - .setDescription("Changes the volume of the music player") - .setDMPermission(false) - .addIntegerOption(option => - option - .setName("amount") - .setDescription("Percentage of the audio volume between 1 and 200") - .setRequired(true) - ), - timeout: 5000, - category: "music", - async execute (interaction) { - const volume = interaction.options.getInteger("amount") - const queue = await distube.getQueue(interaction) - const voiceChannelId = interaction.member.voice.channelId + data: new SlashCommandBuilder() + .setName('volume') + .setDescription('Changes the volume of the music player') + .setDMPermission(false) + .addIntegerOption(option => + option + .setName('amount') + .setDescription('Percentage of the audio volume between 1 and 200') + .setRequired(true), + ), + timeout: 5000, + category: 'music', + async execute(interaction) { + const volume = interaction.options.getInteger('amount'); + const queue = await distube.getQueue(interaction); + const voiceChannelId = interaction.member.voice.channelId; - if (!voiceChannelId) { - return interaction.reply({ - content: "Please join a voice channel first!", - ephemeral: true - }) - } + if (!voiceChannelId) { + return interaction.reply({ + content: 'Please join a voice channel first!', + ephemeral: true, + }); + } - const botMember = interaction.guild.members.cache.get(interaction.client.user.id) + const botMember = interaction.guild.members.cache.get(interaction.client.user.id); - if (!botMember.voice?.channelId) { - return interaction.reply({ - content: "I am not currently in a voice channel!", - ephemeral: true - }) - } + if (!botMember.voice?.channelId) { + return interaction.reply({ + content: 'I am not currently in a voice channel!', + ephemeral: true, + }); + } - const botVoiceChannelId = botMember.voice.channelId + const botVoiceChannelId = botMember.voice.channelId; - if (voiceChannelId !== botVoiceChannelId) { - return interaction.reply({ - content: "You need to be in the same voice channel as the bot to use this command!", - ephemeral: true - }) - } + if (voiceChannelId !== botVoiceChannelId) { + return interaction.reply({ + content: 'You need to be in the same voice channel as the bot to use this command!', + ephemeral: true, + }); + } - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently nothing playing!") - .setColor("#FF0000") + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription('There is currently nothing playing!') + .setColor('#FF0000'); - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } + return interaction.reply({ embeds: [queueError], ephemeral: true }); + } - if (volume < 1 || volume > 200) { - return interaction.reply({ - content: "Please enter a valid number (between 1 and 200)", - ephemeral: true - }) - } + if (volume < 1 || volume > 200) { + return interaction.reply({ + content: 'Please enter a valid number (between 1 and 200)', + ephemeral: true, + }); + } - await distube.setVolume(interaction, volume) + await distube.setVolume(interaction, volume); - const total = 200 - const current = volume - const bar = progressbar.splitBar(total, current, 27, "▬", "🔘")[0] + const total = 200; + const current = volume; + const bar = progressbar.splitBar(total, current, 27, '▬', '🔘')[0]; - await interaction.reply(`Set the new volume to ${volume}%.`) - await interaction.channel.send(bar) - } -} + await interaction.reply(`Set the new volume to ${volume}%.`); + await interaction.channel.send(bar); + }, +}; diff --git a/commands/games/connect4.js b/commands/games/connect4.js index ddf9a0b..8ac8e3a 100644 --- a/commands/games/connect4.js +++ b/commands/games/connect4.js @@ -2,44 +2,44 @@ const { SlashCommandBuilder } = require('discord.js'); const { Connect4 } = require('discord-gamecord'); module.exports = { - data: new SlashCommandBuilder() - .setName('connect4') - .setDescription('Play a game of Connect4 with another player') - .setDMPermission(false) - .addUserOption(option => - option.setName('opponent') - .setDescription('Select your opponent') - .setRequired(true)), -category: "games", - async execute(interaction) { - const opponent = interaction.options.getUser('opponent'); - const game = new Connect4({ - message: interaction, - isSlashGame: true, - opponent, - embed: { - title: 'Connect4 Game', - statusTitle: 'Status', - color: '#5865F2' - }, - emojis: { - board: '⚪', - player1: '🔴', - player2: '🟡' - }, - mentionUser: true, - timeoutTime: 60000, - buttonStyle: 'PRIMARY', - turnMessage: '{emoji} | It\'s the turn of player **{player}**.', - winMessage: '{emoji} | **{player}** won the Connect4 Game.', - tieMessage: 'The game tied! No one won the game!', - timeoutMessage: 'The game went unfinished! No one won the game!', - playerOnlyMessage: `Only ${interaction.user} and ${opponent} can use these buttons.` - }); + data: new SlashCommandBuilder() + .setName('connect4') + .setDescription('Play a game of Connect4 with another player') + .setDMPermission(false) + .addUserOption(option => + option.setName('opponent') + .setDescription('Select your opponent') + .setRequired(true)), + category: 'games', + async execute(interaction) { + const opponent = interaction.options.getUser('opponent'); + const game = new Connect4({ + message: interaction, + isSlashGame: true, + opponent, + embed: { + title: 'Connect4 Game', + statusTitle: 'Status', + color: '#5865F2', + }, + emojis: { + board: '⚪', + player1: '🔴', + player2: '🟡', + }, + mentionUser: true, + timeoutTime: 60000, + buttonStyle: 'PRIMARY', + turnMessage: '{emoji} | It\'s the turn of player **{player}**.', + winMessage: '{emoji} | **{player}** won the Connect4 Game.', + tieMessage: 'The game tied! No one won the game!', + timeoutMessage: 'The game went unfinished! No one won the game!', + playerOnlyMessage: `Only ${interaction.user} and ${opponent} can use these buttons.`, + }); - game.startGame(); - game.on('gameOver', (result) => { - console.log(result); - }); - }, + game.startGame(); + game.on('gameOver', (result) => { + console.log(result); + }); + }, }; diff --git a/commands/games/minesweeper.js b/commands/games/minesweeper.js index e930500..4d5994b 100644 --- a/commands/games/minesweeper.js +++ b/commands/games/minesweeper.js @@ -2,31 +2,31 @@ const { SlashCommandBuilder } = require('discord.js'); const { Minesweeper } = require('discord-gamecord'); module.exports = { - data: new SlashCommandBuilder() - .setName('minesweeper') - .setDescription('Play a game of Minesweeper') - .setDMPermission(false), -category: "games", - async execute(interaction) { - const game = new Minesweeper({ - message: interaction, - isSlashGame: true, - embed: { - title: 'Minesweeper', - color: '#5865F2', - description: 'Click on the buttons to reveal the blocks except mines.' - }, - emojis: { flag: '🚩', mine: '💣' }, - mines: 5, - timeoutTime: 60000, - winMessage: 'You won the Game! You successfully avoided all the mines.', - loseMessage: 'You lost the Game! Be aware of the mines next time.', - playerOnlyMessage: 'Only {player} can use these buttons.' - }); + data: new SlashCommandBuilder() + .setName('minesweeper') + .setDescription('Play a game of Minesweeper') + .setDMPermission(false), + category: 'games', + async execute(interaction) { + const game = new Minesweeper({ + message: interaction, + isSlashGame: true, + embed: { + title: 'Minesweeper', + color: '#5865F2', + description: 'Click on the buttons to reveal the blocks except mines.', + }, + emojis: { flag: '🚩', mine: '💣' }, + mines: 5, + timeoutTime: 60000, + winMessage: 'You won the Game! You successfully avoided all the mines.', + loseMessage: 'You lost the Game! Be aware of the mines next time.', + playerOnlyMessage: 'Only {player} can use these buttons.', + }); - game.startGame(); - game.on('gameOver', result => { - console.log(result); - }); - }, + game.startGame(); + game.on('gameOver', result => { + console.log(result); + }); + }, }; diff --git a/commands/games/pokemon.js b/commands/games/pokemon.js index 8b19ba5..3b67990 100644 --- a/commands/games/pokemon.js +++ b/commands/games/pokemon.js @@ -2,29 +2,29 @@ const { SlashCommandBuilder } = require('discord.js'); const { GuessThePokemon } = require('discord-gamecord'); module.exports = { - data: new SlashCommandBuilder() - .setName('guesspokemon') - .setDescription('Play a game of Guess the Pokémon') - .setDMPermission(false), -category: "games", - async execute(interaction) { - const game = new GuessThePokemon({ - message: interaction, - isSlashGame: true, - embed: { - title: 'Who\'s The Pokémon', - color: '#5865F2' - }, - timeoutTime: 60000, - winMessage: 'You guessed it right! It was a {pokemon}.', - loseMessage: 'Better luck next time! It was a {pokemon}.', - errMessage: 'Unable to fetch Pokémon data! Please try again.', - playerOnlyMessage: 'Only {player} can use these buttons.' - }); + data: new SlashCommandBuilder() + .setName('guesspokemon') + .setDescription('Play a game of Guess the Pokémon') + .setDMPermission(false), + category: 'games', + async execute(interaction) { + const game = new GuessThePokemon({ + message: interaction, + isSlashGame: true, + embed: { + title: 'Who\'s The Pokémon', + color: '#5865F2', + }, + timeoutTime: 60000, + winMessage: 'You guessed it right! It was a {pokemon}.', + loseMessage: 'Better luck next time! It was a {pokemon}.', + errMessage: 'Unable to fetch Pokémon data! Please try again.', + playerOnlyMessage: 'Only {player} can use these buttons.', + }); - game.startGame(); - game.on('gameOver', result => { - console.log(result); - }); - }, + game.startGame(); + game.on('gameOver', result => { + console.log(result); + }); + }, }; diff --git a/commands/games/rps.js b/commands/games/rps.js index d27ef5f..0539d4a 100644 --- a/commands/games/rps.js +++ b/commands/games/rps.js @@ -2,51 +2,50 @@ const { SlashCommandBuilder } = require('discord.js'); const { RockPaperScissors } = require('discord-gamecord'); module.exports = { - data: new SlashCommandBuilder() - .setName('rps') - .setDescription('Play a game Rock Paper Scissors with another player') - .setDMPermission(false) - .addUserOption(option => option - .setName('opponent') - .setDescription('Select your opponent') - .setRequired(true)), -category: "games", - async execute(interaction) { - const opponent = interaction.options.getUser('opponent'); - const author = interaction.user; + data: new SlashCommandBuilder() + .setName('rps') + .setDescription('Play a game Rock Paper Scissors with another player') + .setDMPermission(false) + .addUserOption(option => option + .setName('opponent') + .setDescription('Select your opponent') + .setRequired(true)), + category: 'games', + async execute(interaction) { + const opponent = interaction.options.getUser('opponent'); - const game = new RockPaperScissors({ - message: interaction, - isSlashGame: true, - opponent: opponent, - embed: { - title: 'Rock Paper Scissors', - color: '#5865F2', - description: 'Press a button below to make a choice.' - }, - buttons: { - rock: 'Rock', - paper: 'Paper', - scissors: 'Scissors' - }, - emojis: { - rock: '🌑', - paper: '📰', - scissors: '✂️' - }, - mentionUser: true, - timeoutTime: 60000, - buttonStyle: 'PRIMARY', - pickMessage: 'You choose {emoji}.', - winMessage: '**{player}** won the Game! Congratulations!', - tieMessage: 'The Game tied! No one won the Game!', - timeoutMessage: 'The Game went unfinished! No one won the Game!', - playerOnlyMessage: 'Only {player} and {opponent} can use these buttons.' - }); + const game = new RockPaperScissors({ + message: interaction, + isSlashGame: true, + opponent: opponent, + embed: { + title: 'Rock Paper Scissors', + color: '#5865F2', + description: 'Press a button below to make a choice.', + }, + buttons: { + rock: 'Rock', + paper: 'Paper', + scissors: 'Scissors', + }, + emojis: { + rock: '🌑', + paper: '📰', + scissors: '✂️', + }, + mentionUser: true, + timeoutTime: 60000, + buttonStyle: 'PRIMARY', + pickMessage: 'You choose {emoji}.', + winMessage: '**{player}** won the Game! Congratulations!', + tieMessage: 'The Game tied! No one won the Game!', + timeoutMessage: 'The Game went unfinished! No one won the Game!', + playerOnlyMessage: 'Only {player} and {opponent} can use these buttons.', + }); - game.startGame(); - game.on('gameOver', result => { - console.log(result); - }); - }, + game.startGame(); + game.on('gameOver', result => { + console.log(result); + }); + }, }; diff --git a/commands/games/slots.js b/commands/games/slots.js index c18cd0b..b5de7ff 100644 --- a/commands/games/slots.js +++ b/commands/games/slots.js @@ -2,25 +2,25 @@ const { SlashCommandBuilder } = require('discord.js'); const { Slots } = require('discord-gamecord'); module.exports = { - data: new SlashCommandBuilder() - .setName('slots') - .setDescription('Play with the Slot Machine') - .setDMPermission(false), -category: "games", - async execute(interaction) { - const game = new Slots({ - message: interaction, - isSlashGame: true, - embed: { - title: 'Slot Machine', - color: '#5865F2' - }, - slots: ['🍇', '🍊', '🍋', '🍌'] - }); + data: new SlashCommandBuilder() + .setName('slots') + .setDescription('Play with the Slot Machine') + .setDMPermission(false), + category: 'games', + async execute(interaction) { + const game = new Slots({ + message: interaction, + isSlashGame: true, + embed: { + title: 'Slot Machine', + color: '#5865F2', + }, + slots: ['🍇', '🍊', '🍋', '🍌'], + }); - game.startGame(); - game.on('gameOver', result => { - console.log(result); - }); - }, + game.startGame(); + game.on('gameOver', result => { + console.log(result); + }); + }, }; diff --git a/commands/games/snake.js b/commands/games/snake.js index 2a53db3..e9669a8 100644 --- a/commands/games/snake.js +++ b/commands/games/snake.js @@ -2,38 +2,38 @@ const { SlashCommandBuilder } = require('discord.js'); const { Snake } = require('discord-gamecord'); module.exports = { - data: new SlashCommandBuilder() - .setName('snake') - .setDescription('Play a game of Snake') - .setDMPermission(false), -category: "games", - async execute(interaction) { - const game = new Snake({ - message: interaction, - isSlashGame: true, - embed: { - title: 'Snake Game', - overTitle: 'Game Over', - color: '#5865F2' - }, - emojis: { - board: '⬛', - food: '🍎', - up: '⬆️', - down: '⬇️', - left: '⬅️', - right: '➡️', - }, - snake: { head: '🟢', body: '🟩', tail: '🟢', skull: '💀' }, - foods: ['🍎', '🍇', '🍊', '🫐', '🥕', '🥝', '🌽'], - stopButton: 'Stop', - timeoutTime: 60000, - playerOnlyMessage: 'Only {player} can use these buttons.' - }); + data: new SlashCommandBuilder() + .setName('snake') + .setDescription('Play a game of Snake') + .setDMPermission(false), + category: 'games', + async execute(interaction) { + const game = new Snake({ + message: interaction, + isSlashGame: true, + embed: { + title: 'Snake Game', + overTitle: 'Game Over', + color: '#5865F2', + }, + emojis: { + board: '⬛', + food: '🍎', + up: '⬆️', + down: '⬇️', + left: '⬅️', + right: '➡️', + }, + snake: { head: '🟢', body: '🟩', tail: '🟢', skull: '💀' }, + foods: ['🍎', '🍇', '🍊', '🫐', '🥕', '🥝', '🌽'], + stopButton: 'Stop', + timeoutTime: 60000, + playerOnlyMessage: 'Only {player} can use these buttons.', + }); - game.startGame(); - game.on('gameOver', result => { - console.log(result); - }); - }, + game.startGame(); + game.on('gameOver', result => { + console.log(result); + }); + }, }; diff --git a/commands/games/tictactoe.js b/commands/games/tictactoe.js index 3e7989c..e86d781 100644 --- a/commands/games/tictactoe.js +++ b/commands/games/tictactoe.js @@ -2,47 +2,47 @@ const { SlashCommandBuilder } = require('discord.js'); const { TicTacToe } = require('discord-gamecord'); module.exports = { - data: new SlashCommandBuilder() - .setName('tictactoe') - .setDescription('Play a game of Tic Tac Toe with another player') - .setDMPermission(false) - .addUserOption(option => - option.setName('opponent') - .setDescription('Select your opponent') - .setRequired(true)), - category: "games", - async execute(interaction) { - const opponent = interaction.options.getUser('opponent'); + data: new SlashCommandBuilder() + .setName('tictactoe') + .setDescription('Play a game of Tic Tac Toe with another player') + .setDMPermission(false) + .addUserOption(option => + option.setName('opponent') + .setDescription('Select your opponent') + .setRequired(true)), + category: 'games', + async execute(interaction) { + const opponent = interaction.options.getUser('opponent'); - const game = new TicTacToe({ - message: interaction, - isSlashGame: true, - opponent: opponent, - embed: { - title: 'Tic Tac Toe', - color: '#5865F2', - statusTitle: 'Status', - overTitle: 'Game Over' - }, - emojis: { - xButton: '❌', - oButton: '🔵', - blankButton: '➖' - }, - mentionUser: true, - timeoutTime: 60000, - xButtonStyle: 'DANGER', - oButtonStyle: 'PRIMARY', - turnMessage: '{emoji} | It\'s {player}\'s turn.', - winMessage: '{emoji} | **{player}** won the Tic Tac Toe game!', - tieMessage: 'The game is tied! It\'s a draw.', - timeoutMessage: 'The game went unfinished! No one won the game.', - playerOnlyMessage: `Only {player} and ${opponent} can use these buttons.` - }); + const game = new TicTacToe({ + message: interaction, + isSlashGame: true, + opponent: opponent, + embed: { + title: 'Tic Tac Toe', + color: '#5865F2', + statusTitle: 'Status', + overTitle: 'Game Over', + }, + emojis: { + xButton: '❌', + oButton: '🔵', + blankButton: '➖', + }, + mentionUser: true, + timeoutTime: 60000, + xButtonStyle: 'DANGER', + oButtonStyle: 'PRIMARY', + turnMessage: '{emoji} | It\'s {player}\'s turn.', + winMessage: '{emoji} | **{player}** won the Tic Tac Toe game!', + tieMessage: 'The game is tied! It\'s a draw.', + timeoutMessage: 'The game went unfinished! No one won the game.', + playerOnlyMessage: `Only {player} and ${opponent} can use these buttons.`, + }); - game.startGame(); - game.on('gameOver', result => { - console.log(result); - }); - }, + game.startGame(); + game.on('gameOver', result => { + console.log(result); + }); + }, }; diff --git a/commands/games/yugioh.js b/commands/games/yugioh.js index f893d50..741ce32 100644 --- a/commands/games/yugioh.js +++ b/commands/games/yugioh.js @@ -1,78 +1,77 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); -const fs = require('fs'); const axios = require('axios'); module.exports = { - data: new SlashCommandBuilder() - .setName('yugioh') - .setDescription('Uploads and posts anonymously a .ydk file.') - .setDMPermission(false) - .addAttachmentOption((option) => - option - .setName('file') - .setDescription('Upload a .ydk file') - .setRequired(true) - ), - category: "games", - async execute(interaction) { - const file = interaction.options.getAttachment('file'); + data: new SlashCommandBuilder() + .setName('yugioh') + .setDescription('Uploads and posts anonymously a .ydk file.') + .setDMPermission(false) + .addAttachmentOption((option) => + option + .setName('file') + .setDescription('Upload a .ydk file') + .setRequired(true), + ), + category: 'games', + async execute(interaction) { + const file = interaction.options.getAttachment('file'); - const attachmentName = `${generateRandomName()}.ydk`; - const originalFileName = file.name; // Get the original file name - const channel = interaction.channel; + const attachmentName = `${generateRandomName()}.ydk`; + const originalFileName = file.name; + const channel = interaction.channel; - // Check if the file extension is .ydk - if (!originalFileName.endsWith('.ydk')) { - return await interaction.reply({ - content: 'Invalid file format. Please upload a .ydk file.', - ephemeral: true, - }); - } + if (!originalFileName.endsWith('.ydk')) { + return await interaction.reply({ + content: 'Invalid file format. Please upload a .ydk file.', + ephemeral: true, + }); + } - await interaction.reply({ - content: `Uploading file \`${originalFileName}\`...`, - ephemeral: true, - }); + await interaction.reply({ + content: `Uploading file \`${originalFileName}\`...`, + ephemeral: true, + }); - try { - const fileData = await getFileData(file.attachment); - await channel.send({ - content: "A new anonymous deck file has been uploaded!\nVisit https://yugiohdeck.github.io/ and upload the file to see its content.", - files: [{ - attachment: fileData, - name: attachmentName - }], - }); + try { + const fileData = await getFileData(file.attachment); + await channel.send({ + content: 'A new anonymous deck file has been uploaded!\nVisit https://yugiohdeck.github.io/ and upload the file to see its content.', + files: [{ + attachment: fileData, + name: attachmentName, + }], + }); - await interaction.followUp({ - content: `File \`${originalFileName}\` sent successfully and renamed to \`${attachmentName}\`.`, - ephemeral: true, - }); - } catch (error) { - console.error('Error uploading file:', error); - return await interaction.followUp({ - content: 'An error occurred while uploading the file.', - ephemeral: true, - }); - } - }, + await interaction.followUp({ + content: `File \`${originalFileName}\` sent successfully and renamed to \`${attachmentName}\`.`, + ephemeral: true, + }); + } + catch (error) { + console.error('Error uploading file:', error); + return await interaction.followUp({ + content: 'An error occurred while uploading the file.', + ephemeral: true, + }); + } + }, }; function generateRandomName() { - const characters = + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - let randomName = ''; - for (let i = 0; i < 10; i++) { - randomName += characters.charAt( - Math.floor(Math.random() * characters.length) - ); - } - return randomName; + let randomName = ''; + for (let i = 0; i < 10; i++) { + randomName += characters.charAt( + Math.floor(Math.random() * characters.length), + ); + } + return randomName; } async function getFileData(attachment) { - const response = await axios.get(attachment, { - responseType: 'arraybuffer' - }); - return response.data; + const response = await axios.get(attachment, { + responseType: 'arraybuffer', + }); + return response.data; } diff --git a/commands/misc/donate.js b/commands/misc/donate.js index e10ff04..313a56d 100644 --- a/commands/misc/donate.js +++ b/commands/misc/donate.js @@ -1,28 +1,28 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); const { donate } = require('../../config.json'); module.exports = { - data: new SlashCommandBuilder() - .setName("donate") - .setDescription("Displays the donation link"), - category: "misc", - async execute (interaction) { - if (!donate) { - return interaction.reply({ content: "Missing `donate` parameter in config.json", ephemeral: true }) - } + data: new SlashCommandBuilder() + .setName('donate') + .setDescription('Displays the donation link'), + category: 'misc', + async execute(interaction) { + if (!donate) { + return interaction.reply({ content: 'Missing `donate` parameter in config.json', ephemeral: true }); + } - if (!donate.startsWith("https://paypal.com/")) { - return interaction.reply({ content: "Please provide a valid Paypal link", ephemeral: true }) - } + if (!donate.startsWith('https://paypal.com/')) { + return interaction.reply({ content: 'Please provide a valid Paypal link', ephemeral: true }); + } - const embed = new EmbedBuilder() - .setTitle("Thank you for donating!") - .setThumbnail("https://cdn.discordapp.com/emojis/1092421597211656262.png") - .setColor("#007BFF") - .setDescription(`You like the bot and want to support me? - You can donate via Paypal:\n${donate}`) + const embed = new EmbedBuilder() + .setTitle('Thank you for donating!') + .setThumbnail('https://cdn.discordapp.com/emojis/1092421597211656262.png') + .setColor('#007BFF') + .setDescription(`You like the bot and want to support me? + You can donate via Paypal:\n${donate}`); - return interaction.reply({ embeds: [embed] }) - } -} \ No newline at end of file + return interaction.reply({ embeds: [embed] }); + }, +}; \ No newline at end of file diff --git a/commands/misc/github.js b/commands/misc/github.js index 09ced25..2362f3e 100644 --- a/commands/misc/github.js +++ b/commands/misc/github.js @@ -1,27 +1,27 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); const { github } = require('../../config.json'); module.exports = { - data: new SlashCommandBuilder() - .setName("github") - .setDescription("Displays the link to the public github repository of the bot"), - category: "misc", - async execute (interaction) { - if (!github) { - return interaction.reply({ content: "Missing `githubLink` parameter in config.json", ephemeral: true }) - } + data: new SlashCommandBuilder() + .setName('github') + .setDescription('Displays the link to the public github repository of the bot'), + category: 'misc', + async execute(interaction) { + if (!github) { + return interaction.reply({ content: 'Missing `githubLink` parameter in config.json', ephemeral: true }); + } - if (!github.startsWith("https://github.com/")) { - return interaction.reply({ content: "Please provide a valid Github link", ephemeral: true }) - } + if (!github.startsWith('https://github.com/')) { + return interaction.reply({ content: 'Please provide a valid Github link', ephemeral: true }); + } - const embed = new EmbedBuilder() - .setTitle(`${interaction.client.user.username}'s Github repository`) - .setThumbnail("https://cdn.discordapp.com/emojis/1091295909972803616.png") - .setColor("#007BFF") - .setDescription(`You can find the sourcecode here:\n${github}`) + const embed = new EmbedBuilder() + .setTitle(`${interaction.client.user.username}'s Github repository`) + .setThumbnail('https://cdn.discordapp.com/emojis/1091295909972803616.png') + .setColor('#007BFF') + .setDescription(`You can find the sourcecode here:\n${github}`); - return interaction.reply({ embeds: [embed] }) - } -} \ No newline at end of file + return interaction.reply({ embeds: [embed] }); + }, +}; \ No newline at end of file diff --git a/commands/misc/guilds.js b/commands/misc/guilds.js index d8847a4..f637353 100644 --- a/commands/misc/guilds.js +++ b/commands/misc/guilds.js @@ -1,23 +1,23 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); module.exports = { - data: new SlashCommandBuilder() - .setName("guilds") - .setDescription("Displays the top 50 guilds the bot is in"), - category: "misc", - async execute (interaction) { - const guilds = interaction.client.guilds.cache - .sort((a, b) => b.memberCount - a.memberCount) - .first(50) - const description = guilds.map((guild, index) => { - return `${index + 1}) ${guild.name} | ${guild.memberCount} members | ID:${guild.id} ` - }).join("\n") - const embed = new EmbedBuilder() - .setTitle(`${interaction.client.user.username}'s Top 50 servers`) - .setThumbnail(interaction.client.user.displayAvatarURL()) - .setColor("#FFFF00") - .setDescription(description) - interaction.reply({ embeds: [embed] }) - } -} \ No newline at end of file + data: new SlashCommandBuilder() + .setName('guilds') + .setDescription('Displays the top 50 guilds the bot is in'), + category: 'misc', + async execute(interaction) { + const guilds = interaction.client.guilds.cache + .sort((a, b) => b.memberCount - a.memberCount) + .first(50); + const description = guilds.map((guild, index) => { + return `${index + 1}) ${guild.name} | ${guild.memberCount} members | ID:${guild.id} `; + }).join('\n'); + const embed = new EmbedBuilder() + .setTitle(`${interaction.client.user.username}'s Top 50 servers`) + .setThumbnail(interaction.client.user.displayAvatarURL()) + .setColor('#FFFF00') + .setDescription(description); + interaction.reply({ embeds: [embed] }); + }, +}; \ No newline at end of file diff --git a/commands/misc/invite.js b/commands/misc/invite.js index 2a9708b..d3bffda 100644 --- a/commands/misc/invite.js +++ b/commands/misc/invite.js @@ -1,27 +1,27 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); const { invite } = require('../../config.json'); module.exports = { - data: new SlashCommandBuilder() - .setName("invite") - .setDescription("Displays the invite link of the bot"), - category: "misc", - async execute (interaction) { - if (!invite) { - return interaction.reply({ content: "Missing `invite` parameter in config.json", ephemeral: true }) - } + data: new SlashCommandBuilder() + .setName('invite') + .setDescription('Displays the invite link of the bot'), + category: 'misc', + async execute(interaction) { + if (!invite) { + return interaction.reply({ content: 'Missing `invite` parameter in config.json', ephemeral: true }); + } - if (!invite.startsWith("https://discord.com/")) { - return interaction.reply({ content: "Please provide a valid invite link", ephemeral: true }) - } + if (!invite.startsWith('https://discord.com/')) { + return interaction.reply({ content: 'Please provide a valid invite link', ephemeral: true }); + } - const embed = new EmbedBuilder() - .setTitle(`${interaction.client.user.username}'s invite link`) - .setThumbnail(interaction.client.user.displayAvatarURL()) - .setColor("#007BFF") - .setDescription(`You can invite me to your server with the following link:\n${invite}`) + const embed = new EmbedBuilder() + .setTitle(`${interaction.client.user.username}'s invite link`) + .setThumbnail(interaction.client.user.displayAvatarURL()) + .setColor('#007BFF') + .setDescription(`You can invite me to your server with the following link:\n${invite}`); - return interaction.reply({ embeds: [embed] }) - } -} \ No newline at end of file + return interaction.reply({ embeds: [embed] }); + }, +}; \ No newline at end of file diff --git a/commands/misc/ping.js b/commands/misc/ping.js index 2bdcddf..bbded98 100644 --- a/commands/misc/ping.js +++ b/commands/misc/ping.js @@ -1,21 +1,21 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); module.exports = { cooldown: 10, - data: new SlashCommandBuilder() - .setName("ping") - .setDescription("Returns latency and API ping"), - category: "misc", - async execute (interaction) { - const embed = new EmbedBuilder() - .setColor("#FF0000") - .setTitle("PONG! :ping_pong:") - .setThumbnail(interaction.user.displayAvatarURL()) - .addFields( - { name: "Latency", value: `\`${Date.now() - interaction.createdTimestamp}ms\`` }, - { name: "API Latency", value: `\`${Math.round(interaction.client.ws.ping)}ms\`` } - ) - await interaction.reply({ embeds: [embed] }) - } -} \ No newline at end of file + data: new SlashCommandBuilder() + .setName('ping') + .setDescription('Returns latency and API ping'), + category: 'misc', + async execute(interaction) { + const embed = new EmbedBuilder() + .setColor('#FF0000') + .setTitle('PONG! :ping_pong:') + .setThumbnail(interaction.user.displayAvatarURL()) + .addFields( + { name: 'Latency', value: `\`${Date.now() - interaction.createdTimestamp}ms\`` }, + { name: 'API Latency', value: `\`${Math.round(interaction.client.ws.ping)}ms\`` }, + ); + await interaction.reply({ embeds: [embed] }); + }, +}; \ No newline at end of file diff --git a/commands/misc/uptime.js b/commands/misc/uptime.js index 56e8024..57d2579 100644 --- a/commands/misc/uptime.js +++ b/commands/misc/uptime.js @@ -1,24 +1,24 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); module.exports = { - data: new SlashCommandBuilder() - .setName("uptime") - .setDescription("Displays the bots uptime"), - category: "misc", - async execute (interaction) { - const days = Math.floor(interaction.client.uptime / 86400000) - const hours = Math.floor(interaction.client.uptime / 3600000) % 24 - const minutes = Math.floor(interaction.client.uptime / 60000) % 60 - const seconds = Math.floor(interaction.client.uptime / 1000) % 60 + data: new SlashCommandBuilder() + .setName('uptime') + .setDescription('Displays the bots uptime'), + category: 'misc', + async execute(interaction) { + const days = Math.floor(interaction.client.uptime / 86400000); + const hours = Math.floor(interaction.client.uptime / 3600000) % 24; + const minutes = Math.floor(interaction.client.uptime / 60000) % 60; + const seconds = Math.floor(interaction.client.uptime / 1000) % 60; - const embed = new EmbedBuilder() - .setTitle(`${interaction.client.user.username}`) - .setColor("#00FF00") - .addFields( - { name: ":computer: UPTIME", value: ` ${days} days ${hours} hrs ${minutes} min ${seconds} sec` }) - .setTimestamp() + const embed = new EmbedBuilder() + .setTitle(`${interaction.client.user.username}`) + .setColor('#00FF00') + .addFields( + { name: ':computer: UPTIME', value: ` ${days} days ${hours} hrs ${minutes} min ${seconds} sec` }) + .setTimestamp(); - await interaction.reply({ embeds: [embed] }) - } -} \ No newline at end of file + await interaction.reply({ embeds: [embed] }); + }, +}; \ No newline at end of file diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 5b98fe0..980de4e 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -1,29 +1,29 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() - .setName("ban") - .setDescription("Select a member and ban them from the server.") + .setName('ban') + .setDescription('Select a member and ban them from the server.') .addUserOption(option => option - .setName("target") - .setDescription("The member to ban") + .setName('target') + .setDescription('The member to ban') .setRequired(true)) .addStringOption(option => option - .setName("reason") - .setDescription("The reason for the ban") + .setName('reason') + .setDescription('The reason for the ban') .setRequired(false)) .setDefaultMemberPermissions(PermissionFlagsBits.BanMembers) .setDMPermission(false), - category: "moderation", + category: 'moderation', async execute(interaction) { - const user = interaction.options.getMember("target"); - const reason = interaction.options.getString("reason") || "No reason specified"; + const user = interaction.options.getMember('target'); + const reason = interaction.options.getString('reason') || 'No reason specified'; - if (member.id === interaction.guild.ownerId) { - return interaction.reply({ content: "You cannot bam the server owner!", ephemeral: true }); + if (user.id === interaction.guild.ownerId) { + return interaction.reply({ content: 'You cannot bam the server owner!', ephemeral: true }); } - - await member.ban({ reason }); - return interaction.reply({ content: `Successfully banned \`${user.user.username}\` for: \`${reason}\``}); + + await user.ban({ reason }); + return interaction.reply({ content: `Successfully banned \`${user.user.username}\` for: \`${reason}\`` }); }, }; diff --git a/commands/moderation/clear.js b/commands/moderation/clear.js index 85a4134..e351ea2 100644 --- a/commands/moderation/clear.js +++ b/commands/moderation/clear.js @@ -1,24 +1,24 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() - .setName("clear") - .setDescription("Clear up to 99 messages.") + .setName('clear') + .setDescription('Clear up to 99 messages.') .addIntegerOption(option => - option.setName("amount") - .setDescription("Number of messages to clear") + option.setName('amount') + .setDescription('Number of messages to clear') .setRequired(true) .setMinValue(1) .setMaxValue(100)) - .setDMPermission(false) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), - category: "moderation", + .setDMPermission(false) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), + category: 'moderation', async execute(interaction) { - const amount = interaction.options.getInteger("amount"); + const amount = interaction.options.getInteger('amount'); await interaction.channel.bulkDelete(amount, true).catch(error => { console.error(error); - interaction.reply({ content: "There was an error trying to clear messages in this channel!", ephemeral: true }); + interaction.reply({ content: 'There was an error trying to clear messages in this channel!', ephemeral: true }); }); return interaction.reply({ content: `Successfully cleared \`${amount}\` messages.`, ephemeral: true }); diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 8c614df..85ca298 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -1,31 +1,31 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() - .setName("kick") - .setDescription("Select a member and kick them from the server.") + .setName('kick') + .setDescription('Select a member and kick them from the server.') .addUserOption(option => option - .setName("target") - .setDescription("The member to kick") + .setName('target') + .setDescription('The member to kick') .setRequired(true)) .addStringOption(option => option - .setName("reason") - .setDescription("The reason for the kick") + .setName('reason') + .setDescription('The reason for the kick') .setRequired(false)) .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers) .setDMPermission(false), - category: "moderation", + category: 'moderation', async execute(interaction) { - const user = interaction.options.getMember("target"); - const reason = interaction.options.getString("reason") || "No reason specified"; + const user = interaction.options.getMember('target'); + const reason = interaction.options.getString('reason') || 'No reason specified'; // Check if the member being kicked is the server owner or an admin - if (member.id === interaction.guild.ownerId) { - return interaction.reply({ content: "You cannot kick the server owner!", ephemeral: true }); + if (user.id === interaction.guild.ownerId) { + return interaction.reply({ content: 'You cannot kick the server owner!', ephemeral: true }); } // Perform the kick - await member.kick({ reason }); - return interaction.reply({ content: `Successfully kicked \`${user.user.tag}\` for: \`${reason}\``}); + await user.kick({ reason }); + return interaction.reply({ content: `Successfully kicked \`${user.user.tag}\` for: \`${reason}\`` }); }, }; diff --git a/commands/moderation/log.js b/commands/moderation/log.js index 89c4abe..49df9a1 100644 --- a/commands/moderation/log.js +++ b/commands/moderation/log.js @@ -1,37 +1,38 @@ -const fs = require("fs") -const path = require("node:path") -const { SlashCommandBuilder } = require("@discordjs/builders") -const { AttachmentBuilder, PermissionFlagsBits } = require("discord.js") +const fs = require('fs'); +const path = require('node:path'); +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { AttachmentBuilder, PermissionFlagsBits } = require('discord.js'); module.exports = { - data: new SlashCommandBuilder() - .setName("log") - .setDescription("Displays the command log") - .setDMPermission(false) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - async execute (interaction) { - try { - const serverId = interaction.guild.id - const logFilePath = path.join(__dirname, "../../logs", `${serverId}.txt`) + data: new SlashCommandBuilder() + .setName('log') + .setDescription('Displays the command log') + .setDMPermission(false) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + async execute(interaction) { + try { + const serverId = interaction.guild.id; + const logFilePath = path.join(__dirname, '../../logs', `${serverId}.txt`); - // Check if the log file exists for the server - if (!fs.existsSync(logFilePath)) { - await interaction.reply({ content: "There is no command log for this server.", ephemeral: true }) - return - } + // Check if the log file exists for the server + if (!fs.existsSync(logFilePath)) { + await interaction.reply({ content: 'There is no command log for this server.', ephemeral: true }); + return; + } - // If the log file exists, create an attachment for it and send it - const attachment = new AttachmentBuilder(logFilePath, `${serverId}.txt`) - await interaction.reply({ - content: "Here is the command log:", - files: [attachment], - ephemeral: true - }) - } catch (err) { - console.error(err) - await interaction.reply( - "There was an error while fetching the command log." - ) - } - } -} + // If the log file exists, create an attachment for it and send it + const attachment = new AttachmentBuilder(logFilePath, `${serverId}.txt`); + await interaction.reply({ + content: 'Here is the command log:', + files: [attachment], + ephemeral: true, + }); + } + catch (err) { + console.error(err); + await interaction.reply( + 'There was an error while fetching the command log.', + ); + } + }, +}; diff --git a/commands/moderation/nickname.js b/commands/moderation/nickname.js index 4a506ae..c019a53 100644 --- a/commands/moderation/nickname.js +++ b/commands/moderation/nickname.js @@ -1,24 +1,24 @@ -const { SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() - .setName("nickname") - .setDescription("Change the nickname of a user") + .setName('nickname') + .setDescription('Change the nickname of a user') .addUserOption(option => option - .setName("target") - .setDescription("The user to change the nickname for") + .setName('target') + .setDescription('The user to change the nickname for') .setRequired(true)) .addStringOption(option => option - .setName("nickname") - .setDescription("The new nickname for the user") + .setName('nickname') + .setDescription('The new nickname for the user') .setRequired(true)), - category: "moderation", + category: 'moderation', async execute(interaction) { - const member = interaction.options.getMember("target"); - const nickname = interaction.options.getString("nickname"); + const member = interaction.options.getMember('target'); + const nickname = interaction.options.getString('nickname'); await member.setNickname(nickname); - return interaction.reply({ content: `Successfully changed the nickname for \`${member.user.tag}\` to \`${nickname}\`.`, ephemeral: true }); + return interaction.reply({ content: `Successfully changed the nickname for \`${member.user.tag}\` to \`${nickname}\`.`, ephemeral: true }); }, }; diff --git a/commands/moderation/role.js b/commands/moderation/role.js index 7418f7e..a34c018 100644 --- a/commands/moderation/role.js +++ b/commands/moderation/role.js @@ -1,48 +1,49 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); module.exports = { - data: new SlashCommandBuilder() - .setName('role') - .setDescription('Adds or removes a role from a user') - .setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles) - .setDMPermission(false) - .addSubcommand(subcommand => - subcommand - .setName('add') - .setDescription('Adds a role to a user') - .addUserOption(option => - option.setName('user') - .setDescription('Select the user') - .setRequired(true)) - .addRoleOption(option => - option.setName('role') - .setDescription('Select the role') - .setRequired(true)) - ) - .addSubcommand(subcommand => - subcommand - .setName('remove') - .setDescription('Removes a role from a user') - .addUserOption(option => - option.setName('user') - .setDescription('Select the user') - .setRequired(true)) - .addRoleOption(option => - option.setName('role') - .setDescription('Select the role') - .setRequired(true)) - ), - async execute(interaction) { - const subcommand = interaction.options.getSubcommand(); - const user = interaction.options.getMember('user'); - const role = interaction.options.getRole('role'); + data: new SlashCommandBuilder() + .setName('role') + .setDescription('Adds or removes a role from a user') + .setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles) + .setDMPermission(false) + .addSubcommand(subcommand => + subcommand + .setName('add') + .setDescription('Adds a role to a user') + .addUserOption(option => + option.setName('user') + .setDescription('Select the user') + .setRequired(true)) + .addRoleOption(option => + option.setName('role') + .setDescription('Select the role') + .setRequired(true)), + ) + .addSubcommand(subcommand => + subcommand + .setName('remove') + .setDescription('Removes a role from a user') + .addUserOption(option => + option.setName('user') + .setDescription('Select the user') + .setRequired(true)) + .addRoleOption(option => + option.setName('role') + .setDescription('Select the role') + .setRequired(true)), + ), + async execute(interaction) { + const subcommand = interaction.options.getSubcommand(); + const user = interaction.options.getMember('user'); + const role = interaction.options.getRole('role'); - if (subcommand === 'add') { - await user.roles.add(role); - await interaction.reply({content: `Added \`${role.name}\` to \`${user.user.tag}\``, ephemeral: true}); - } else if (subcommand === 'remove') { - await user.roles.remove(role); - await interaction.reply({conent: `Removed \`${role.name}\` from \`${user.user.tag}\``, ephemeral: true}); - } - }, + if (subcommand === 'add') { + await user.roles.add(role); + await interaction.reply({ content: `Added \`${role.name}\` to \`${user.user.tag}\``, ephemeral: true }); + } + else if (subcommand === 'remove') { + await user.roles.remove(role); + await interaction.reply({ conent: `Removed \`${role.name}\` from \`${user.user.tag}\``, ephemeral: true }); + } + }, }; diff --git a/commands/owner/lvsv.js b/commands/owner/lvsv.js index 101f602..c0bd0e9 100644 --- a/commands/owner/lvsv.js +++ b/commands/owner/lvsv.js @@ -1,33 +1,34 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { authorId } = require("../../config.json") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { authorId } = require('../../config.json'); module.exports = { - data: new SlashCommandBuilder() - .setName("lvsv") - .setDescription("Leaves a specified discord server | Bot owner only!") - .setDMPermission(false) - .addStringOption(option => - option.setName("id") - .setDescription("id server") - .setRequired(true)), - category: "owner", - async execute (interaction) { - const guildId = interaction.options.getString("id") - const guild = interaction.client.guilds.cache.get(guildId) + data: new SlashCommandBuilder() + .setName('lvsv') + .setDescription('Leaves a specified discord server | Bot owner only!') + .setDMPermission(false) + .addStringOption(option => + option.setName('id') + .setDescription('id server') + .setRequired(true)), + category: 'owner', + async execute(interaction) { + const guildId = interaction.options.getString('id'); + const guild = interaction.client.guilds.cache.get(guildId); - if (interaction.member.id !== authorId) { - return interaction.reply({ content: "Only the bot owner is allowed to use this command!", ephemeral: true }) - } + if (interaction.member.id !== authorId) { + return interaction.reply({ content: 'Only the bot owner is allowed to use this command!', ephemeral: true }); + } - if (!guild) { - return interaction.reply({ content: "No guild ID was specified. Please specify a guild ID", ephemeral: true }) - } + if (!guild) { + return interaction.reply({ content: 'No guild ID was specified. Please specify a guild ID', ephemeral: true }); + } - try { - await guild.leave() - return interaction.reply({ content: `Left **${guild.name}** with \`${guild.memberCount}\` members.`, ephemeral: true }) - } catch (err) { - return interaction.reply({ content: `An error occurred while leaving the server: \`${err.message}\``, ephemeral: true }) - } - } -} + try { + await guild.leave(); + return interaction.reply({ content: `Left **${guild.name}** with \`${guild.memberCount}\` members.`, ephemeral: true }); + } + catch (err) { + return interaction.reply({ content: `An error occurred while leaving the server: \`${err.message}\``, ephemeral: true }); + } + }, +}; diff --git a/commands/owner/reload.js b/commands/owner/reload.js index 8085519..322b3d5 100644 --- a/commands/owner/reload.js +++ b/commands/owner/reload.js @@ -1,41 +1,42 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { SlashCommandBuilder } = require('discord.js'); const { ownerId } = require('../../config.json'); module.exports = { - data: new SlashCommandBuilder() - .setName('reload') - .setDescription('Reloads a command.') - .setDMPermission(false) - .addStringOption(option => - option.setName('command') - .setDescription('The command to reload.') - .setRequired(true)), - category: "owner", - async execute(interaction) { - const commandName = interaction.options.getString('command', true).toLowerCase(); - const command = interaction.client.commands.get(commandName); + data: new SlashCommandBuilder() + .setName('reload') + .setDescription('Reloads a command.') + .setDMPermission(false) + .addStringOption(option => + option.setName('command') + .setDescription('The command to reload.') + .setRequired(true)), + category: 'owner', + async execute(interaction) { + const commandName = interaction.options.getString('command', true).toLowerCase(); + const command = interaction.client.commands.get(commandName); - if (!command) { - return interaction.reply(`There is no command with the name \`${commandName}\`!`); - } + if (!command) { + return interaction.reply(`There is no command with the name \`${commandName}\`!`); + } - if (interaction.member.id !== ownerId) { - return interaction.reply({ - content: 'Only the bot owner is allowed to use this command!', - ephemeral: true - }); - } + if (interaction.member.id !== ownerId) { + return interaction.reply({ + content: 'Only the bot owner is allowed to use this command!', + ephemeral: true, + }); + } - delete require.cache[require.resolve(`../${command.category}/${command.data.name}.js`)]; + delete require.cache[require.resolve(`../${command.category}/${command.data.name}.js`)]; - try { - interaction.client.commands.delete(command.data.name); - const newCommand = require(`../${command.category}/${command.data.name}.js`); - interaction.client.commands.set(newCommand.data.name, newCommand); - await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`); - } catch (error) { - console.error(error); - await interaction.reply(`There was an error while reloading the command \`${command.data.name}\`:\n\`${error.message}\``); - } - }, + try { + interaction.client.commands.delete(command.data.name); + const newCommand = require(`../${command.category}/${command.data.name}.js`); + interaction.client.commands.set(newCommand.data.name, newCommand); + await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`); + } + catch (error) { + console.error(error); + await interaction.reply(`There was an error while reloading the command \`${command.data.name}\`:\n\`${error.message}\``); + } + }, }; diff --git a/commands/util/about.js b/commands/util/about.js index 73eeee7..8cc410c 100644 --- a/commands/util/about.js +++ b/commands/util/about.js @@ -1,33 +1,33 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); module.exports = { - data: new SlashCommandBuilder() - .setName("about") - .setDescription("Displays some information about a specific user") - .addUserOption((option) => - option - .setName("user") - .setDescription("The user to get information for") - .setRequired(true)) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('about') + .setDescription('Displays some information about a specific user') + .addUserOption((option) => + option + .setName('user') + .setDescription('The user to get information for') + .setRequired(true)) + .setDMPermission(false), category: 'util', - async execute (interaction) { - const user = interaction.options.getUser("user") + async execute(interaction) { + const user = interaction.options.getUser('user'); - const embed = new EmbedBuilder() - .setTitle(user.username) - .setColor("#D722F3") - .setURL(`https://discord.com/users/${user.id}`) - .setThumbnail(user.displayAvatarURL()) - .addFields( - { name: "User ID", value: user.id, inline: true }, - { name: "User Tag", value: user.tag, inline: true }, - { name: "Avatar URL", value: user.displayAvatarURL({ dynamic: true }) }, - { name: "Joined Discord", value: user.createdAt.toDateString(), inline: true }, - { name: "Joined Server", value: interaction.guild.members.cache.get(user.id).joinedAt.toDateString(), inline: true } - ) + const embed = new EmbedBuilder() + .setTitle(user.username) + .setColor('#D722F3') + .setURL(`https://discord.com/users/${user.id}`) + .setThumbnail(user.displayAvatarURL()) + .addFields( + { name: 'User ID', value: user.id, inline: true }, + { name: 'User Tag', value: user.tag, inline: true }, + { name: 'Avatar URL', value: user.displayAvatarURL({ dynamic: true }) }, + { name: 'Joined Discord', value: user.createdAt.toDateString(), inline: true }, + { name: 'Joined Server', value: interaction.guild.members.cache.get(user.id).joinedAt.toDateString(), inline: true }, + ); - await interaction.reply({ embeds: [embed] }) - } -} + await interaction.reply({ embeds: [embed] }); + }, +}; diff --git a/commands/util/avatar.js b/commands/util/avatar.js index a8332f6..9ad6e29 100644 --- a/commands/util/avatar.js +++ b/commands/util/avatar.js @@ -7,7 +7,7 @@ module.exports = { .addUserOption(option => option .setName('target') .setDescription('The user\'s avatar to show')) - .setDMPermission(false), + .setDMPermission(false), category: 'util', async execute(interaction) { const user = interaction.options.getUser('target'); diff --git a/commands/util/help.js b/commands/util/help.js index e71d21b..18bd9fe 100644 --- a/commands/util/help.js +++ b/commands/util/help.js @@ -1,65 +1,67 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const fs = require("fs") -const path = require("path") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const fs = require('fs'); +const path = require('path'); +const { EmbedBuilder } = require('discord.js'); module.exports = { - data: new SlashCommandBuilder() - .setName("help") - .setDescription("Shows a list with every command available") - .setDMPermission(false), - category: "util", - async execute (interaction) { - const commandFolders = fs.readdirSync(path.join(__dirname, "..", "..", "commands")).filter(folder => folder !== "Inactive") - const commands = [] + data: new SlashCommandBuilder() + .setName('help') + .setDescription('Shows a list with every command available') + .setDMPermission(false), + category: 'util', + async execute(interaction) { + const commandFolders = fs.readdirSync(path.join(__dirname, '..', '..', 'commands')).filter(folder => folder !== 'Inactive'); + const commands = []; - for (const folder of commandFolders) { - const folderCommands = fs.readdirSync(path.join(__dirname, "..", "..", "commands", folder)).filter(file => file.endsWith(".js")) - for (const file of folderCommands) { - try { - const command = require(path.join(__dirname, "..", "..", "commands", folder, file)) - if (command.data) { - commands.push(command.data.toJSON()) - } else { - console.log(`Command file ${file} in folder ${folder} doesn't have a data property.`) - } - } catch (error) { - console.log(`Error loading command file ${file} in folder ${folder}: ${error}`) - } - } - } + for (const folder of commandFolders) { + const folderCommands = fs.readdirSync(path.join(__dirname, '..', '..', 'commands', folder)).filter(file => file.endsWith('.js')); + for (const file of folderCommands) { + try { + const command = require(path.join(__dirname, '..', '..', 'commands', folder, file)); + if (command.data) { + commands.push(command.data.toJSON()); + } + else { + console.log(`Command file ${file} in folder ${folder} doesn't have a data property.`); + } + } + catch (error) { + console.log(`Error loading command file ${file} in folder ${folder}: ${error}`); + } + } + } - const sortedCommands = commands.sort((a, b) => a.name.localeCompare(b.name)) - const numCommands = sortedCommands.length - let start = 0 - let end = Math.min(start + 10, numCommands) + const sortedCommands = commands.sort((a, b) => a.name.localeCompare(b.name)); + const numCommands = sortedCommands.length; + let start = 0; + let end = Math.min(start + 10, numCommands); - const embed = new EmbedBuilder() - .setColor("#0000ff") - .setTitle(`Available (/) commands (Part ${Math.floor(start / 10) + 1} of ${Math.ceil(numCommands / 10)})`) - .addFields(sortedCommands.slice(start, end).map(command => ({ - name: `/${command.name}`, - value: command.description, - inline: false - }))) + const embed1 = new EmbedBuilder() + .setColor('#0000ff') + .setTitle(`Available (/) commands (Part ${Math.floor(start / 10) + 1} of ${Math.ceil(numCommands / 10)})`) + .addFields(sortedCommands.slice(start, end).map(command => ({ + name: `/${command.name}`, + value: command.description, + inline: false, + }))); - await interaction.reply({ embeds: [embed] }) - start = end + await interaction.reply({ embeds: [embed1] }); + start = end; - while (start < numCommands) { - end = Math.min(start + 10, numCommands) + while (start < numCommands) { + end = Math.min(start + 10, numCommands); - const embed = new EmbedBuilder() - .setColor("#0000ff") - .setTitle(`Available (/) commands (Part ${Math.floor(start / 10) + 1} of ${Math.ceil(numCommands / 10)})`) - .addFields(sortedCommands.slice(start, end).map(command => ({ - name: `/${command.name}`, - value: command.description, - inline: false - }))) + const embed2 = new EmbedBuilder() + .setColor('#0000ff') + .setTitle(`Available (/) commands (Part ${Math.floor(start / 10) + 1} of ${Math.ceil(numCommands / 10)})`) + .addFields(sortedCommands.slice(start, end).map(command => ({ + name: `/${command.name}`, + value: command.description, + inline: false, + }))); - await interaction.followUp({ embeds: [embed] }) - start = end - } - } -} + await interaction.followUp({ embeds: [embed2] }); + start = end; + } + }, +}; diff --git a/commands/util/info.js b/commands/util/info.js index 042f430..feb4450 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -1,82 +1,82 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder, version } = require("discord.js") -const os = require("os") -const botver = require("../../version.json").version +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder, version } = require('discord.js'); +const os = require('os'); +const botver = require('../../version.json').version; const { ownerId } = require('../../config.json'); module.exports = { - data: new SlashCommandBuilder() - .setName("info") - .setDescription("Displays detailed information about the bot"), - category: "util", - async execute (interaction) { - const client = interaction.client - const embed = new EmbedBuilder() - .setThumbnail(client.user.displayAvatarURL()) - .setTitle("Bot Information") - .setColor("#7200FF") - .addFields( - { - name: "<:author:1091296385388773437> Author", - value: `${client.users.cache.get(ownerId)?.tag}`, - inline: true - }, - { - name: "<:discord:1091295194818818098> Servers", - value: `Joined ${client.guilds.cache.size} servers`, - inline: true - }, - { - name: "<:channels:1091302046201810984> Channels", - value: `Watching ${client.channels.cache.size} channels`, - inline: true - }, - { - name: "<:user:1091295188762243114> Users", - value: `Serving ${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)} users`, - inline: true - }, - { - name: "<:join:1091295564483792926> Join Date", - value: client.user.createdAt.toLocaleDateString("en-us"), - inline: true - }, - { - name: "<:djs:1091295192956547072> Discord.js Version", - value: `\`v${version}\``, - inline: true - }, - { - name: "<:node:1091294141641674852> Node.js Version", - value: `\`${process.version}\``, - inline: true - }, - { - name: "<:github:1091295909972803616> Bot Version", - value: `\`v${botver}\``, - inline: true - }, - { - name: "<:computer:879379500322922507> ARCH", - value: `\`${os.arch()}\``, - inline: true - }, - { - name: "<:computer:879379500322922507> Platform", - value: `\`${os.platform()}\``, - inline: true - }, - { - name: "<:memory:1091301379928236074> Memory", - value: `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} mb\``, - inline: true - }, - { - name: "<:cpu:1091295423915892737> CPU", - value: `\`\`\`md\n${os.cpus().map((i) => `${i.model}`)[0]}\`\`\``, - inline: true - } - ) - await interaction.reply({ embeds: [embed] }) - } -} \ No newline at end of file + data: new SlashCommandBuilder() + .setName('info') + .setDescription('Displays detailed information about the bot'), + category: 'util', + async execute(interaction) { + const client = interaction.client; + const embed = new EmbedBuilder() + .setThumbnail(client.user.displayAvatarURL()) + .setTitle('Bot Information') + .setColor('#7200FF') + .addFields( + { + name: '<:author:1091296385388773437> Author', + value: `${client.users.cache.get(ownerId)?.tag}`, + inline: true, + }, + { + name: '<:discord:1091295194818818098> Servers', + value: `Joined ${client.guilds.cache.size} servers`, + inline: true, + }, + { + name: '<:channels:1091302046201810984> Channels', + value: `Watching ${client.channels.cache.size} channels`, + inline: true, + }, + { + name: '<:user:1091295188762243114> Users', + value: `Serving ${client.guilds.cache.reduce((a, b) => a + b.memberCount, 0)} users`, + inline: true, + }, + { + name: '<:join:1091295564483792926> Join Date', + value: client.user.createdAt.toLocaleDateString('en-us'), + inline: true, + }, + { + name: '<:djs:1091295192956547072> Discord.js Version', + value: `\`v${version}\``, + inline: true, + }, + { + name: '<:node:1091294141641674852> Node.js Version', + value: `\`${process.version}\``, + inline: true, + }, + { + name: '<:github:1091295909972803616> Bot Version', + value: `\`v${botver}\``, + inline: true, + }, + { + name: '<:computer:879379500322922507> ARCH', + value: `\`${os.arch()}\``, + inline: true, + }, + { + name: '<:computer:879379500322922507> Platform', + value: `\`${os.platform()}\``, + inline: true, + }, + { + name: '<:memory:1091301379928236074> Memory', + value: `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} mb\``, + inline: true, + }, + { + name: '<:cpu:1091295423915892737> CPU', + value: `\`\`\`md\n${os.cpus().map((i) => `${i.model}`)[0]}\`\`\``, + inline: true, + }, + ); + await interaction.reply({ embeds: [embed] }); + }, +}; \ No newline at end of file diff --git a/commands/util/poke.js b/commands/util/poke.js index a7c20b3..48b1e08 100644 --- a/commands/util/poke.js +++ b/commands/util/poke.js @@ -1,52 +1,52 @@ -const { SlashCommandBuilder } = require("@discordjs/builders") -const { EmbedBuilder } = require("discord.js") +const { SlashCommandBuilder } = require('@discordjs/builders'); +const { EmbedBuilder } = require('discord.js'); module.exports = { - data: new SlashCommandBuilder() - .setName("poke") - .setDescription("Sends a poke to another user") - .addUserOption(option => - option - .setName("target") - .setDescription("The user you want to poke") - .setRequired(true)) - .setDMPermission(false) - .addStringOption(option => - option - .setName("message") - .setDescription("The message you want to send") - .setRequired(false) - .setMaxLength(1024) - ), - category: 'util', - async execute (interaction) { - const target = interaction.options.getUser("target") - const message = interaction.options.getString("message") || " " - const serverName = interaction.guild.name - const senderName = interaction.user.username + data: new SlashCommandBuilder() + .setName('poke') + .setDescription('Sends a poke to another user') + .addUserOption(option => + option + .setName('target') + .setDescription('The user you want to poke') + .setRequired(true)) + .setDMPermission(false) + .addStringOption(option => + option + .setName('message') + .setDescription('The message you want to send') + .setRequired(false) + .setMaxLength(1024), + ), + category: 'util', + async execute(interaction) { + const target = interaction.options.getUser('target'); + const message = interaction.options.getString('message') || ' '; + const serverName = interaction.guild.name; + const senderName = interaction.user.username; - // Check if the target user is the bot itself - if (target.id === interaction.client.user.id) { - const errorMessage = "Sorry, you cannot poke me!" - const errorEmbed = new EmbedBuilder() - .setColor("#FF0000") - .setTitle("Error") - .setDescription(errorMessage) - await interaction.reply({ embeds: [errorEmbed], ephemeral: true }) - return - } + // Check if the target user is the bot itself + if (target.id === interaction.client.user.id) { + const errorMessage = 'Sorry, you cannot poke me!'; + const errorEmbed = new EmbedBuilder() + .setColor('#FF0000') + .setTitle('Error') + .setDescription(errorMessage); + await interaction.reply({ embeds: [errorEmbed], ephemeral: true }); + return; + } - // Send a DM to the target user - target.send( - `You've been poked by **${senderName}** from **${serverName}**!\nMessage: ${message}` - ) + // Send a DM to the target user + target.send( + `You've been poked by **${senderName}** from **${serverName}**!\nMessage: ${message}`, + ); - // Send confirmation to the user who initiated the command - const embed = new EmbedBuilder() - .setColor("#00FF0C") - .setTitle("Poke Sent") - .setDescription(`Successfully sent a poke to **${target.username}**.`) - .addFields({ name: "Message", value: message || " " }) - await interaction.reply({ embeds: [embed], ephemeral: true }) - } -} + // Send confirmation to the user who initiated the command + const embed = new EmbedBuilder() + .setColor('#00FF0C') + .setTitle('Poke Sent') + .setDescription(`Successfully sent a poke to **${target.username}**.`) + .addFields({ name: 'Message', value: message || ' ' }); + await interaction.reply({ embeds: [embed], ephemeral: true }); + }, +}; diff --git a/events/deployCommands.js b/events/deployCommands.js index a6916ff..e47444f 100644 --- a/events/deployCommands.js +++ b/events/deployCommands.js @@ -44,4 +44,4 @@ async function deployCommands() { } } -module.exports = deployCommands; +module.exports = deployCommands; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 096e256..a694af8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "DiCoBo", - "version": "2.0.2", + "version": "2.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "DiCoBo", - "version": "2.0.2", + "version": "2.0.3", "license": "MIT", "dependencies": { "@ballaual/discord-temp-voice": "^1.0.3", diff --git a/package.json b/package.json index db344ce..724427d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "DiCoBo", - "version": "2.0.2", + "version": "2.0.3", "description": "a discordbot written in discord.js v14 using (/) commands", "main": "index.js", "scripts": { diff --git a/version.json b/version.json index 683da16..70e9170 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "version": "2.0.2", + "version": "2.0.3", "note": "DO NOT EDIT this file, unless you know what you are doing here!" } \ No newline at end of file