diff --git a/.env.example b/.env.example index 685b3ec..6f35367 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,5 @@ # Bot TOKEN=REPLACE_HERE -PREFIX=# EMBED_COLOR=#000001 SEARCH_ENGINE=youtube LEAVE_EMPTY=120000 diff --git a/README.md b/README.md index 32decd8..524368b 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ ## 📑 Feature - [x] Music Systems +- [x] Slash Commands (Base, Group, Sub) +- [x] AutoComplete (Play, Playskip, Playtop) - [x] Custom Filters - [x] Easy to use @@ -64,7 +66,6 @@ Copy or Rename `.env.example` to `.env` and fill out the values: ```.env # Bot TOKEN=REPLACE_HERE -PREFIX=! EMBED_COLOR=#000001 SEARCH_ENGINE=youtube LEAVE_EMPTY=120000 @@ -88,70 +89,70 @@ After installation or finishes all you can use `node .` to start the bot. or `Ru ## 🔩 Features & Commands -> Note: The default prefix is '#' +> Note: The default prefix is '/' 🎶 **Music Commands!** -- Play (#play, #p, #pplay [song/url]) -- Nowplaying (#nowplaying, #np, #now) -- Queue (#queue ) -- Repeat (#loop (current, all), #repeat (current, all)) -- Loopqueue (#loopall, #lq, repeatall) -- Shuffle (#shuffle, mix) -- Volume control (#vol, #v [10 - 100]) -- Pause (#pause, #pa) -- Resume (#resume, #r) -- Skip (#skip, #s) -- Skipto (#skipto, #st [position]) -- Clear (#clear) -- Join (#join, #summon) -- Leave (#leave, #dc, #lev, #stop) -- Forward (#forward ) -- Seek (#seek ) -- Rewind (#rewind ) -- Replay (#replay) -- Search (#search [songname]) -- 247 (#247) -- Previous (#previous) -- Autoplay (#autoplay) -- Move (#move [song] [position]) -- Remove (#remove [song]) -- PlaySkip (#playskip [song/url]) -- SearchSkip (#searchskip [songname]) -- PlayTop (#playtop [song/url]) -- SearchTop (#searchtop [songname]) +- Play (/play [song/url]) +- Nowplaying (/nowplaying) +- Queue (/queue [page]) +- Repeat (/loop [current, all]) +- Loopqueue (/loopqueue) +- Shuffle (/shuffle) +- Volume control (/volume [1 - 100]) +- Pause (/pause) +- Resume (/resume) +- Skip (/skip) +- Skipto (/skipto [position]) +- Clear (/clear) +- Join (/join ) +- Leave (/leave) +- Forward (/forward [seconds]) +- Seek (/seek [seconds]) +- Rewind (/rewind [seconds]) +- Replay (/replay) +- Search (/search [songname]) +- 247 (/247) +- Previous (/previous) +- Autoplay (/autoplay) +- Move (/move [song] [position]) +- Remove (/remove [song]) +- PlaySkip (/playskip [song/url]) +- SearchSkip (/searchskip [songname]) +- PlayTop (/playtop [song/url]) +- SearchTop (/searchtop [songname]) ⏺ **Filter Commands!** -- Bass (#bass) -- Superbass (#superbass, #sb) -- Pop (#pop) -- Treblebass (#treblebass, #tb) -- Soft (#soft) -- Earrape (#earrape, #ear) -- Equalizer (#eq ) -- Speed (#speed ) -- Picth (#pitch ) -- Vaporwave (#vaporwave) -- Nightcore (#nightcore) -- Bassboost (#bassboost, #bb [-10 - 10]) -- Rate (#rate) -- Reset (#reset) -- 3d (#3d) -- China (#china) -- Dance (#dance) -- Chipmunk (#chipmunk) -- Darthvader (#darthvader) -- DoubleTime (#doubletime) -- SlowMotion (#slowmotion) -- Tremolo (#tremolo) -- Vibrate (#vibrate) -- Vibrato (#vibrato) -- Daycore (#daycore) -- Television (#Television) -- Jazz (#jazz) +- Bass (/bass) +- Superbass (/superbass) +- Pop (/pop) +- Treblebass (/treblebass) +- Soft (/soft) +- Earrape (/earrape) +- Equalizer (/equalizer [custom]) +- Speed (/speed [0 - 10]) +- Picth (/pitch [0 - 10]) +- Vaporwave (/vaporwave) +- Nightcore (/nightcore) +- Bassboost (/bassboost [-10 - 10]) +- Rate (/rate) +- Reset (/reset) +- 3d (/3d) +- China (/china) +- Dance (/dance) +- Chipmunk (/chipmunk) +- Darthvader (/darthvader) +- DoubleTime (/doubletime) +- SlowMotion (/slowmotion) +- Tremolo (/tremolo) +- Vibrate (/vibrate) +- Vibrato (/vibrato) +- Daycore (/daycore) +- Television (/Television) +- Jazz (/jazz) 📑 **Misc Commands!** -- Help (#help, #halp [command]) +- Help (/help)

