skip.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const { MessageEmbed } = require("discord.js");
  2. const { TrackUtils } = require("erela.js");
  3. module.exports = {
  4. name: "skip",
  5. description: "Skip the current song",
  6. usage: "",
  7. permissions: {
  8. channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
  9. member: [],
  10. },
  11. aliases: ["s", "next"],
  12. /**
  13. *
  14. * @param {import("../structures/DiscordMusicBot")} client
  15. * @param {import("discord.js").Message} message
  16. * @param {string[]} args
  17. * @param {*} param3
  18. */
  19. run: async (client, message, args, { GuildDB }) => {
  20. let player = await client.Manager.get(message.guild.id);
  21. if (!player) return client.sendTime(message.channel, "❌ | **Nothing is playing right now...**");
  22. if (!message.member.voice.channel) return client.sendTime(message.channel, "❌ | **You must be in a voice channel to use this command!**");
  23. player.stop();
  24. await message.react("✅");
  25. },
  26. SlashCommand: {
  27. run: async (client, interaction, args, { GuildDB }) => {
  28. const guild = client.guilds.cache.get(interaction.guild_id);
  29. const member = guild.members.cache.get(interaction.member.user.id);
  30. if (!member.voice.channel) return client.sendTime(interaction, "❌ | **You must be in a voice channel to use this command.**");
  31. if (guild.me.voice.channel && !guild.me.voice.channel.equals(member.voice.channel)) return client.sendTime(interaction, `❌ | **You must be in ${guild.me.voice.channel} to use this command.**`);
  32. const skipTo = interaction.data.options ? interaction.data.options[0].value : null;
  33. let player = await client.Manager.get(interaction.guild_id);
  34. if (!player) return interaction.send("Nothing is playing right now...");
  35. console.log(interaction.data);
  36. if (skipTo !== null && (isNaN(skipTo) || skipTo < 1 || skipTo > player.queue.length)) return interaction.send("❌ | Invalid number to skip.");
  37. player.stop(skipTo);
  38. interaction.send("Skipped the song");
  39. },
  40. },
  41. };