skipto.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. const { MessageEmbed } = require("discord.js");
  2. const { TrackUtils, Player } = require("erela.js");
  3. module.exports = {
  4. name: "skipto",
  5. description: `Skip to a song in the queue`,
  6. usage: "<number>",
  7. permissions: {
  8. channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
  9. member: [],
  10. },
  11. aliases: ["st"],
  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. const player = client.Manager.create({
  21. guild: message.guild.id,
  22. voiceChannel: message.member.voice.channel.id,
  23. textChannel: message.channel.id,
  24. selfDeafen: false,
  25. });
  26. if (!player) return client.sendTime(message.channel, "❌ | **Nothing is playing right now...**");
  27. if (!message.member.voice.channel) return client.sendTime(message.channel, "❌ | **You must be in a voice channel to use this command!**");
  28. //else if(message.guild.me.voice && message.guild.me.voice.channel.id !== message.member.voice.channel.id)return client.sendTime(message.channel, `❌ | **You must be in ${guild.me.voice.channel} to use this command.**`);
  29. try {
  30. if (!args[0])
  31. return message.channel.send(new MessageEmbed()
  32. .setColor("GREEN")
  33. .setDescription(`**Usage**: \`${GuildDB.prefix}skipto [number]\``)
  34. );
  35. //if the wished track is bigger then the Queue Size
  36. if (Number(args[0]) > player.queue.size)
  37. return message.channel.send(new MessageEmbed()
  38. .setColor("GREEN")
  39. .setDescription(`❌ | That song is not in the queue! Please try again!`)
  40. );
  41. //remove all tracks to the jumped song
  42. player.queue.remove(0, Number(args[0]) - 1);
  43. //stop the player
  44. player.stop()
  45. //Send Success Message
  46. return message.channel.send(new MessageEmbed()
  47. .setDescription(`⏭ Skipped \`${Number(args[0] - 1)}\` songs`)
  48. .setColor("GREEN")
  49. );
  50. } catch (e) {
  51. console.log(String(e.stack).bgRed)
  52. client.sendError(
  53. message.channel,
  54. "Something went wrong."
  55. );
  56. }
  57. },
  58. SlashCommand: {
  59. options: [
  60. {
  61. name: "number",
  62. value: "[number]",
  63. type: 4,
  64. required: true,
  65. description: "Remove a song from the queue",
  66. },
  67. ],
  68. /**
  69. *
  70. * @param {import("../structures/DiscordMusicBot")} client
  71. * @param {import("discord.js").Message} message
  72. * @param {string[]} args
  73. * @param {*} param3
  74. */
  75. run: async (client, interaction, args, { GuildDB }) => {
  76. const player = client.Manager.create({
  77. guild: interaction.guild_id,
  78. voiceChannel: interaction.member.voice.channel.id,
  79. textChannel: interaction.channel.id,
  80. selfDeafen: false,
  81. });
  82. try {
  83. if (!args[0])
  84. return interaction.send(new MessageEmbed()
  85. .setColor("GREEN")
  86. .setDescription(`**Usage**: \`${GuildDB.prefix}skipto <number>\``)
  87. );
  88. //if the wished track is bigger then the Queue Size
  89. if (Number(args[0]) > player.queue.size)
  90. return interaction.send(new MessageEmbed()
  91. .setColor("GREEN")
  92. .setTitle(`❌ | That song is not in the queue! Please try again!`)
  93. );
  94. //remove all tracks to the jumped song
  95. player.queue.remove(0, Number(args[0]) - 1);
  96. //stop the player
  97. player.stop()
  98. //Send Success Message
  99. return interaction.send(new MessageEmbed()
  100. .setDescription(`⏭ Skipped \`${Number(args[0])}\` songs`)
  101. .setColor("GREEN")
  102. );
  103. } catch (e) {
  104. console.log(String(e.stack).bgRed)
  105. client.sendError(
  106. interaction,
  107. "Something went wrong."
  108. );
  109. }
  110. },
  111. }
  112. };