seek.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const { MessageEmbed } = require("discord.js");
  2. const { TrackUtils } = require("erela.js");
  3. module.exports = {
  4. name: "seek",
  5. description: "Seek to a position in the song",
  6. usage: "<time s/m/h>",
  7. permissions: {
  8. channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
  9. member: [],
  10. },
  11. aliases: ["forward"],
  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. if (!player.queue.current.isSeekable) return message.channel.send("This song is not able to seek from.");
  24. let SeekTo = client.ParseHumanTime(args.join(" "));
  25. if (!SeekTo) return message.channel.send("Please enter a time to seek!");
  26. player.seek(SeekTo * 1000);
  27. message.react("✅");
  28. },
  29. SlashCommand: {
  30. options: [
  31. {
  32. name: "time",
  33. description: "Seek to any part of a song",
  34. value: "time",
  35. type: 1,
  36. required: true,
  37. options: [],
  38. run: async (client, interaction, args, { GuildDB }) => {
  39. const guild = client.guilds.cache.get(interaction.guild_id);
  40. const member = guild.members.cache.get(interaction.member.user.id);
  41. if (!member.voice.channel) return client.sendTime(interaction, "❌ | **You must be in a voice channel to use this command.**");
  42. 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.**`);
  43. let player = await client.Manager.get(interaction.guild_id);
  44. if (!player) return interaction.send("❌ | **Nothing is playing right now...**");
  45. if (!player.queue.current.isSeekable) return interaction.send("This song is not able to seek from.");
  46. let SeekTo = client.ParseHumanTime(interaction.data.options[0].value);
  47. if (!SeekTo) return interaction.send("Please enter a time to seek!");
  48. player.seek(SeekTo * 1000);
  49. interaction.send("Successfully moved the song to ", Seekto);
  50. },
  51. },
  52. ],
  53. },
  54. };