diff --git a/commands/Filter/3d.js b/commands/Filter/3d.js new file mode 100644 index 0000000..9080789 --- /dev/null +++ b/commands/Filter/3d.js @@ -0,0 +1,34 @@ +const { EmbedBuilder } = require("discord.js"); + +module.exports = { + name: ["filter", "3d"], + description: "Turning on 3d filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply("Loading please wait..."); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: "filters", + guildId: interaction.guild.id, + rotation: { rotationHz: 0.2 } + }; + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription("`💠` | *Turned on:* `3d`") + .setColor(client.color); + + await delay(5000); + return interaction.editReply({ content: " ", embeds: [embed] }); + } +} + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filters/Bass.js b/commands/Filter/Bass.js similarity index 59% rename from commands/Filters/Bass.js rename to commands/Filter/Bass.js index 58f00c7..d48dddd 100644 --- a/commands/Filters/Bass.js +++ b/commands/Filter/Bass.js @@ -1,23 +1,20 @@ const { EmbedBuilder } = require("discord.js"); module.exports = { - config: { - name: "bass", - description: "Turn on bass filter", - category: "Filters", - accessableby: "Member" - }, - run: async (client, message, args) => { - const msg = await message.reply("Loading please wait..."); + name: ["filter", "bass"], + description: "Turning on bass filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply("Loading please wait..."); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0.10 }, { band: 1, gain: 0.10 }, @@ -43,7 +40,7 @@ module.exports = { .setColor(client.color); await delay(5000); - return msg.edit({ content: " ", embeds: [embed] }); + return interaction.editReply({ content: " ", embeds: [embed] }); } } diff --git a/commands/Filters/BassBoost.js b/commands/Filter/BassBoost.js similarity index 51% rename from commands/Filters/BassBoost.js rename to commands/Filter/BassBoost.js index 6b429ff..da39cea 100644 --- a/commands/Filters/BassBoost.js +++ b/commands/Filter/BassBoost.js @@ -1,26 +1,32 @@ -const { EmbedBuilder } = require("discord.js"); +const { EmbedBuilder, ApplicationCommandOptionType } = require("discord.js"); module.exports = { - config: { - name: "bassboost", - description: "Turn on bass filter", - category: "Filters", - usage: "", - accessableby: "Member", - aliases: ["bb"] - }, - run: async (client, message, args) => { - const msg = await message.reply("Loading please wait..."); + name: ["filter", "bassboost"], + description: 'Turning on bassboost filter', + category: "Filter", + options: [ + { + name: 'amount', + description: 'The amount of the bassboost', + type: ApplicationCommandOptionType.Integer, + required: false, + min_value: -10, + max_value: 10 + } + ], + run: async (client, interaction) => { + await interaction.reply("Loading please wait..."); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); - if(!args[0]) { + const value = interaction.options.getInteger('amount'); + if(!value) { const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0.10 }, { band: 1, gain: 0.10 }, @@ -46,22 +52,19 @@ module.exports = { .setColor(client.color); await delay(5000); - return msg.edit({ content: " ", embeds: [embed] }); + return interaction.editReply({ content: " ", embeds: [embed] }); } else { - if(isNaN(args[0])) return msg.edit(`Please enter a number!`); - if(args[0] > 10 || args[0] < -10) return msg.edit(`Please enter a number between -10 - 10!`); - const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ - { band: 0, gain: args[0] / 10 }, - { band: 1, gain: args[0] / 10 }, - { band: 2, gain: args[0] / 10 }, - { band: 3, gain: args[0] / 10 }, - { band: 4, gain: args[0] / 10 }, - { band: 5, gain: args[0] / 10 }, - { band: 6, gain: args[0] / 10 }, + { band: 0, gain: value / 10 }, + { band: 1, gain: value / 10 }, + { band: 2, gain: value / 10 }, + { band: 3, gain: value / 10 }, + { band: 4, gain: value / 10 }, + { band: 5, gain: value / 10 }, + { band: 6, gain: value / 10 }, { band: 7, gain: 0 }, { band: 8, gain: 0 }, { band: 9, gain: 0 }, @@ -75,11 +78,11 @@ module.exports = { await player.send(data); const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Bassboost\` | *Gain:* \`${args[0]}\``) + .setDescription(`\`💠\` | *Turned on:* \`Bassboost\` | *Gain:* \`${value}\``) .setColor(client.color); await delay(5000); - return msg.edit({ content: " ", embeds: [embed] }); + return interaction.editReply({ content: " ", embeds: [embed] }); } } } diff --git a/commands/Filter/China.js b/commands/Filter/China.js new file mode 100644 index 0000000..5c7cc25 --- /dev/null +++ b/commands/Filter/China.js @@ -0,0 +1,38 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "china"], + description: "Turning on china filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { + speed: 0.75, + pitch: 1.25, + rate: 1.25 + } + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription("`💠` | *Turned on:* `China`") + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/Chipmunk.js b/commands/Filter/Chipmunk.js new file mode 100644 index 0000000..bb0ea8d --- /dev/null +++ b/commands/Filter/Chipmunk.js @@ -0,0 +1,38 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "chipmunk"], + description: "Turning on chipmunk filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { + speed: 1.05, + pitch: 1.35, + rate: 1.25 + }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Chipmunk\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/Dance.js b/commands/Filter/Dance.js new file mode 100644 index 0000000..bc8591d --- /dev/null +++ b/commands/Filter/Dance.js @@ -0,0 +1,38 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "dance"], + description: "Turning on dance filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { + speed: 1.25, + pitch: 1.25, + rate: 1.25 + }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Dance\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/Darthvader.js b/commands/Filter/Darthvader.js new file mode 100644 index 0000000..53ac9fe --- /dev/null +++ b/commands/Filter/Darthvader.js @@ -0,0 +1,38 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "darthvader"], + description: "Turning on darthvader filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { + speed: 0.975, + pitch: 0.5, + rate: 0.8 + }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Darth Vader\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filters/Daycore.js b/commands/Filter/Daycore.js similarity index 61% rename from commands/Filters/Daycore.js rename to commands/Filter/Daycore.js index 8411e0f..dab77af 100644 --- a/commands/Filters/Daycore.js +++ b/commands/Filter/Daycore.js @@ -1,23 +1,20 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "daycore", - description: "Turning on daycore filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); + name: ["filter", "daycore"], + description: "Turning on daycore filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0 }, { band: 1, gain: 0 }, @@ -47,7 +44,7 @@ module.exports = { .setColor(client.color); await delay(5000); - msg.edit({ content: " ", embeds: [daycored] }); + interaction.editReply({ content: " ", embeds: [daycored] }); } }; diff --git a/commands/Filter/DoubleTime.js b/commands/Filter/DoubleTime.js new file mode 100644 index 0000000..ccec9db --- /dev/null +++ b/commands/Filter/DoubleTime.js @@ -0,0 +1,36 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "doubletime"], + description: "Turning on doubletime filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { + speed: 1.165, + }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`DoubleTime\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/Earrape.js b/commands/Filter/Earrape.js new file mode 100644 index 0000000..80fdc66 --- /dev/null +++ b/commands/Filter/Earrape.js @@ -0,0 +1,33 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "earrape"], + description: "Turning on earrape filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + await player.setVolume(500); + const data = { + op: 'filters', + guildId: interaction.guild.id, + } + await player.send(data); + + const earrapped = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Earrape\``) + .setColor(client.color); + + await delay(3000); + interaction.editReply({ content: " ", embeds: [earrapped] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/Equalizer.js b/commands/Filter/Equalizer.js new file mode 100644 index 0000000..45f3aae --- /dev/null +++ b/commands/Filter/Equalizer.js @@ -0,0 +1,75 @@ +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); + +module.exports = { + name: ["equalizer"], + description: 'Custom Equalizer!', + category: "Filter", + options: [ + { + name: 'bands', + description: 'Number of bands to use (max 14 bands.)', + type: ApplicationCommandOptionType.String, + required: false, + } + ], + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); + + const value = interaction.options.getString('bands'); + + if (!value) { + const embed = new EmbedBuilder() + .setAuthor({ name: `Custom Equalizer`, iconURL: client.user.displayAvatarURL() }) + .setColor(client.color) + .setDescription(`There are 14 bands that can be set from -10 to 10. Not all bands have to be filled out.`) + .addFields({ name: `Example:`, value: `${client.prefix}eq 2 3 0 8 0 5 0 -5 0 0`, inline: false }) + .setFooter({ text: `Reset equalizer type: ${client.prefix}eq reset` }) + + return interaction.reply({ embeds: [embed] }); + + } else if (value == 'off' || value == 'reset') { + const data = { + op: 'filters', + guildId: interaction.guild.id, + } + return await player.send(data); + } + + const bands = args.join(' ').split(/[ ]+/); + let bandsStr = ''; + for (let i = 0; i < bands.length; i++) { + if (i > 13) break; + if (isNaN(bands[i])) return interaction.reply(`Band #${i + 1} is not a valid number.`); + if (bands[i] > 10) return interaction.reply(`Band #${i + 1} must be less than 10.`); + } + + for (let i = 0; i < bands.length; i++) { + if (i > 13) break; + const data = { + op: 'filters', + guildId: interaction.guild.id, + equalizer: [ + { band: i, gain: (bands[i]) / 10 }, + ] + } + await player.send(data); + bandsStr += `${bands[i]} `; + } + + await interaction.reply(`Setting **Equalizer** to... \`${bandsStr}\` This may take a few seconds...`); + + const embed = new EmbedBuilder() + .setDescription(`\`🔩\` | *Equalizer set to:* \`${bandsStr}\``) + .setColor(client.color); + + await delay(5000); + return interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filters/Jazz.js b/commands/Filter/Jazz.js similarity index 59% rename from commands/Filters/Jazz.js rename to commands/Filter/Jazz.js index 457f1dc..07ea663 100644 --- a/commands/Filters/Jazz.js +++ b/commands/Filter/Jazz.js @@ -1,23 +1,20 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "jazz", - description: "Turning on jazz filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); + name: ["filter", "jazz"], + description: "Turning on jazz filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0 }, { band: 1, gain: 0 }, @@ -43,7 +40,7 @@ module.exports = { .setColor(client.color); await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); + interaction.editReply({ content: " ", embeds: [embed] }); } }; diff --git a/commands/Filter/Nightcore.js b/commands/Filter/Nightcore.js new file mode 100644 index 0000000..ca3b0ed --- /dev/null +++ b/commands/Filter/Nightcore.js @@ -0,0 +1,38 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "nightcore"], + description: "Turning on nightcore filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { + speed: 1.165, + pitch: 1.125, + rate: 1.05 + }, + } + + await player.send(data); + + const nightcored = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Nightcore\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [nightcored] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/Pitch.js b/commands/Filter/Pitch.js new file mode 100644 index 0000000..32caab5 --- /dev/null +++ b/commands/Filter/Pitch.js @@ -0,0 +1,46 @@ +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); + +module.exports = { + name: ["filter", "pitch"], + description: 'Sets the pitch of the song.', + category: "Filter", + options: [ + { + name: 'amount', + description: 'The amount of pitch to change the song by.', + type: ApplicationCommandOptionType.Integer, + required: true, + min_value: 0, + max_value: 10 + } + ], + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const value = interaction.options.getInteger('amount'); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { pitch: value }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Pitch set to:* \`${value}\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filters/Pop.js b/commands/Filter/Pop.js similarity index 59% rename from commands/Filters/Pop.js rename to commands/Filter/Pop.js index 9204f0e..4433680 100644 --- a/commands/Filters/Pop.js +++ b/commands/Filter/Pop.js @@ -1,23 +1,20 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "pop", - description: "Turning on pop filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); + name: ["filter", "pop"], + description: "Turning on pop filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0.65 }, { band: 1, gain: 0.45 }, @@ -43,7 +40,7 @@ module.exports = { .setColor(client.color); await delay(5000); - msg.edit({ content: " ", embeds: [popped] }); + interaction.editReply({ content: " ", embeds: [popped] }); } }; diff --git a/commands/Filter/Rate.js b/commands/Filter/Rate.js new file mode 100644 index 0000000..3066d35 --- /dev/null +++ b/commands/Filter/Rate.js @@ -0,0 +1,45 @@ +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); + +module.exports = { + name: ["filter", "rate"], + description: "Sets the rate of the song.", + category: "Filter", + options: [ + { + name: "amount", + description: "The amount of rate to set.", + type: ApplicationCommandOptionType.Integer, + required: true, + min_value: 0, + max_value: 10 + } + ], + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const value = interaction.options.getInteger('amount'); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { rate: value }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Rate set to:* \`${value}\``) + .setColor(client.color); + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/Reset.js b/commands/Filter/Reset.js new file mode 100644 index 0000000..44e1e66 --- /dev/null +++ b/commands/Filter/Reset.js @@ -0,0 +1,34 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["reset"], + description: "Reset filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + } + + await player.send(data); + await player.setVolume(100); + + const resetted = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Reset\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [resetted] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/SlowMotion.js b/commands/Filter/SlowMotion.js new file mode 100644 index 0000000..e72c248 --- /dev/null +++ b/commands/Filter/SlowMotion.js @@ -0,0 +1,38 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "slowmotion"], + description: "Turning on slowmotion filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { + speed: 0.5, + pitch: 1.0, + rate: 0.8 + } + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Slow Motion\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filters/Soft.js b/commands/Filter/Soft.js similarity index 59% rename from commands/Filters/Soft.js rename to commands/Filter/Soft.js index f7b475b..152a7a5 100644 --- a/commands/Filters/Soft.js +++ b/commands/Filter/Soft.js @@ -1,23 +1,20 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "soft", - description: "Turning on soft filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); + name: ["filter", "soft"], + description: "Turning on soft filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0 }, { band: 1, gain: 0 }, @@ -43,7 +40,7 @@ module.exports = { .setColor(client.color); await delay(5000); - msg.edit({ content: " ", embeds: [softed] }); + interaction.editReply({ content: " ", embeds: [softed] }); } }; diff --git a/commands/Filter/Speed.js b/commands/Filter/Speed.js new file mode 100644 index 0000000..8ce14c6 --- /dev/null +++ b/commands/Filter/Speed.js @@ -0,0 +1,46 @@ +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); + +module.exports = { + name: ["filter", "speed"], + description: "Sets the speed of the song.", + category: "Filter", + options: [ + { + name: "amount", + description: "The amount of speed to set the song to.", + type: ApplicationCommandOptionType.Integer, + required: true, + min_value: 0, + max_value: 10 + } + ], + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const value = interaction.options.getInteger('amount'); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + timescale: { speed: value }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Speed set to:* \`${value}\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filters/SuperBass.js b/commands/Filter/SuperBass.js similarity index 58% rename from commands/Filters/SuperBass.js rename to commands/Filter/SuperBass.js index 0bba532..0331454 100644 --- a/commands/Filters/SuperBass.js +++ b/commands/Filter/SuperBass.js @@ -1,24 +1,20 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "superbass", - description: "Turning on superbass filter", - category: "Filters", - accessableby: "Member", - aliases: ["sb"] - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); + name: ["filter", "superbass"], + description: "Turning on superbass filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0.2 }, { band: 1, gain: 0.3 }, @@ -44,7 +40,7 @@ module.exports = { .setColor(client.color); await delay(5000); - msg.edit({ content: " ", embeds: [sbed] }); + interaction.editReply({ content: " ", embeds: [sbed] }); } }; diff --git a/commands/Filters/Television.js b/commands/Filter/Television.js similarity index 59% rename from commands/Filters/Television.js rename to commands/Filter/Television.js index c4ca1ad..f7c6605 100644 --- a/commands/Filters/Television.js +++ b/commands/Filter/Television.js @@ -1,23 +1,20 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "television", - description: "Turning on television filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); + name: ["filter", "television"], + description: "Turning on television filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0 }, { band: 1, gain: 0 }, @@ -43,7 +40,7 @@ module.exports = { .setColor(client.color); await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); + interaction.editReply({ content: " ", embeds: [embed] }); } }; diff --git a/commands/Filters/TrebleBass.js b/commands/Filter/TrebleBass.js similarity index 58% rename from commands/Filters/TrebleBass.js rename to commands/Filter/TrebleBass.js index d536d2e..7a1f7e2 100644 --- a/commands/Filters/TrebleBass.js +++ b/commands/Filter/TrebleBass.js @@ -1,24 +1,20 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "treblebass", - description: "Turning on treblebass filter", - category: "Filters", - accessableby: "Member", - aliases: ["tb"] - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); + name: ["filter", "treblebass"], + description: "Turning on treblebass filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0.6 }, { band: 1, gain: 0.67 }, @@ -44,7 +40,7 @@ module.exports = { .setColor(client.color); await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); + interaction.editReply({ content: " ", embeds: [embed] }); } }; diff --git a/commands/Filter/Tremolo.js b/commands/Filter/Tremolo.js new file mode 100644 index 0000000..a9bf9d7 --- /dev/null +++ b/commands/Filter/Tremolo.js @@ -0,0 +1,37 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "tremolo"], + description: "Turning on tremolo filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + tremolo: { + frequency: 4.0, + depth: 0.75 + }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Tremolo\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filters/Vaporwave.js b/commands/Filter/Vaporwave.js similarity index 60% rename from commands/Filters/Vaporwave.js rename to commands/Filter/Vaporwave.js index 0499453..31d6807 100644 --- a/commands/Filters/Vaporwave.js +++ b/commands/Filter/Vaporwave.js @@ -1,23 +1,20 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "vaporwave", - description: "Turning on vaporwave filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); + name: ["filter", "vaporwave"], + description: "Turning on vaporwave filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); const data = { op: 'filters', - guildId: message.guild.id, + guildId: interaction.guild.id, equalizer: [ { band: 0, gain: 0 }, { band: 1, gain: 0 }, @@ -46,7 +43,7 @@ module.exports = { .setColor(client.color); await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); + interaction.editReply({ content: " ", embeds: [embed] }); } }; diff --git a/commands/Filter/Vibrate.js b/commands/Filter/Vibrate.js new file mode 100644 index 0000000..e3166d1 --- /dev/null +++ b/commands/Filter/Vibrate.js @@ -0,0 +1,41 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "vibrate"], + description: "Turning on vibrate filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + vibrato: { + frequency: 4.0, + depth: 0.75 + }, + tremolo: { + frequency: 4.0, + depth: 0.75 + }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Vibrato\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filter/Vibrato.js b/commands/Filter/Vibrato.js new file mode 100644 index 0000000..5126f5d --- /dev/null +++ b/commands/Filter/Vibrato.js @@ -0,0 +1,37 @@ +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: ["filter", "vibrato"], + description: "Turning on vibrato filter", + category: "Filter", + run: async (client, interaction) => { + await interaction.reply(`Loading please wait....`); + + const player = client.manager.players.get(interaction.guild.id); + if(!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const data = { + op: 'filters', + guildId: interaction.guild.id, + vibrato: { + frequency: 4.0, + depth: 0.75 + }, + } + + await player.send(data); + + const embed = new EmbedBuilder() + .setDescription(`\`💠\` | *Turned on:* \`Vibrato\``) + .setColor(client.color); + + await delay(5000); + interaction.editReply({ content: " ", embeds: [embed] }); + } +}; + +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} \ No newline at end of file diff --git a/commands/Filters/3d.js b/commands/Filters/3d.js deleted file mode 100644 index 7eeddaa..0000000 --- a/commands/Filters/3d.js +++ /dev/null @@ -1,37 +0,0 @@ -const { EmbedBuilder } = require("discord.js"); - -module.exports = { - config: { - name: "3d", - description: "Turn on 3d filter", - category: "Filters", - accessableby: "Member" - }, - run: async (client, message, args) => { - const msg = await message.reply("Loading please wait..."); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: "filters", - guildId: message.guild.id, - rotation: { rotationHz: 0.2 } - }; - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription("`💠` | *Turned on:* `3d`") - .setColor(client.color); - - await delay(5000); - return msg.edit({ content: " ", embeds: [embed] }); - } -} - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/China.js b/commands/Filters/China.js deleted file mode 100644 index f1ff96b..0000000 --- a/commands/Filters/China.js +++ /dev/null @@ -1,41 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "china", - description: "Turning on china filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { - speed: 0.75, - pitch: 1.25, - rate: 1.25 - } - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription("`💠` | *Turned on:* `China`") - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Chipmunk.js b/commands/Filters/Chipmunk.js deleted file mode 100644 index 68aee59..0000000 --- a/commands/Filters/Chipmunk.js +++ /dev/null @@ -1,41 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "chipmunk", - description: "Turning on chipmunk filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { - speed: 1.05, - pitch: 1.35, - rate: 1.25 - }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Chipmunk\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Dance.js b/commands/Filters/Dance.js deleted file mode 100644 index 9844461..0000000 --- a/commands/Filters/Dance.js +++ /dev/null @@ -1,41 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "dance", - description: "Turning on dance filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { - speed: 1.25, - pitch: 1.25, - rate: 1.25 - }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Dance\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Darthvader.js b/commands/Filters/Darthvader.js deleted file mode 100644 index 2f8e037..0000000 --- a/commands/Filters/Darthvader.js +++ /dev/null @@ -1,41 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "darthvader", - description: "Turning on darthvader filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { - speed: 0.975, - pitch: 0.5, - rate: 0.8 - }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Darth Vader\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/DoubleTime.js b/commands/Filters/DoubleTime.js deleted file mode 100644 index e9b8ff8..0000000 --- a/commands/Filters/DoubleTime.js +++ /dev/null @@ -1,39 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "doubletime", - description: "Turning on doubletime filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { - speed: 1.165, - }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`DoubleTime\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Earrape.js b/commands/Filters/Earrape.js deleted file mode 100644 index d2b0723..0000000 --- a/commands/Filters/Earrape.js +++ /dev/null @@ -1,37 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "earrape", - description: "Destroy your ear!", - category: "Filters", - accessableby: "Member", - aliases: ["ear"] - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - await player.setVolume(500); - const data = { - op: 'filters', - guildId: message.guild.id, - } - await player.send(data); - - const earrapped = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Earrape\``) - .setColor(client.color); - - await delay(3000); - msg.edit({ content: " ", embeds: [earrapped] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Equalizer.js b/commands/Filters/Equalizer.js deleted file mode 100644 index 7a8c77d..0000000 --- a/commands/Filters/Equalizer.js +++ /dev/null @@ -1,68 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "equalizer", - description: "Sets the equalizer of the current playing song.", - category: "Filters", - accessableby: "Member", - usage: "<2 3 0 8 0 5 0 -5 0 0>", - aliases: ["eq"] - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if(!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); - - if (!args[0]) { - const embed = new EmbedBuilder() - .setAuthor({ name: `Custom Equalizer`, iconURL: client.user.displayAvatarURL() }) - .setColor(client.color) - .setDescription(`There are 14 bands that can be set from -10 to 10. Not all bands have to be filled out.`) - .addFields({ name: `Example:`, value: `${client.prefix}eq 2 3 0 8 0 5 0 -5 0 0`, inline: false }) - .setFooter({ text: `Reset equalizer type: ${client.prefix}eq reset` }) - return message.reply({ embeds: [embed] }); - } else if (args[0] == 'off' || args[0] == 'reset') { - const data = { - op: 'filters', - guildId: message.guild.id, - } - return await player.send(data); - } - - const bands = args.join(' ').split(/[ ]+/); - let bandsStr = ''; - for (let i = 0; i < bands.length; i++) { - if (i > 13) break; - if (isNaN(bands[i])) return message.reply(`Band #${i + 1} is not a valid number.`); - if (bands[i] > 10) return message.reply(`Band #${i + 1} must be less than 10.`); - } - - for (let i = 0; i < bands.length; i++) { - if (i > 13) break; - const data = { - op: 'filters', - guildId: message.guild.id, - equalizer: [ - { band: i, gain: (bands[i]) / 10 }, - ] - } - await player.send(data); - bandsStr += `${bands[i]} `; - } - - const msg = await message.reply(`Setting **Equalizer** to... \`${bandsStr}\` This may take a few seconds...`); - - const embed = new EmbedBuilder() - .setDescription(`\`🔩\` | *Equalizer set to:* \`${bandsStr}\``) - .setColor(client.color); - - await delay(5000); - return msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Nightcore.js b/commands/Filters/Nightcore.js deleted file mode 100644 index 616bfa1..0000000 --- a/commands/Filters/Nightcore.js +++ /dev/null @@ -1,41 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "nightcore", - description: "Turning on nightcore filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { - speed: 1.165, - pitch: 1.125, - rate: 1.05 - }, - } - - await player.send(data); - - const nightcored = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Nightcore\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [nightcored] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Pitch.js b/commands/Filters/Pitch.js deleted file mode 100644 index 96ed04b..0000000 --- a/commands/Filters/Pitch.js +++ /dev/null @@ -1,41 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "pitch", - description: "Sets the pitch of the song.", - category: "Filters", - accessableby: "Member", - usage: '', - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - if (isNaN(args[0])) return msg.edit(`Please enter a number!`); - if(args[0] > 10 || args[0] < 0) return msg.edit(`Please enter a number between 0 - 10!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { pitch: args[0] }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Pitch set to:* \`${args[0]}\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Rate.js b/commands/Filters/Rate.js deleted file mode 100644 index 6659806..0000000 --- a/commands/Filters/Rate.js +++ /dev/null @@ -1,40 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "rate", - description: "Sets the rate of the song.", - category: "Filters", - accessableby: "Member", - usage: '', - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - if (isNaN(args[0])) return msg.edit(`Please enter a number!`); - if(args[0] > 10 || args[0] < 0) return msg.edit(`Please enter a number between 0 - 10!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { rate: args[0] }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Rate set to:* \`${args[0]}\``) - .setColor(client.color); - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Reset.js b/commands/Filters/Reset.js deleted file mode 100644 index c120440..0000000 --- a/commands/Filters/Reset.js +++ /dev/null @@ -1,37 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "reset", - description: "reseting all filters", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - } - - await player.send(data); - await player.setVolume(100); - - const resetted = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Reset\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [resetted] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/SlowMotion.js b/commands/Filters/SlowMotion.js deleted file mode 100644 index b53dd9e..0000000 --- a/commands/Filters/SlowMotion.js +++ /dev/null @@ -1,41 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "slowmotion", - description: "Turning on slowmotion filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { - speed: 0.5, - pitch: 1.0, - rate: 0.8 - } - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Slow Motion\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Speed.js b/commands/Filters/Speed.js deleted file mode 100644 index 3e74a10..0000000 --- a/commands/Filters/Speed.js +++ /dev/null @@ -1,41 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "speed", - description: "Sets the speed of the song.", - category: "Filters", - accessableby: "Member", - usage: '', - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - if (isNaN(args[0])) return msg.edit(`Please enter a number!`); - if(args[0] > 10 || args[0] < 0) return msg.edit(`Please enter a number between 0 - 10!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - timescale: { speed: args[0] }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Speed set to:* \`${args[0]}\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Tremolo.js b/commands/Filters/Tremolo.js deleted file mode 100644 index 45b96fc..0000000 --- a/commands/Filters/Tremolo.js +++ /dev/null @@ -1,40 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "tremolo", - description: "Turning on tremolo filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - tremolo: { - frequency: 4.0, - depth: 0.75 - }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Tremolo\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Vibrate.js b/commands/Filters/Vibrate.js deleted file mode 100644 index b748cb2..0000000 --- a/commands/Filters/Vibrate.js +++ /dev/null @@ -1,44 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "vibrate", - description: "Turning on vibrate filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - vibrato: { - frequency: 4.0, - depth: 0.75 - }, - tremolo: { - frequency: 4.0, - depth: 0.75 - }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Vibrato\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Filters/Vibrato.js b/commands/Filters/Vibrato.js deleted file mode 100644 index 4997b10..0000000 --- a/commands/Filters/Vibrato.js +++ /dev/null @@ -1,40 +0,0 @@ -const { EmbedBuilder } = require('discord.js'); - -module.exports = { - config: { - name: "vibrato", - description: "Turning on vibrato filter", - category: "Filters", - accessableby: "Member", - }, - run: async (client, message, args) => { - const msg = await message.reply(`Loading please wait....`); - - const player = client.manager.players.get(message.guild.id); - if(!player) return msg.edit(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return msg.edit(`I'm not in the same voice channel as you!`); - - const data = { - op: 'filters', - guildId: message.guild.id, - vibrato: { - frequency: 4.0, - depth: 0.75 - }, - } - - await player.send(data); - - const embed = new EmbedBuilder() - .setDescription(`\`💠\` | *Turned on:* \`Vibrato\``) - .setColor(client.color); - - await delay(5000); - msg.edit({ content: " ", embeds: [embed] }); - } -}; - -function delay(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file diff --git a/commands/Misc/Help.js b/commands/Misc/Help.js index 2a09f18..d703d95 100644 --- a/commands/Misc/Help.js +++ b/commands/Misc/Help.js @@ -1,52 +1,29 @@ const { EmbedBuilder } = require("discord.js"); const { readdirSync } = require("fs"); -const { stripIndents } = require("common-tags"); module.exports = { - config: { - name: "help", - aliases: ["h", "halp", "commands"], - usage: "(command)", - category: "Misc", - description: "Displays all commands that the bot has.", - accessableby: "Members" - }, - run: async (client, message, args) => { + name: ["help"], + description: "Display all commands bot has.", + category: "Misc", + run: async (client, interaction) => { const embed = new EmbedBuilder() - .setColor('#000001') - .setAuthor({ name: `${message.guild.members.me.displayName} Help Command!`, iconURL: message.guild.iconURL({ dynamic: true })}) - .setThumbnail(client.user.displayAvatarURL({ dynamic: true, size: 2048 })); + .setColor(client.color) + .setAuthor({ name: `${interaction.guild.members.me.displayName} Help Command!`, iconURL: interaction.guild.iconURL({ dynamic: true })}) + .setThumbnail(client.user.displayAvatarURL({ dynamic: true, size: 2048 })) + .setDescription(`The bot prefix is: **/**`) + .setFooter({ text: `© ${interaction.guild.members.me.displayName} | Total Commands: ${client.commands.size}`, iconURL: client.user.displayAvatarURL({ dynamic: true })}) - if(!args[0]) { - const categories = readdirSync("./commands/") + const categories = readdirSync("./commands/"); + categories.forEach(category => { + const dir = client.commands.filter(c => c.category === category); + const capitalise = category.slice(0, 1).toUpperCase() + category.slice(1); - embed.setDescription(`The bot prefix is: **${client.prefix}**`) - embed.setFooter({ text: `© ${message.guild.members.me.displayName} | Total Commands: ${client.commands.size}`, iconURL: client.user.displayAvatarURL({ dynamic: true })}); - - categories.forEach(category => { - const dir = client.commands.filter(c => c.config.category === category) - const capitalise = category.slice(0, 1).toUpperCase() + category.slice(1) - try { - embed.addFields({ name: `❯ ${capitalise} [${dir.size}]:`, value: dir.map(c => `\`${c.config.name}\``).join(" "), inline: false }) - } catch(e) { - console.log(e) - } - }); - - return message.channel.send({ embeds: [embed] }) - } else { - let command = client.commands.get(client.aliases.get(args[0].toLowerCase()) || args[0].toLowerCase()) - if(!command) return message.channel.send({ embeds: [embed.setTitle("Invalid Command.").setDescription(`Do \`${client.prefix}help\` for the list of the commands.`)] }) - command = command.config - - embed.setDescription(stripIndents`The client's prefix is: \`${client.prefix}\`\n - **Command:** ${command.name.slice(0, 1).toUpperCase() + command.name.slice(1)} - **Description:** ${command.description || "No Description provided."} - **Usage:** ${command.usage ? `\`${client.prefix}${command.name} ${command.usage}\`` : "No Usage"} - **Accessible by:** ${command.accessableby || "Members"} - **Aliases:** ${command.aliases ? command.aliases.join(", ") : "None."}`) - - return message.channel.send({ embeds: [embed] }) - } + try { + embed.addFields({ name: `❯ ${capitalise} [${dir.size}]:`, value: `${dir.map(c => `\`${c.name.at(-1)}\``).join(", ")}`, inline: false }) + } catch(e) { + console.log(e) + } + }) + return interaction.reply({ embeds: [embed] }) } } \ No newline at end of file diff --git a/commands/Music/AutoPlay.js b/commands/Music/AutoPlay.js index 90f9fbf..be8772d 100644 --- a/commands/Music/AutoPlay.js +++ b/commands/Music/AutoPlay.js @@ -1,17 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "autoplay", - description: "Auto play music in voice channel.", - accessableby: "Member", - category: "Music" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "autoplay"], + description: "Autoplay music (Random play songs)", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); if (player.data.get("autoplay")) { // get undifined = turn on + set data await player.data.set("autoplay", false); @@ -21,15 +18,15 @@ module.exports = { .setDescription("`📻` | *Autoplay has been:* `Deactivated`") .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } else { const identifier = player.queue.current.identifier; const search = `https://www.youtube.com/watch?v=${identifier}&list=RD${identifier}`; - const res = await player.search(search, { requester: message.author }); - if (!res.tracks.length) return message.reply(`Engine \`${player.queue.current.sourceName}\` not support!`); + const res = await player.search(search, { requester: interaction.user }); + if (!res.tracks.length) return interaction.reply(`Engine \`${player.queue.current.sourceName}\` not support!`); await player.data.set("autoplay", true); - await player.data.set("requester", message.author); + await player.data.set("requester", interaction.user); await player.data.set("identifier", identifier); await player.queue.add(res.tracks[1]); @@ -37,7 +34,7 @@ module.exports = { .setDescription("`📻` | *Autoplay has been:* `Activated`") .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } }; \ No newline at end of file diff --git a/commands/Music/Clear.js b/commands/Music/Clear.js index 2998af8..329d654 100644 --- a/commands/Music/Clear.js +++ b/commands/Music/Clear.js @@ -1,17 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "clear", - description: "Clear song in queue!", - accessableby: "Member", - category: "Music", - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "clear"], + description: "Clear song in queue!", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); await player.queue.clear(); @@ -19,6 +16,6 @@ module.exports = { .setDescription("`📛` | *Queue has been:* `Cleared`") .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Forward.js b/commands/Music/Forward.js index 10255dd..75ffe52 100644 --- a/commands/Music/Forward.js +++ b/commands/Music/Forward.js @@ -1,42 +1,49 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); const formatDuration = require('../../structures/FormatDuration.js') const fastForwardNum = 10; module.exports = { - config: { - name: "forward", - description: "Forward timestamp in the song!", - accessableby: "Member", - category: "Music", - usage: "" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "forward"], + description: "forward the currently playing song.", + category: "Music", + options: [ + { + name: "seconds", + description: "How many seconds to forward?", + type: ApplicationCommandOptionType.Integer, + required: false, + min_value: 1 + } + ], + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); + + const value = interaction.options.getInteger("seconds"); const song = player.queue.current; const CurrentDuration = formatDuration(player.position); - if (args[0] && !isNaN(args[0])) { - if((player.position + args[0] * 1000) < song.length) { - await player.seek(player.position + args[0] * 1000); + if (value && !isNaN(value)) { + if((player.position + value * 1000) < song.length) { + await player.seek(player.position + value * 1000); const embed = new EmbedBuilder() .setDescription(`\`⏭\` | *Forward to:* \`${CurrentDuration}\``) .setColor(client.color); - message.reply({ content: " ", embeds: [embed] }); + interaction.reply({ content: " ", embeds: [embed] }); } else { - return message.reply(`You can't forward more than the duration of the song!`); + return interaction.reply(`You can't forward more than the duration of the song!`); } - } else if (args[0] && isNaN(args[0])) { - return message.reply(`Please enter a number!`); + } else if (value && isNaN(value)) { + return interaction.reply(`Please enter a number!`); } - if (!args[0]) { + if (!value) { if((player.position + fastForwardNum * 1000) < song.length) { await player.seek(player.position + fastForwardNum * 1000); @@ -44,9 +51,9 @@ module.exports = { .setDescription(`\`⏭\` | *Forward to:* \`${CurrentDuration}\``) .setColor(client.color); - message.reply({ content: " ", embeds: [embed] }); + interaction.reply({ content: " ", embeds: [embed] }); } else { - return message.reply(`You can't forward more than the duration of the song!`); + return interaction.reply(`You can't forward more than the duration of the song!`); } } } diff --git a/commands/Music/Join.js b/commands/Music/Join.js index a5c1356..67de284 100644 --- a/commands/Music/Join.js +++ b/commands/Music/Join.js @@ -1,22 +1,18 @@ const { EmbedBuilder, PermissionsBitField } = require('discord.js'); module.exports = { - config: { - name: "join", - aliases: ["summon"], - description: "Make the bot join the voice channel.", - accessableby: "Member", - category: "Music", - }, - run: async (client, message, args) => { - const { channel } = message.member.voice; - if (!channel) return message.reply(`You are not in a voice channel`); - if (!channel.permissionsFor(message.guild.members.me).has(PermissionsBitField.Flags.Connect)) return message.reply(`I don't have permission to join your voice channel!`); - if (!channel.permissionsFor(message.guild.members.me).has(PermissionsBitField.Flags.Speak)) return message.reply(`I don't have permission to speak in your voice channel!`); + name: ["music", "join"], + description: "Summon the bot to your voice channel.", + category: "Music", + run: async (client, interaction) => { + const { channel } = interaction.member.voice; + if (!channel) return interaction.reply(`You are not in a voice channel`); + if (!channel.permissionsFor(interaction.guild.members.me).has(PermissionsBitField.Flags.Connect)) return interaction.reply(`I don't have permission to join your voice channel!`); + if (!channel.permissionsFor(interaction.guild.members.me).has(PermissionsBitField.Flags.Speak)) return interaction.reply(`I don't have permission to speak in your voice channel!`); client.manager.createPlayer({ - guildId: message.guild.id, - textId: message.channel.id, + guildId: interaction.guild.id, + textId: interaction.channel.id, voiceId: channel.id, volume: 100, deaf: true @@ -26,6 +22,6 @@ module.exports = { .setDescription(`\`🔊\` | *Joined:* \`${channel.name}\``) .setColor(client.color) - return message.reply({ embeds: [embed] }) + return interaction.reply({ embeds: [embed] }) } } diff --git a/commands/Music/Leave.js b/commands/Music/Leave.js index ebcfbd8..f3c9204 100644 --- a/commands/Music/Leave.js +++ b/commands/Music/Leave.js @@ -1,18 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "leave", - aliases: ["lev", "stop", "dc"], - description: "Makes the bot leave the voice channel.", - accessableby: "Member", - category: "Music", - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "leave"], + description: "Disconnect the bot from your voice channel", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); await player.destroy(); @@ -20,6 +16,6 @@ module.exports = { .setDescription(`\`🚫\` | *Left:* | \`${channel.name}\``) .setColor(client.color); - return message.reply({ embeds: [embed] }) + return interaction.reply({ embeds: [embed] }) } } diff --git a/commands/Music/Loop.js b/commands/Music/Loop.js index f5541e0..bc4a71e 100644 --- a/commands/Music/Loop.js +++ b/commands/Music/Loop.js @@ -1,21 +1,36 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); module.exports = { - config: { - name: "loop", - aliases: ["repeat"], - description: "Loop song in queue!", - accessableby: "Member", - category: "Music", - usage: "" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); - - if (!args[0] || args[0].toLowerCase() == 'current') { + name: ["music", "loop"], + description: "Loops the current song!", + category: "Music", + options: [ + { + name: "mode", + description: "What mode do you want to loop?", + type: ApplicationCommandOptionType.String, + required: true, + choices: [ + { + name: "Current 🔂", + value: "current" + }, + { + name: "Queue 🔁", + value: "queue" + } + ] + } + ], + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); + + const choice = interaction.options.getString("mode"); + + if (choice == 'current') { if (player.loop === "none") { player.setLoop("track"); @@ -23,7 +38,7 @@ module.exports = { .setDescription(`\`🔁\` | *Song has been:* \`Looped\``) .setColor(client.color); - message.reply({ embeds: [embed] }); + interaction.reply({ embeds: [embed] }); } else { player.setLoop("none") @@ -31,25 +46,25 @@ module.exports = { .setDescription(`\`🔁\` | *Song has been:* \`Unlooped\``) .setColor(client.color); - message.reply({ embeds: [embed] }); + interaction.reply({ embeds: [embed] }); } - } else if (args[0] == 'all') { + } else if (choice == 'queue') { if (player.loop === "queue") { player.setLoop("none") - const embed = new EmbedBuilder() //// this is unloop all in queue! + const embed = new EmbedBuilder() .setDescription(`\`🔁\` | *Loop all has been:* \`Disabled\``) .setColor(client.color); - message.reply({ embeds: [embed] }); + interaction.reply({ embeds: [embed] }); } else { player.setLoop("queue") - const embed = new EmbedBuilder() // this is loop all in queue! + const embed = new EmbedBuilder() .setDescription(`\`🔁\` | *Loop all has been:* \`Enabled\``) .setColor(client.color); - message.reply({ embeds: [embed] }); + interaction.reply({ embeds: [embed] }); } } } diff --git a/commands/Music/LoopQueue.js b/commands/Music/LoopQueue.js index f2712da..826e369 100644 --- a/commands/Music/LoopQueue.js +++ b/commands/Music/LoopQueue.js @@ -1,18 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "loopqueue", - aliases: ["repeatall", 'lq', 'loopall'], - description: "Loop all songs in queue!", - accessableby: "Member", - category: "Music" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "loopqueue"], + description: "Loops all songs in queue!", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); if (player.loop === "queue") { player.setLoop("none") @@ -21,7 +17,7 @@ module.exports = { .setDescription(`\`🔁\` | *Loop all has been:* \`Disabled\``) .setColor(client.color); - message.reply({ embeds: [embed] }); + interaction.reply({ embeds: [embed] }); } else { player.setLoop("queue") @@ -29,7 +25,7 @@ module.exports = { .setDescription(`\`🔁\` | *Loop all has been:* \`Enabled\``) .setColor(client.color); - message.reply({ embeds: [embed] }); + interaction.reply({ embeds: [embed] }); } } }; \ No newline at end of file diff --git a/commands/Music/Lyrics.js b/commands/Music/Lyrics.js index 52d8d1b..8549e42 100644 --- a/commands/Music/Lyrics.js +++ b/commands/Music/Lyrics.js @@ -1,20 +1,25 @@ const lyricsfinder = require('lyrics-finder'); -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); module.exports = { - config: { - name: "lyrics", - description: "Display lyrics of a song", - accessableby: "Member", - category: "Music", - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "lyric"], + description: "Display lyrics of a song.", + category: "Music", + options: [ + { + name: "result", + description: "Song name to return lyrics for.", + type: ApplicationCommandOptionType.String, + required: false, + } + ], + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); - let song = args.join(" "); + const song = interaction.options.getString("result"); let CurrentSong = player.queue.current; if (!song && CurrentSong) song = CurrentSong.title; @@ -22,10 +27,10 @@ module.exports = { try { lyrics = await lyricsfinder(song, ""); - if (!lyrics) return message.reply(`No lyrics found for ${song}`); + if (!lyrics) return interaction.reply(`No lyrics found for ${song}`); } catch (err) { console.log(err); - return message.reply(`No lyrics found for ${song}`); + return interaction.reply(`No lyrics found for ${song}`); } let lyricsEmbed = new EmbedBuilder() .setColor(client.color) @@ -37,6 +42,6 @@ module.exports = { if (lyrics.length > 2048) { lyricsEmbed.setDescription(`Lyrics are too long to display!`); } - message.reply({ content: ' ', embeds: [lyricsEmbed] }); + interaction.reply({ content: ' ', embeds: [lyricsEmbed] }); } }; \ No newline at end of file diff --git a/commands/Music/Move.js b/commands/Music/Move.js index 450cad1..78fba8c 100644 --- a/commands/Music/Move.js +++ b/commands/Music/Move.js @@ -1,27 +1,36 @@ -const { EmbedBuilder } = require("discord.js"); +const { EmbedBuilder, ApplicationCommandOptionType } = require("discord.js"); module.exports = { - config: { - name: "move", - description: "Move position song in queue!", - usage: "<3 1>", - category: "Music", - accessableby: "Member" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); - - const tracks = args[0]; - const position = args[1]; - - if (isNaN(tracks) || isNaN(position)) return message.reply(`Please enter a valid number in the queue! ${client.prefix}move `); - - if (tracks == 0 && position == 0) return message.reply(`Cannot remove a song that is already playing`); - if (tracks > player.queue.length || (tracks && !player.queue[tracks - 1])) return message.reply(`Song not found.`); - if ((position > player.queue.length) || !player.queue[position - 1]) return message.reply(`Song not found.`); + name: ["music", "move"], + description: "Change a songs position in a queue.", + category: "Music", + options: [ + { + name: "from", + description: "The queue number of the song", + type: ApplicationCommandOptionType.Integer, + required: true, + min_value: 1 + }, + { + name: "to", + description: "The position in queue you want to move", + type: ApplicationCommandOptionType.Integer, + required: true, + min_value: 1 + } + ], + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); + + const tracks = interaction.options.getInteger("from"); + const position = interaction.options.getInteger("to"); + + if (tracks > player.queue.length || (tracks && !player.queue[tracks - 1])) return interaction.reply(`Song not found.`); + if ((position > player.queue.length) || !player.queue[position - 1]) return interaction.reply(`Song not found.`); const song = player.queue[tracks - 1]; @@ -32,6 +41,6 @@ module.exports = { .setColor(client.color) .setDescription(`**Moved • [${song.title}](${song.uri})** to ${position}`) - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/NowPlaying.js b/commands/Music/NowPlaying.js index b334fbc..21c7601 100644 --- a/commands/Music/NowPlaying.js +++ b/commands/Music/NowPlaying.js @@ -3,24 +3,17 @@ const { convertQueue } = require("../../structures/ConvertTime.js"); const { EmbedBuilder } = require("discord.js"); module.exports = { - config: { - name: "nowplaying", - aliases: ["np", "now"], - description: "Display the song currently playing.", - accessableby: "Member", - category: "Music", - }, - - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); + name: ["nowplaying"], + description: "Display the song currently playing.", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); const song = player.queue.current; const CurrentDuration = formatDuration(player.position); const TotalDuration = formatDuration(song.length); - console.log(song.sourceName) - const Part = Math.floor(player.position / song.length * 30); const Emoji = player.playing ? "🔴 |" : "⏸ |"; @@ -43,6 +36,6 @@ module.exports = { embed.setThumbnail(client.user.displayAvatarURL()); } - return message.reply({ content: " ", embeds: [embed] }); + return interaction.reply({ content: " ", embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Pause.js b/commands/Music/Pause.js index 514f1a3..4e8e853 100644 --- a/commands/Music/Pause.js +++ b/commands/Music/Pause.js @@ -1,18 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "pause", - aliases: ["pa"], - description: "Pause song in queue!", - accessableby: "Member", - category: "Music", - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "pause"], + description: "Pause the music!", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); await player.pause(player.playing); const uni = player.paused ? `Paused` : `Resumed`; @@ -21,6 +17,6 @@ module.exports = { .setDescription(`\`⏯\` | *Song has been:* \`${uni}\``) .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Play.js b/commands/Music/Play.js index 5af41fe..7128662 100644 --- a/commands/Music/Play.js +++ b/commands/Music/Play.js @@ -1,53 +1,65 @@ const { convertTime } = require("../../structures/ConvertTime.js"); -const { EmbedBuilder, PermissionsBitField } = require("discord.js"); +const { EmbedBuilder, PermissionsBitField, ApplicationCommandOptionType } = require("discord.js"); module.exports = { - config: { - name: "play", - description: "Play a song!", - usage: "", - category: "Music", - accessableby: "Member", - aliases: ["p", "pplay"] - }, - run: async (client, message, args) => { - if(!args[0]) return message.reply("Please provide song name."); - const { channel } = message.member.voice; - if (!channel) return message.reply(`You are not in a voice channel`); - if (!channel.permissionsFor(message.guild.members.me).has(PermissionsBitField.Flags.Connect)) return message.reply(`I don't have permission to join your voice channel!`); - if (!channel.permissionsFor(message.guild.members.me).has(PermissionsBitField.Flags.Speak)) return message.reply(`I don't have permission to speak in your voice channel!`); - - const player = await client.manager.createPlayer({ - guildId: message.guild.id, - textId: message.channel.id, - voiceId: channel.id, - volume: 100, - deaf: true - }); - - let res = await player.search(args, { requester: message.author }); - if (!res.tracks.length) return message.reply("No results found!"); - - if (res.type === "PLAYLIST") { - for (let track of res.tracks) player.queue.add(track); - - if (!player.playing && !player.paused) player.play(); - - const embed = new EmbedBuilder() - .setColor(client.color) - .setDescription(`**Queued • [${res.playlistName}](${args})** \`${convertTime(res.tracks[0].length + player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) - - return message.reply({ embeds: [embed] }) - } else { - player.queue.add(res.tracks[0]); - - if (!player.playing && !player.paused) player.play(); + name: ["play"], + description: "Plays a song from the source.", + category: "Music", + options: [ + { + name: "search", + type: ApplicationCommandOptionType.String, + description: "The song to play.", + required: true, + autocomplete: true + } + ], + run: async (client, interaction) => { + try { + if (interaction.options.getString("search")) { + const { channel } = interaction.member.voice; + if (!channel) return interaction.reply(`You are not in a voice channel`); + if (!channel.permissionsFor(interaction.guild.members.me).has(PermissionsBitField.Flags.Connect)) return interaction.reply(`I don't have permission to join your voice channel!`); + if (!channel.permissionsFor(interaction.guild.members.me).has(PermissionsBitField.Flags.Speak)) return interaction.reply(`I don't have permission to speak in your voice channel!`); + + await interaction.reply(`🔍 **Searching...** \`${interaction.options.getString("search")}\``); - const embed = new EmbedBuilder() - .setColor(client.color) - .setDescription(`**Queued • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) + const player = await client.manager.createPlayer({ + guildId: interaction.guild.id, + textId: interaction.channel.id, + voiceId: channel.id, + volume: 100, + deaf: true + }); + const string = interaction.options.getString("search"); - return message.reply({ embeds: [embed] }) + const res = await player.search(string, { requester: interaction.user }); + if (!res.tracks.length) return interaction.editReply("No results found!"); + + if (res.type === "PLAYLIST") { + for (let track of res.tracks) player.queue.add(track); + + if (!player.playing && !player.paused) player.play(); + + const embed = new EmbedBuilder() + .setColor(client.color) + .setDescription(`**Queued • [${res.playlistName}](${string})** \`${convertTime(res.tracks[0].length + player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) + + return interaction.editReply({ content: " ", embeds: [embed] }) + } else { + player.queue.add(res.tracks[0]); + + if (!player.playing && !player.paused) player.play(); + + const embed = new EmbedBuilder() + .setColor(client.color) + .setDescription(`**Queued • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) + + return interaction.editReply({ content: " ", embeds: [embed] }) + } + } + } catch { + /// } } } \ No newline at end of file diff --git a/commands/Music/PlaySkip.js b/commands/Music/PlaySkip.js index 0ea01ef..50b5ca3 100644 --- a/commands/Music/PlaySkip.js +++ b/commands/Music/PlaySkip.js @@ -1,46 +1,57 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); const { convertTime } = require("../../structures/ConvertTime.js"); const { KazagumoTrack } = require("kazagumo"); module.exports = { - config: { - name: "playskip", - description: "Play and skip to the song!", - usage: "", - category: "Music", - accessableby: "Member", - aliases: ["pskip", "skipplay"] - }, - run: async (client, message, args) => { - if(!args[0]) return message.reply("Please provide song name."); - - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); - - const res = await player.search(args, { requester: message.author }); - if (!res.tracks.length) return message.reply("No results found!"); - - if (res.type === "PLAYLIST") { - const queues = player.queue.size; - for (let track of res.tracks) player.queue.add(track); - - Playlist(player, queues); - - const embed = new EmbedBuilder() - .setColor(client.color) - .setDescription(`**Skipped • [${res.playlistName}](${args})** \`${convertTime(player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) - - return message.reply({ embeds: [embed] }) - } else { - player.play(new KazagumoTrack(res.tracks[0].getRaw(), message.author)); - - const embed = new EmbedBuilder() - .setColor(client.color) - .setDescription(`**Skipped • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) + name: ["music", "playskip"], + description: "Play and skip to a song!", + category: "Music", + options: [ + { + name: "search", + type: ApplicationCommandOptionType.String, + description: "The song to play.", + required: true, + autocomplete: true + } + ], + run: async (client, interaction) => { + try { + if (interaction.options.getString("search")) { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); + + await interaction.reply(`🔍 **Searching...** \`${interaction.options.getString("search")}\``); - return message.reply({ embeds: [embed] }) + const string = interaction.options.getString("search"); + const res = await player.search(string, { requester: interaction.user }); + if (!res.tracks.length) return interaction.editReply("No results found!"); + + if (res.type === "PLAYLIST") { + const queues = player.queue.size; + for (let track of res.tracks) player.queue.add(track); + + Playlist(player, queues); + + const embed = new EmbedBuilder() + .setColor(client.color) + .setDescription(`**Skipped • [${res.playlistName}](${string})** \`${convertTime(player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) + + return interaction.editReply({ content: " ", embeds: [embed] }) + } else { + player.play(new KazagumoTrack(res.tracks[0].getRaw(), interaction.user)); + + const embed = new EmbedBuilder() + .setColor(client.color) + .setDescription(`**Skipped • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) + + return interaction.editReply({ content: " ", embeds: [embed] }) + } + } + } catch { + // } } } diff --git a/commands/Music/PlayTop.js b/commands/Music/PlayTop.js index 17f3748..7804ae0 100644 --- a/commands/Music/PlayTop.js +++ b/commands/Music/PlayTop.js @@ -1,48 +1,58 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); const { convertTime } = require("../../structures/ConvertTime.js"); module.exports = { - config: { - name: "playtop", - description: "Queue song to the top!", - usage: "", - category: "Music", - accessableby: "Member", - aliases: ["tplay", "topplay"] - }, - run: async (client, message, args) => { - if(!args[0]) return message.reply("Please provide song name."); - - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); - - const res = await player.search(args, { requester: message.author }); - if (!res.tracks.length) return message.reply("No results found!"); - - if (res.type === "PLAYLIST") { - const queues = player.queue.size; - for (let track of res.tracks) player.queue.add(track); - - // your have another tick? pls contributor - Playlist(player, queues); - - const embed = new EmbedBuilder() - .setColor(client.color) - .setDescription(`**Shifted • [${res.playlistName}](${args})** \`${convertTime(player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) - - return message.reply({ embeds: [embed] }) - } else { - player.queue.add(res.tracks[0]); - - Normal(player); - - const embed = new EmbedBuilder() - .setColor(client.color) - .setDescription(`**Shifted • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) + name: ["music", "playtop"], + description: "Queue song to the top!", + category: "Music", + options: [ + { + name: "search", + type: ApplicationCommandOptionType.String, + description: "The song to play.", + required: true, + autocomplete: true + } + ], + run: async (client, interaction) => { + try { + if (interaction.options.getString("search")) { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); + + await interaction.reply(`🔍 **Searching...** \`${interaction.options.getString("search")}\``); - return message.reply({ embeds: [embed] }) + const string = interaction.options.getString("search"); + const res = await player.search(string, { requester: interaction.user }); + if (!res.tracks.length) return interaction.editReply("No results found!"); + + if (res.type === "PLAYLIST") { + const queues = player.queue.size; + for (let track of res.tracks) player.queue.add(track); + + Playlist(player, queues); + + const embed = new EmbedBuilder() + .setColor(client.color) + .setDescription(`**Shifted • [${res.playlistName}](${string})** \`${convertTime(player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) + + return interaction.editReply({ content: " ", embeds: [embed] }) + } else { + player.queue.add(res.tracks[0]); + + Normal(player); + + const embed = new EmbedBuilder() + .setColor(client.color) + .setDescription(`**Shifted • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) + + return interaction.editReply({ content: " ", embeds: [embed] }) + } + } + } catch { + // } } } diff --git a/commands/Music/Previous.js b/commands/Music/Previous.js index 438d49e..cdfe042 100644 --- a/commands/Music/Previous.js +++ b/commands/Music/Previous.js @@ -2,26 +2,23 @@ const { EmbedBuilder } = require('discord.js'); const { KazagumoTrack } = require('kazagumo'); module.exports = { - config: { - name: "previous", - description: "Previous a song!", - accessableby: "Member", - category: "Music" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "previous"], + description: "Play the previous song in the queue.", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); - if (!player.queue.previous) return message.reply(`No previous song/s not found`); + if (!player.queue.previous) return interaction.reply(`No previous song/s not found`); - await player.play(new KazagumoTrack(player.queue.previous.getRaw(), message.author)); + await player.play(new KazagumoTrack(player.queue.previous.getRaw(), interaction.user)); const embed = new EmbedBuilder() .setDescription("`⏮` | *Song has been:* `Previous`") .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Queue.js b/commands/Music/Queue.js index 6b03ee8..c3e140c 100644 --- a/commands/Music/Queue.js +++ b/commands/Music/Queue.js @@ -1,20 +1,28 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); const { NormalPage } = require('../../structures/PageQueue.js'); const formatDuration = require('../../structures/FormatDuration.js'); module.exports = { - config: { - name: "queue", - aliases: ["q"], - description: "Displays what the current queue is.", - accessableby: "Member", - category: "Music", - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["queue"], + description: "Show the queue of songs.", + category: "Music", + options: [ + { + name: "page", + description: "Page number to show.", + type: ApplicationCommandOptionType.Integer, + required: false, + } + ], + run: async (client, interaction) => { + await interaction.deferReply({ ephemeral: false }); + + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const args = interaction.options.getInteger("page"); const song = player.queue.current; const qduration = formatDuration(player.queue.durationLength + song.length); @@ -35,7 +43,7 @@ module.exports = { const str = songStrings.slice(i * 10, i * 10 + 10).join(''); const embed = new EmbedBuilder() - .setAuthor({ name: `Queue - ${message.guild.name}`, iconURL: message.guild.iconURL({ dynamic: true }) }) + .setAuthor({ name: `Queue - ${interaction.guild.name}`, iconURL: interaction.guild.iconURL({ dynamic: true }) }) .setColor(client.color) //**Currently Playing:**\n**[${song.title}](${song.uri})** \`[${formatDuration(song.duration)}]\` • ${song.requester}\n\n**Rest of queue**:${str == '' ? ' Nothing' : '\n' + str} .setDescription(`**Currently Playing**\n[${song.title}](${song.uri}) \`[${formatDuration(song.length)}]\` • ${song.requester}\n\n**Rest of queue**:${str == '' ? ' Nothing' : '\n' + str}`) //Page • ${i + 1}/${pagesNum} | ${player.queue.length} • Song | ${qduration} • Total duration .setFooter({ text: `Page • ${i + 1}/${pagesNum} | ${player.queue.length} • Song/s | ${qduration} • Total Duration` }); @@ -49,14 +57,14 @@ module.exports = { pages.push(embed); } - if (!args[0]) { - if (pages.length == pagesNum && player.queue.length > 10) NormalPage(client, message, pages, 60000, player.queue.length, qduration); - else return message.reply({ embeds: [pages[0]] }); + if (!args) { + if (pages.length == pagesNum && player.queue.length > 10) NormalPage(client, interaction, pages, 60000, player.queue.length, qduration); + else return interaction.editReply({ embeds: [pages[0]] }); } else { - if (isNaN(args[0])) return message.reply(`Please enter a number!`); - if (args[0] > pagesNum) return message.reply(`There are only ${pagesNum} pages available!`); - const pageNum = args[0] == 0 ? 1 : args[0] - 1; - return message.reply({ embeds: [pages[pageNum]] }); + if (isNaN(args)) return interaction.editReply(`Please enter a number!`); + if (args > pagesNum) return interaction.editReply(`There are only ${pagesNum} pages available!`); + const pageNum = args == 0 ? 1 : args - 1; + return interaction.editReply({ embeds: [pages[pageNum]] }); } } }; \ No newline at end of file diff --git a/commands/Music/Remove.js b/commands/Music/Remove.js index 64f6e46..940c4ba 100644 --- a/commands/Music/Remove.js +++ b/commands/Music/Remove.js @@ -1,27 +1,27 @@ -const { EmbedBuilder } = require("discord.js"); +const { EmbedBuilder, ApplicationCommandOptionType } = require("discord.js"); const { convertTime } = require("../../structures/ConvertTime.js"); module.exports = { - config: { - name: "remove", - description: "Remove song from queue!", - usage: "", - category: "Music", - accessableby: "Member", - aliases: ["rt", "rs"], - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "remove"], + description: "Remove song from queue!", + category: "Music", + options: [ + { + name: "position", + description: "The position in queue want to remove.", + type: ApplicationCommandOptionType.Integer, + required: true, + min_value: 1 + } + ], + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); - const tracks = args[0]; - - if (isNaN(tracks)) return message.reply(`Please enter a valid number in the queue! ${client.prefix}remove `); - - if (tracks == 0) return message.reply(`Cannot remove a song that is already playing.`); - if (tracks > player.queue.size) return message.reply(`Song not found.`); + const tracks = interaction.options.getInteger("position"); + if (tracks > player.queue.size) return interaction.reply(`Song not found.`); const song = player.queue[tracks - 1]; await player.queue.splice(tracks - 1, 1); @@ -30,6 +30,6 @@ module.exports = { .setColor(client.color) .setDescription(`**Removed • [${song.title}](${song.uri})** \`${convertTime(song.length, true)}\` • ${song.requester}`) - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Replay.js b/commands/Music/Replay.js index 35b7807..a3f3483 100644 --- a/commands/Music/Replay.js +++ b/commands/Music/Replay.js @@ -1,17 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "replay", - description: "Replay current song!", - accessableby: "Member", - category: "Music" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "replay"], + description: "Replay the current song!", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); await player.seek(0); @@ -19,6 +16,6 @@ module.exports = { .setDescription("`⏮` | *Song has been:* `Replayed`") .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Resume.js b/commands/Music/Resume.js index d40bd53..90cd79e 100644 --- a/commands/Music/Resume.js +++ b/commands/Music/Resume.js @@ -1,18 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "resume", - aliases: ["r"], - description: "Makes the bot pause/resume the music currently playing.", - accessableby: "Member", - category: "Music", - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "resume"], + description: "Resume the music!", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); await player.pause(player.playing); const uni = player.paused ? `Paused` : `Resumed`; @@ -21,6 +17,6 @@ module.exports = { .setDescription(`\`⏯\` | *Song has been:* \`${uni}\``) .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Rewind.js b/commands/Music/Rewind.js index e3272b5..de1c28e 100644 --- a/commands/Music/Rewind.js +++ b/commands/Music/Rewind.js @@ -1,41 +1,47 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); const formatDuration = require('../../structures/FormatDuration.js') const rewindNum = 10; module.exports = { - config: { - name: "rewind", - description: "Rewind timestamp in the song!", - accessableby: "Member", - category: "Music", - usage: "" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "rewind"], + description: "Rewind timestamp in the song!", + category: "Music", + options: [ + { + name: "seconds", + description: "Rewind timestamp in the song!", + type: ApplicationCommandOptionType.Integer, + required: false, + min_value: 1 + } + ], + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); + const value = interaction.options.getInteger("seconds"); const CurrentDuration = formatDuration(player.position); - if(args[0] && !isNaN(args[0])) { - if((player.position - args[0] * 1000) > 0) { - await player.seek(player.position - args[0] * 1000); + if(value && !isNaN(value)) { + if((player.position - value * 1000) > 0) { + await player.seek(player.position - value * 1000); const embed = new EmbedBuilder() .setDescription(`\`⏮\` | *Rewind to:* \`${CurrentDuration}\``) .setColor(client.color); - message.reply({ embeds: [embed] }); + interaction.reply({ embeds: [embed] }); } else { - return message.reply(`You can't rewind more than the duration of the song!`); + return interaction.reply(`You can't rewind more than the duration of the song!`); } - } else if(args[0] && isNaN(args[0])) { - return message.reply(`Please enter a number!`); + } else if(value && isNaN(value)) { + return interaction.reply(`Please enter a number!`); } - if(!args[0]) { + if(!value) { if((player.position - rewindNum * 1000) > 0) { await player.seek(player.position - rewindNum * 1000); @@ -43,9 +49,9 @@ module.exports = { .setDescription(`\`⏮\` | *Rewind to:* \`${CurrentDuration}\``) .setColor(client.color); - message.reply({ embeds: [embed] }); + interaction.reply({ embeds: [embed] }); } else { - return message.reply(`You can't rewind more than the duration of the song!`); + return interaction.reply(`You can't rewind more than the duration of the song!`); } } } diff --git a/commands/Music/Search.js b/commands/Music/Search.js index 97d1c29..dda5aa9 100644 --- a/commands/Music/Search.js +++ b/commands/Music/Search.js @@ -1,24 +1,32 @@ const { convertTime } = require("../../structures/ConvertTime.js") -const { EmbedBuilder, PermissionsBitField, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); +const { EmbedBuilder, PermissionsBitField, ActionRowBuilder, ButtonBuilder, ButtonStyle, ApplicationCommandOptionType, ComponentType } = require("discord.js"); module.exports = { - config: { - name: "search", - description: "Search a song!", - usage: "", - category: "Music", - accessableby: "Member", - }, - run: async (client, message, args) => { - if(!args[0]) return message.reply("Please provide song name."); - const { channel } = message.member.voice; - if (!channel) return message.reply(`You are not in a voice channel`); - if (!channel.permissionsFor(message.guild.members.me).has(PermissionsBitField.Flags.Connect)) return message.reply(`I don't have permission to join your voice channel!`); - if (!channel.permissionsFor(message.guild.members.me).has(PermissionsBitField.Flags.Speak)) return message.reply(`I don't have permission to speak in your voice channel!`); + name: ["search"], + description: "Search for a song!", + category: "Music", + options: [ + { + name: "song", + description: "The input of the song", + type: ApplicationCommandOptionType.String, + required: true, + } + ], + run: async (client, interaction) => { + await interaction.deferReply({ ephemeral: false }); + + const args = interaction.options.getString("song"); + const { channel } = interaction.member.voice; + if (!channel) return interaction.editReply(`You are not in a voice channel`); + if (!channel.permissionsFor(interaction.guild.members.me).has(PermissionsBitField.Flags.Connect)) return interaction.editReply(`I don't have permission to join your voice channel!`); + if (!channel.permissionsFor(interaction.guild.members.me).has(PermissionsBitField.Flags.Speak)) return interaction.editReply(`I don't have permission to speak in your voice channel!`); + + const msg = await interaction.editReply(` Searching for \`${args}\`...`); const player = await client.manager.createPlayer({ - guildId: message.guild.id, - textId: message.channel.id, + guildId: interaction.guild.id, + textId: interaction.channel.id, voiceId: channel.id, volume: 100, deaf: true @@ -57,8 +65,8 @@ module.exports = { ) - let res = await player.search(args, { requester: message.author }); - if (!res.tracks.length) return message.reply("No results found!"); + let res = await player.search(args, { requester: interaction.user }); + if (!res.tracks.length) return interaction.editReply("No results found!"); if (res.type === "PLAYLIST") { for (let track of res.tracks) player.queue.add(track); @@ -69,22 +77,22 @@ module.exports = { .setColor(client.color) .setDescription(`**Queued • [${res.playlistName}](${args})** \`${convertTime(player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) - return message.reply({ embeds: [embed] }) + return interaction.editReply({ embeds: [embed] }) } else { let index = 1; const results = res.tracks.slice(0, 5).map(x => `**(${index++}.) [${x.title}](${x.uri})** \`${convertTime(x.length, true)}\` Author: ${x.author}`).join("\n") const embed = new EmbedBuilder() - .setAuthor({ name: `Song Selection...`, iconURL: message.guild.iconURL({ dynamic: true }) }) + .setAuthor({ name: `Song Selection...`, iconURL: interaction.guild.iconURL({ dynamic: true }) }) .setColor(client.color) .setDescription(results) .setFooter({ text: `Please Respone in 30s` }) - const msg = await message.reply({ embeds: [embed], components: [row] }); - const collector = msg.createMessageComponentCollector({ filter: (interaction) => interaction.user.id === message.author.id ? true : false && interaction.deferUpdate(), max: 1, time: 30000 }); + await msg.edit({ embeds: [embed], components: [row], content: " " }); + const collector = msg.createMessageComponentCollector({ filter: (interaction) => interaction.user.id === interaction.user.id, max: 1, time: 30000 }); collector.on('collect', async (interaction) => { - if(!interaction.deferred) await interaction.deferUpdate(); + // if(!interaction.deferred) await interaction.deferUpdate(); if(!player && !collector.ended) return collector.stop(); const id = interaction.customId; @@ -96,7 +104,7 @@ module.exports = { .setDescription(`**Queued • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "two") { player.queue.add(res.tracks[1]); if (!player.playing && !player.paused) player.play(); @@ -105,7 +113,7 @@ module.exports = { .setDescription(`**Queued • [${res.tracks[1].title}](${res.tracks[1].uri})** \`${convertTime(res.tracks[1].length, true)}\` • ${res.tracks[1].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "three") { player.queue.add(res.tracks[2]); if (!player.playing && !player.paused) player.play(); @@ -114,7 +122,7 @@ module.exports = { .setDescription(`**Queued • [${res.tracks[2].title}](${res.tracks[2].uri})** \`${convertTime(res.tracks[2].length, true)}\` • ${res.tracks[2].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "four") { player.queue.add(res.tracks[3]); if (!player.playing && !player.paused) player.play(); @@ -123,7 +131,7 @@ module.exports = { .setDescription(`**Queued • [${res.tracks[3].title}](${res.tracks[3].uri})** \`${convertTime(res.tracks[3].length, true)}\` • ${res.tracks[3].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "five") { player.queue.add(res.tracks[4]); if (!player.playing && !player.paused) player.play(); @@ -132,14 +140,14 @@ module.exports = { .setDescription(`**Queued • [${res.tracks[4].title}](${res.tracks[4].uri})** \`${convertTime(res.tracks[4].length, true)}\` • ${res.tracks[4].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } }); collector.on('end', async (collected, reason) => { if(reason === "time") { await msg.edit({ content: `No Interaction!`, embeds: [], components: [] }); - return player.destroy(); + if (!player.playing) player.destroy(); } }); } diff --git a/commands/Music/SearchSkip.js b/commands/Music/SearchSkip.js index d255aa4..c7c92ee 100644 --- a/commands/Music/SearchSkip.js +++ b/commands/Music/SearchSkip.js @@ -1,23 +1,30 @@ -const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); +const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ApplicationCommandOptionType } = require("discord.js"); const { convertTime } = require("../../structures/ConvertTime.js"); const { KazagumoTrack } = require("kazagumo"); module.exports = { - config: { - name: "searchskip", - description: "Search and skip to the song!", - usage: "", - category: "Music", - accessableby: "Member", - aliases: ["sskip", "skipsearch"] - }, - run: async (client, message, args) => { - if(!args[0]) return message.reply("Please provide song name."); - - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "searchskip"], + description: "Search and skip to a song!", + category: "Music", + options: [ + { + name: "song", + description: "The input of the song", + type: ApplicationCommandOptionType.String, + required: true, + } + ], + run: async (client, interaction) => { + await interaction.deferReply({ ephemeral: false }); + + const args = interaction.options.getString("song"); + + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const msg = await interaction.editReply(` Searching for \`${args}\`...`); const row = new ActionRowBuilder() .addComponents( @@ -51,8 +58,8 @@ module.exports = { .setStyle(ButtonStyle.Secondary) ) - const res = await player.search(args, { requester: message.author }); - if (!res.tracks.length) return message.reply("No results found!"); + const res = await player.search(args, { requester: interaction.user }); + if (!res.tracks.length) return interaction.editReply("No results found!"); if (res.type === "PLAYLIST") { const queues = player.queue.size; @@ -64,72 +71,72 @@ module.exports = { .setColor(client.color) .setDescription(`**Skipped • [${res.playlistName}](${args})** \`${convertTime(player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) - return message.reply({ embeds: [embed] }) + return interaction.editReply({ embeds: [embed] }) } else { let index = 1; const results = res.tracks.slice(0, 5).map(x => `**(${index++}.) [${x.title}](${x.uri})** \`${convertTime(x.length, true)}\` Author: ${x.author}`).join("\n") const embed = new EmbedBuilder() - .setAuthor({ name: `Song Selection...`, iconURL: message.guild.iconURL({ dynamic: true }) }) + .setAuthor({ name: `Song Selection...`, iconURL: interaction.guild.iconURL({ dynamic: true }) }) .setColor(client.color) .setDescription(results) .setFooter({ text: `Please Respone in 30s` }) - const msg = await message.reply({ embeds: [embed], components: [row] }); + await msg.edit({ embeds: [embed], components: [row], content: " " }); - const collector = msg.createMessageComponentCollector({ filter: (interaction) => interaction.user.id === message.author.id ? true : false && interaction.deferUpdate(), max: 1, time: 30000 }); + const collector = msg.createMessageComponentCollector({ filter: (interaction) => interaction.user.id === interaction.user.id, max: 1, time: 30000 }); collector.on('collect', async (interaction) => { - if(!interaction.deferred) await interaction.deferUpdate(); + // if(!interaction.deferred) await interaction.deferUpdate(); if(!player && !collector.ended) return collector.stop(); const id = interaction.customId; if(id === "one") { - player.play(new KazagumoTrack(res.tracks[0].getRaw(), message.author));; + player.play(new KazagumoTrack(res.tracks[0].getRaw(), interaction.author));; const embed = new EmbedBuilder() .setDescription(`**Skipped • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "two") { - player.play(new KazagumoTrack(res.tracks[1].getRaw(), message.author)); + player.play(new KazagumoTrack(res.tracks[1].getRaw(), interaction.author)); const embed = new EmbedBuilder() .setDescription(`**Skipped • [${res.tracks[1].title}](${res.tracks[1].uri})** \`${convertTime(res.tracks[1].length, true)}\` • ${res.tracks[1].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "three") { - player.play(new KazagumoTrack(res.tracks[2].getRaw(), message.author)); + player.play(new KazagumoTrack(res.tracks[2].getRaw(), interaction.author)); const embed = new EmbedBuilder() .setDescription(`**Skipped • [${res.tracks[2].title}](${res.tracks[2].uri})** \`${convertTime(res.tracks[2].length, true)}\` • ${res.tracks[2].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "four") { - player.play(new KazagumoTrack(res.tracks[3].getRaw(), message.author)); + player.play(new KazagumoTrack(res.tracks[3].getRaw(), interaction.author)); const embed = new EmbedBuilder() .setDescription(`**Skipped • [${res.tracks[3].title}](${res.tracks[3].uri})** \`${convertTime(res.tracks[3].length, true)}\` • ${res.tracks[3].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "five") { - player.play(new KazagumoTrack(res.tracks[4].getRaw(), message.author)); + player.play(new KazagumoTrack(res.tracks[4].getRaw(), interaction.author)); const embed = new EmbedBuilder() .setDescription(`**Skipped • [${res.tracks[4].title}](${res.tracks[4].uri})** \`${convertTime(res.tracks[4].length, true)}\` • ${res.tracks[4].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } }); collector.on('end', async (collected, reason) => { if(reason === "time") { await msg.edit({ content: `No Interaction!`, embeds: [], components: [] }); - return player.destroy(); + if (!player.playing) player.destroy(); } }); } diff --git a/commands/Music/SearchTop.js b/commands/Music/SearchTop.js index b655393..0f5e834 100644 --- a/commands/Music/SearchTop.js +++ b/commands/Music/SearchTop.js @@ -1,22 +1,29 @@ -const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); +const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ApplicationCommandOptionType } = require("discord.js"); const { convertTime } = require("../../structures/ConvertTime.js"); module.exports = { - config: { - name: "searchtop", - description: "Queue song to the top!", - usage: "", - category: "Music", - accessableby: "Member", - aliases: ["splay", "topsearch"] - }, - run: async (client, message, args) => { - if(!args[0]) return message.reply("Please provide song name."); - - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "searchtop"], + description: "Search and queue song to the top!", + category: "Music", + options: [ + { + name: "song", + description: "The input of the song", + type: ApplicationCommandOptionType.String, + required: true, + } + ], + run: async (client, interaction) => { + await interaction.deferReply({ ephemeral: false }); + + const args = interaction.options.getString("song"); + + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.editReply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.editReply(`I'm not in the same voice channel as you!`); + + const msg = await interaction.editReply(` Searching for \`${args}\`...`); const row = new ActionRowBuilder() .addComponents( @@ -50,8 +57,8 @@ module.exports = { .setStyle(ButtonStyle.Secondary) ) - const res = await player.search(args, { requester: message.author }); - if (!res.tracks.length) return message.reply("No results found!"); + const res = await player.search(args, { requester: interaction.user }); + if (!res.tracks.length) return interaction.editReply("No results found!"); if (res.type === "PLAYLIST") { const queues = player.queue.size; @@ -63,22 +70,22 @@ module.exports = { .setColor(client.color) .setDescription(`**Shifted • [${res.playlistName}](${args})** \`${convertTime(player.queue.durationLength, true)}\` (${res.tracks.length} tracks) • ${res.tracks[0].requester}`) - return message.reply({ embeds: [embed] }) + return interaction.editReply({ embeds: [embed] }) } else { let index = 1; const results = res.tracks.slice(0, 5).map(x => `**(${index++}.) [${x.title}](${x.uri})** \`${convertTime(x.length, true)}\` Author: ${x.author}`).join("\n") const embed = new EmbedBuilder() - .setAuthor({ name: `Song Selection...`, iconURL: message.guild.iconURL({ dynamic: true }) }) + .setAuthor({ name: `Song Selection...`, iconURL: interaction.guild.iconURL({ dynamic: true }) }) .setColor(client.color) .setDescription(results) .setFooter({ text: `Please Respone in 30s` }) - const msg = await message.reply({ embeds: [embed], components: [row] }); + await msg.edit({ embeds: [embed], components: [row], content: " " }); - const collector = msg.createMessageComponentCollector({ filter: (interaction) => interaction.user.id === message.author.id ? true : false && interaction.deferUpdate(), max: 1, time: 30000 }); + const collector = msg.createMessageComponentCollector({ filter: (interaction) => interaction.user.id === interaction.user.id, max: 1, time: 30000 }); collector.on('collect', async (interaction) => { - if(!interaction.deferred) await interaction.deferUpdate(); + // if(!interaction.deferred) await interaction.deferUpdate(); if(!player && !collector.ended) return collector.stop(); const id = interaction.customId; @@ -90,7 +97,7 @@ module.exports = { .setDescription(`**Shifted • [${res.tracks[0].title}](${res.tracks[0].uri})** \`${convertTime(res.tracks[0].length, true)}\` • ${res.tracks[0].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "two") { player.queue.add(res.tracks[1]); Normal(player); @@ -99,7 +106,7 @@ module.exports = { .setDescription(`**Shifted • [${res.tracks[1].title}](${res.tracks[1].uri})** \`${convertTime(res.tracks[1].length, true)}\` • ${res.tracks[1].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "three") { player.queue.add(res.tracks[2]); Normal(player); @@ -108,7 +115,7 @@ module.exports = { .setDescription(`**Shifted • [${res.tracks[2].title}](${res.tracks[2].uri})** \`${convertTime(res.tracks[2].length, true)}\` • ${res.tracks[2].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "four") { player.queue.add(res.tracks[3]); Normal(player); @@ -117,7 +124,7 @@ module.exports = { .setDescription(`**Shifted • [${res.tracks[3].title}](${res.tracks[3].uri})** \`${convertTime(res.tracks[3].length, true)}\` • ${res.tracks[3].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } else if(id === "five") { player.queue.add(res.tracks[4]); Normal(player); @@ -126,14 +133,14 @@ module.exports = { .setDescription(`**Shifted • [${res.tracks[4].title}](${res.tracks[4].uri})** \`${convertTime(res.tracks[4].length, true)}\` • ${res.tracks[4].requester}`) .setColor(client.color) - if(msg) await msg.edit({ embeds: [embed], components: [] }); + if(msg) msg.edit({ embeds: [embed], components: [], content: " " }); } }); collector.on('end', async (collected, reason) => { if(reason === "time") { await msg.edit({ content: `No Interaction!`, embeds: [], components: [] }); - return player.destroy(); + if (!player.playing) player.destroy(); } }); } diff --git a/commands/Music/Seek.js b/commands/Music/Seek.js index f023503..958ac79 100644 --- a/commands/Music/Seek.js +++ b/commands/Music/Seek.js @@ -1,31 +1,36 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); const formatDuration = require('../../structures/FormatDuration.js') module.exports = { - config: { - name: "seek", - description: "Seek timestamp in the song!", - accessableby: "Member", - category: "Music", - usage: "" - }, - run: async (client, message, args) => { - if(isNaN(args[0])) return message.reply(`Please enter a number!`); + name: ["music", "seek"], + description: "Seek timestamp in the song!", + category: "Music", + options: [ + { + name: "seconds", + description: "The number of seconds to seek the timestamp by.", + type: ApplicationCommandOptionType.Integer, + required: true, + min_value: 1 + } + ], + run: async (client, interaction) => { + const value = interaction.options.getInteger("seconds"); - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); - if(args[0] * 1000 >= player.queue.current.length || args[0] < 0) return message.reply(`You can't seek more than the duration of the song!`); + if(value * 1000 >= player.queue.current.length || value < 0) return interaction.reply(`You can't seek more than the duration of the song!`); - await player.seek(args[0] * 1000); + await player.seek(value * 1000); const Duration = formatDuration(player.position); const embed = new EmbedBuilder() .setDescription(`\`⏮\` | *Seek to:* \`${Duration}\``) .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Shuffle.js b/commands/Music/Shuffle.js index 7cecd29..3b1be5a 100644 --- a/commands/Music/Shuffle.js +++ b/commands/Music/Shuffle.js @@ -1,18 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "shuffle", - aliases: ["mix"], - description: "Shuffle song in queue!", - accessableby: "Member", - category: "Music" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "shuffle"], + description: "Shuffle song in queue!", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); await player.queue.shuffle(); @@ -20,6 +16,6 @@ module.exports = { .setDescription(`\`🔀\` | *Song has been:* \`Shuffle\``) .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Skip.js b/commands/Music/Skip.js index 77c0126..9b6633d 100644 --- a/commands/Music/Skip.js +++ b/commands/Music/Skip.js @@ -1,18 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "skip", - aliases: ["next", "s"], - description: "Skips the song currently playing.", - accessableby: "Member", - category: "Music" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["skip"], + description: "Skips the song currently playing.", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); await player.skip(); @@ -20,6 +16,6 @@ module.exports = { .setDescription(`\`⏭\` | *Song has been:* \`Skipped\``) .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/Skipto.js b/commands/Music/Skipto.js index 36be615..d0748f8 100644 --- a/commands/Music/Skipto.js +++ b/commands/Music/Skipto.js @@ -1,33 +1,36 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); module.exports = { - config: { - name: "skipto", - aliases: ["jump", "st"], - description: "Skips to a certain song in the queue.", - accessableby: "Member", - category: "Music", - usage: "" - }, - run: async (client, message, args) => { - if (isNaN(args[0])) return message.reply(`Please enter a valid position!`); - if (args[0] == 0) return message.reply(`You can't skip to the first song!`); + name: ["music", "skipto"], + description: "Skips to a certain song in the queue.", + category: "Music", + options: [ + { + name: "position", + description: "The position of the song in the queue.", + type: ApplicationCommandOptionType.Integer, + required: true, + min_value: 1, + } + ], + run: async (client, interaction) => { + const value = interaction.options.getInteger("position"); - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); - if ((args[0] > player.queue.size) || (args[0] && !player.queue[args[0] - 1])) return message.reply(`You can't skip to a song that doesn't exist!`); - if (args[0] == 1) player.skip(); + if ((value > player.queue.size) || (value && !player.queue[value - 1])) return interaction.reply(`You can't skip to a song that doesn't exist!`); + if (value == 1) player.skip(); - await player.queue.splice(0, args[0] - 1); + await player.queue.splice(0, value - 1); await player.skip(); const embed = new EmbedBuilder() - .setDescription(`\`⏭\` | *Skip to:* \`${args[0]}\``) + .setDescription(`\`⏭\` | *Skip to:* \`${value}\``) .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/commands/Music/TwentyFourSeven.js b/commands/Music/TwentyFourSeven.js index 3139650..de58f98 100644 --- a/commands/Music/TwentyFourSeven.js +++ b/commands/Music/TwentyFourSeven.js @@ -1,18 +1,14 @@ const { EmbedBuilder } = require('discord.js'); module.exports = { - config: { - name: "twentyfourseven", - description: "24/7 Music!", - accessableby: "Member", - category: "Music", - aliases: ["247"], - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "twentyfourseven"], + description: "24/7 in voice channel", + category: "Music", + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); if (player.data.get("stay")) { // get undefined = turn on + set data await player.data.set("stay", false); @@ -21,7 +17,7 @@ module.exports = { .setDescription("`🌙` | *Mode 24/7 has been:* `Deactivated`") .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } else { await player.data.set("stay", true); @@ -29,7 +25,7 @@ module.exports = { .setDescription("`🌕` | *Mode 24/7 has been:* `Activated`") .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } }; \ No newline at end of file diff --git a/commands/Music/Volume.js b/commands/Music/Volume.js index 8b8961a..ac607f0 100644 --- a/commands/Music/Volume.js +++ b/commands/Music/Volume.js @@ -1,29 +1,34 @@ -const { EmbedBuilder } = require('discord.js'); +const { EmbedBuilder, ApplicationCommandOptionType } = require('discord.js'); module.exports = { - config: { - name: "volume", - aliases: ["vol", "v"], - description: "Adjusts the volume of the bot.", - accessableby: "Member", - category: "Music", - usage: "" - }, - run: async (client, message, args) => { - const player = client.manager.players.get(message.guild.id); - if (!player) return message.reply(`No playing in this guild!`); - const { channel } = message.member.voice; - if (!channel || message.member.voice.channel !== message.guild.members.me.voice.channel) return message.reply(`I'm not in the same voice channel as you!`); + name: ["music", "volume"], + description: "Adjusts the volume of the bot.", + category: "Music", + options: [ + { + name: "amount", + description: "The amount of volume to set the bot to.", + type: ApplicationCommandOptionType.Integer, + required: false, + min_value: 1, + max_value: 100 + } + ], + run: async (client, interaction) => { + const player = client.manager.players.get(interaction.guild.id); + if (!player) return interaction.reply(`No playing in this guild!`); + const { channel } = interaction.member.voice; + if (!channel || interaction.member.voice.channel !== interaction.guild.members.me.voice.channel) return interaction.reply(`I'm not in the same voice channel as you!`); - if (!args[0]) return message.reply(`*Current volume:* ${player.volume}%`); - if (Number(args[0]) <= 0 || Number(args[0]) > 100) return message.reply(`Please provide a volume between 1 and 100.`); + const value = interaction.options.getInteger("amount"); + if (!value) return interaction.reply(`*Current volume:* ${player.volume}%`); - await player.setVolume(Number(args[0])); + await player.setVolume(Number(value)); const embed = new EmbedBuilder() - .setDescription(`\`🔈\` | *Volume set to:* \`${args[0]}%\``) + .setDescription(`\`🔈\` | *Volume set to:* \`${value}%\``) .setColor(client.color); - return message.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] }); } } \ No newline at end of file diff --git a/deploySlash.js b/deploySlash.js new file mode 100644 index 0000000..793ddcb --- /dev/null +++ b/deploySlash.js @@ -0,0 +1,181 @@ +const { plsParseArgs } = require('plsargs'); +const args = plsParseArgs(process.argv.slice(2)); +const chillout = require("chillout"); +const { makeSureFolderExists } = require("stuffs"); +const path = require("path"); +const readdirRecursive = require("recursive-readdir"); +const { TOKEN } = require("./settings/config.js"); +const { ApplicationCommandOptionType, REST, Routes, ApplicationCommandManager } = require('discord.js'); + +(async () => { + + let command = []; + + let cleared = args.get(0) == "guild" ? args.get(2) == "clear" : (args.get(0) == "global" ? args.get(1) == "clear" : false); + let deployed = args.get(0) == "guild" ? "guild" : args.get(0) == "global" ? "global" : null; + + if (!deployed) { + console.error(`Invalid sharing mode! Valid modes: guild, global`); + console.error(`Usage example: node deploySlash.js guild [clear]`); + console.error(`Usage example: node deploySlash.js global [clear]`); + return process.exit(1); + } + + if (!cleared) { + let interactionsFolder = path.resolve("./commands"); + + await makeSureFolderExists(interactionsFolder); + + let store = []; + + console.log("Reading interaction files..") + + let interactionFilePaths = await readdirRecursive(interactionsFolder); + interactionFilePaths = interactionFilePaths.filter(i => { + let state = path.basename(i).startsWith("-"); + return !state; + }); + + await chillout.forEach(interactionFilePaths, (interactionFilePath) => { + const cmd = require(interactionFilePath); + console.log(`Interaction "${cmd.type == "CHAT_INPUT" ? `/${cmd.name.join(" ")}` : `${cmd.name[0]}`}" ${cmd.name[1] || ""} ${cmd.name[2] || ""} added to the transform list!`); + store.push(cmd); + }); + + store = store.sort((a, b) => a.name.length - b.name.length) + + command = store.reduce((all, current) => { + switch (current.name.length) { + case 1: { + all.push({ + type: current.type, + name: current.name[0], + description: current.description, + defaultPermission: current.defaultPermission, + options: current.options + }); + break; + } + case 2: { + let baseItem = all.find((i) => { + return i.name == current.name[0] && i.type == current.type + }); + if (!baseItem) { + all.push({ + type: current.type, + name: current.name[0], + description: `${current.name[0]} commands.`, + defaultPermission: current.defaultPermission, + options: [ + { + type: ApplicationCommandOptionType.Subcommand, + description: current.description, + name: current.name[1], + options: current.options + } + ] + }); + } else { + baseItem.options.push({ + type: ApplicationCommandOptionType.Subcommand, + description: current.description, + name: current.name[1], + options: current.options + }) + } + break; + } + case 3: { + let SubItem = all.find((i) => { + return i.name == current.name[0] && i.type == current.type + }); + if (!SubItem) { + all.push({ + type: current.type, + name: current.name[0], + description: `${current.name[0]} commands.`, + defaultPermission: current.defaultPermission, + options: [ + { + type: ApplicationCommandOptionType.SubcommandGroup, + description: `${current.name[1]} commands.`, + name: current.name[1], + options: [ + { + type: ApplicationCommandOptionType.Subcommand, + description: current.description, + name: current.name[2], + options: current.options + } + ] + } + ] + }); + } else { + let GroupItem = SubItem.options.find(i => { + return i.name == current.name[1] && i.type == ApplicationCommandOptionType.SubcommandGroup + }); + if (!GroupItem) { + SubItem.options.push({ + type: ApplicationCommandOptionType.SubcommandGroup, + description: `${current.name[1]} commands.`, + name: current.name[1], + options: [ + { + type: ApplicationCommandOptionType.Subcommand, + description: current.description, + name: current.name[2], + options: current.options + } + ] + }) + } else { + GroupItem.options.push({ + type: ApplicationCommandOptionType.Subcommand, + description: current.description, + name: current.name[2], + options: current.options + }) + } + } + } + break; + } + + return all; + }, []); + + command = command.map(i => ApplicationCommandManager.transformCommand(i)); + } else { + console.info("No interactions read, all existing ones will be cleared..."); + } + + const rest = new REST({ version: "9" }).setToken(TOKEN); + const client = await rest.get(Routes.user()); + console.info(`Account information received! ${client.username}#${client.discriminator} (${client.id})`); + + console.info(`Interactions are posted on discord!`); + switch (deployed) { + case "guild": { + let guildId = args.get(1); + console.info(`Deploy mode: guild (${guildId})`); + + await rest.put(Routes.applicationGuildCommands(client.id, guildId), { body: command }); + + console.info(`Shared commands may take 3-5 seconds to arrive.`); + break; + } + case "global": { + console.info(`Deploy mode: global`); + + await rest.put(Routes.applicationCommands(client.id), { body: command }); + + console.info(`Shared commands can take up to 1 hour to arrive. If you want it to come immediately, you can throw your bot from your server and get it back.`); + break; + } + } + + console.info(`Interactions shared!`); +})(); + +/// Credit https://github.com/akanora/Youtube-Together (Handler) || Edit by: https://github.com/Adivise \ No newline at end of file diff --git a/events/guild/interactionCreate.js b/events/guild/interactionCreate.js new file mode 100644 index 0000000..c2d2ca5 --- /dev/null +++ b/events/guild/interactionCreate.js @@ -0,0 +1,60 @@ +const { InteractionType, PermissionsBitField } = require("discord.js"); +const ytsr = require("@distube/ytsr"); +const { SEARCH_DEFAULT } = require("../../settings/config.js") + +module.exports = async(client, interaction) => { + if (interaction.isCommand || interaction.isContextMenuCommand || interaction.isModalSubmit || interaction.isChatInputCommand) { + if (!interaction.guild || interaction.user.bot) return; + + let subCommandName = ""; + try { + subCommandName = interaction.options.getSubcommand(); + } catch { }; + let subCommandGroupName = ""; + try { + subCommandGroupName = interaction.options.getSubcommandGroup(); + } catch { }; + + if (interaction.type == InteractionType.ApplicationCommandAutocomplete) { + const Random = SEARCH_DEFAULT[Math.floor(Math.random() * SEARCH_DEFAULT.length)]; + if(interaction.commandName == "play") { + let choice = [] + await ytsr(interaction.options.getString("search") || Random, { safeSearch: true, limit: 10 }).then(result => { + result.items.forEach(x => { choice.push({ name: x.name, value: x.url }) }) + }); + return await interaction.respond(choice).catch(() => { }); + } else if (interaction.options.getSubcommand() == "playskip") { + let choice = [] + await ytsr(interaction.options.getString("search") || Random, { safeSearch: true, limit: 10 }).then(result => { + result.items.forEach(x => { choice.push({ name: x.name, value: x.url }) }) + }); + return await interaction.respond(choice).catch(() => { }); + } else if (interaction.options.getSubcommand() == "playtop") { + let choice = [] + await ytsr(interaction.options.getString("search") || Random, { safeSearch: true, limit: 10 }).then(result => { + result.items.forEach(x => { choice.push({ name: x.name, value: x.url }) }) + }); + return await interaction.respond(choice).catch(() => { }); + } + } + + const command = client.commands.find(command => { + switch (command.name.length) { + case 1: return command.name[0] == interaction.commandName; + case 2: return command.name[0] == interaction.commandName && command.name[1] == subCommandName; + case 3: return command.name[0] == interaction.commandName && command.name[1] == subCommandGroupName && command.name[2] == subCommandName; + } + }); + if (!command) return; + + if (command) { + try { + command.run(client, interaction); + } catch (error) { + console.log(error); + return interaction.reply({ content: `Something went wrong!`, ephmeral: true }); + } + } + + } +} diff --git a/events/guild/messageCreate.js b/events/guild/messageCreate.js deleted file mode 100644 index 567a5a1..0000000 --- a/events/guild/messageCreate.js +++ /dev/null @@ -1,44 +0,0 @@ -const { PermissionsBitField, EmbedBuilder } = require("discord.js"); - -module.exports = async (client, message) => { - if(message.author.bot || message.channel.type === 1) return; - - const prefix = client.prefix; - - const mention = new RegExp(`^<@!?${client.user.id}>( |)$`); - if(message.content.match(mention)) { - const embed = new EmbedBuilder() - .setColor(client.color) - .setDescription(`My prefix is: \`${prefix}\``); - message.channel.send({ embeds: [embed] }) - }; - - const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefix)})\\s*`); - if (!prefixRegex.test(message.content)) return; - const [ matchedPrefix ] = message.content.match(prefixRegex); - const args = message.content.slice(matchedPrefix.length).trim().split(/ +/g); - const cmd = args.shift().toLowerCase(); - const command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd)); - if(!command) return; - - console.log(`[COMMAND] - ${command.config.name} executed by ${message.author.tag} | ${client.user.username} in ${message.guild.name} (${message.guild.id})`); - - if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.SendMessages)) return message.author.dmChannel.send(`${message.author}, I don't have permission to send messages in ${message.guild.name}!`); - if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.ViewChannel)) return; - if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.EmbedLinks)) return message.channel.send(`${message.author}, I don't have permission to embed links in ${message.guild.name}!`); - if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.Speak)) return message.channel.send(`${message.author}, I don't have permission to speak in ${message.guild.name}!`); - if(!message.guild.members.me.permissions.has(PermissionsBitField.Flags.Connect)) return message.channel.send(`${message.author}, I don't have permission to connect to voice channels in ${message.guild.name}!`); - - try { - if (command.ownerOnly) { - if (message.author.id !== client.owner) { - return message.channel.send(`${message.author}, You are not the owner!`); - } - } - command.run(client, message, args); - } catch (error) { - console.log(error) - await message.channel.send(`${message.author}, an error occured!`); - } -} \ No newline at end of file diff --git a/events/guild/voiceStateUpdate.js b/events/guild/voiceStateUpdate.js index c6a422d..cb28799 100644 --- a/events/guild/voiceStateUpdate.js +++ b/events/guild/voiceStateUpdate.js @@ -1,4 +1,4 @@ -const { PermissionsBitField } = require("discord.js"); +const { PermissionsBitField, ChannelType } = require("discord.js"); module.exports = async (client, oldState, newState) => { const player = client.manager.players.get(newState.guild.id); @@ -8,7 +8,7 @@ module.exports = async (client, oldState, newState) => { player.destroy(); } - if (newState.channelId && newState.channel.type == 13 && newState.guild.members.me.voice.suppress) { + if (newState.channelId && newState.channel.type == ChannelType.GuildStageVoice && newState.guild.members.me.voice.suppress) { if (newState.guild.members.me.permissions.has(PermissionsBitField.Flags.Speak) || (newState.channel && newState.channel.permissionsFor(nS.guild.members.me).has(PermissionsBitField.Flags.Speak))) { await delay(2000); diff --git a/handlers/loadCommand.js b/handlers/loadCommand.js index 60a2de5..99c326a 100644 --- a/handlers/loadCommand.js +++ b/handlers/loadCommand.js @@ -1,13 +1,36 @@ -const { readdirSync } = require("fs") +const chillout = require("chillout"); +const readdirRecursive = require("recursive-readdir"); +const { resolve, relative } = require("path"); module.exports = async (client) => { - const load = dirs => { - const commands = readdirSync(`./commands/${dirs}/`).filter(d => d.endsWith('.js')); - for (let file of commands) { - let pull = require(`../commands/${dirs}/${file}`); - client.commands.set(pull.config.name, pull); - if (pull.config.aliases) pull.config.aliases.forEach(a => client.aliases.set(a, pull.config.name)); - }; - }; - ["Music", "Filters", "Misc"].forEach(x => load(x)); -}; \ No newline at end of file + let interactionsPath = resolve("./commands"); + let interactionFiles = await readdirRecursive(interactionsPath); + + await chillout.forEach(interactionFiles, (interactionFile) => { + const rltPath = relative(__dirname, interactionFile); + const command = require(interactionFile); + + if (command.name.length > 3) { + console.log(`[WARN] "${rltPath}" The name list of the interaction file is too long. (>3) Skipping..`); + return; + } + + if (!command.name?.length) { + console.log(`[WARN] "${rltPath}" The interaction file does not have a name. Skipping..`); + return; + } + + if (client.commands.has(command.name)) { + console.log(`[WARN] "${command.name[1]}" interaction has already been installed. It's skipping.`) + return; + } + + client.commands.set(command.name, command); + }); + + if (client.commands.size) { + console.log(`[INFO] ${client.commands.size} Interactions Loaded!`); + } else { + console.log(`[WARN] No interactions loaded, is everything ok?`); + } +} \ No newline at end of file diff --git a/index.js b/index.js index e83314f..8246fd8 100644 --- a/index.js +++ b/index.js @@ -8,8 +8,7 @@ const client = new Client({ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, - GatewayIntentBits.GuildVoiceStates, - GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildVoiceStates ], allowedMentions: { parse: ["users", "roles"] }, }); @@ -29,7 +28,7 @@ client.manager = new Kazagumo({ } }, new Connectors.DiscordJS(client), client.config.NODES); -["aliases", "commands"].forEach(x => client[x] = new Collection()); +["commands"].forEach(x => client[x] = new Collection()); ["loadCommand", "loadEvent", "loadPlayer", "loadTrack"].forEach(x => require(`./handlers/${x}`)(client)); client.login(client.token); \ No newline at end of file diff --git a/package.json b/package.json index f269b3a..5601c16 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,19 @@ { "dependencies": { - "common-tags": "^1.8.2", + "@distube/ytsr": "^1.1.9", + "chillout": "^5.0.0", "discord.js": "^14.7.1", "dotenv": "^16.0.3", "kazagumo": "^2.3.2", "lyrics-finder": "^21.7.0", - "shoukaku": "^3.3.1" + "plsargs": "^0.1.6", + "recursive-readdir": "^2.2.3", + "shoukaku": "^3.3.1", + "stuffs": "^0.1.27" }, "name": "miyu", "description": "✈ Join Discord: https://discord.gg/4pk97A2 👌", - "version": "1.0.1", + "version": "1.2.0", "main": "index.js", "scripts": { "start": "node index.js" diff --git a/settings/config.js b/settings/config.js index 059ab13..775efd8 100644 --- a/settings/config.js +++ b/settings/config.js @@ -2,9 +2,9 @@ require("dotenv").config(); module.exports = { TOKEN: process.env.TOKEN || "YOUR_TOKEN_BOT", - PREFIX: process.env.PREFIX || "#", OWNER_ID: process.env.OWNER_ID || "YOUR_DISCORD_OWNER_ID", EMBED_COLOR: process.env.EMBED_COLOR || "#000001", + SEARCH_DEFAULT: ["yoasobi", "zutomayo", "kotoha", "lisa"], SEARCH_ENGINE: process.env.SEARCH_ENGINE || "youtube", // default -- 'youtube' | 'soundcloud' | 'youtube_music' LEAVE_EMPTY: process.env.LEAVE_EMPTY || "120000", NODES: [ diff --git a/structures/PageQueue.js b/structures/PageQueue.js index 1ecbd14..3d4b815 100644 --- a/structures/PageQueue.js +++ b/structures/PageQueue.js @@ -16,10 +16,10 @@ const NormalPage = async (client, message, pages, timeout, queueLength, queueDur .addComponents(row1, row2) let page = 0; - const curPage = await message.channel.send({ embeds: [pages[page].setFooter({ text: `Page • ${page + 1}/${pages.length} | ${queueLength} • Song/s | ${queueDuration} • Total Duration` })], components: [row], allowedMentions: { repliedUser: false } }); + const curPage = await message.editReply({ embeds: [pages[page].setFooter({ text: `Page • ${page + 1}/${pages.length} | ${queueLength} • Song/s | ${queueDuration} • Total Duration` })], components: [row], allowedMentions: { repliedUser: false } }); if(pages.length == 0) return; - - const filter = (interaction) => interaction.user.id === message.author.id ? true : false && interaction.deferUpdate(); + + const filter = (m) => m.user.id === message.user.id; const collector = await curPage.createMessageComponentCollector({ filter, time: timeout }); collector.on('collect', async (interaction) => {