leave.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const { MessageEmbed } = require("discord.js");
  2. module.exports = {
  3. name: "leave",
  4. description: "Disconnecting the bot from the voice channel",
  5. usage: "",
  6. permissions: {
  7. channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
  8. member: [],
  9. },
  10. aliases: ["stop", "exit", "quit", "dc", "disconnect"],
  11. /**
  12. *
  13. * @param {import("../structures/DiscordMusicBot")} client
  14. * @param {import("discord.js").Message} message
  15. * @param {string[]} args
  16. * @param {*} param3
  17. */
  18. run: async (client, message, args, { GuildDB }) => {
  19. let player = await client.Manager.get(message.guild.id);
  20. if (!player)
  21. return client.sendTime(
  22. message.channel,
  23. "❌ | **Nothing is playing right now...**"
  24. );
  25. await client.sendTime(
  26. message.channel,
  27. ":notes: | **The player has stopped and the queue has been cleared.**"
  28. );
  29. await message.react("✅");
  30. player.destroy();
  31. },
  32. SlashCommand: {
  33. /**
  34. *
  35. * @param {import("../structures/DiscordMusicBot")} client
  36. * @param {import("discord.js").Message} message
  37. * @param {string[]} args
  38. * @param {*} param3
  39. */
  40. run: async (client, interaction, args, { GuildDB }) => {
  41. const guild = client.guilds.cache.get(interaction.guild_id);
  42. const member = guild.members.cache.get(interaction.member.user.id);
  43. if (!member.voice.channel)
  44. return client.sendTime(
  45. interaction,
  46. "❌ | **You must be in a voice channel to use this command.**"
  47. );
  48. if (
  49. guild.me.voice.channel &&
  50. !guild.me.voice.channel.equals(member.voice.channel)
  51. )
  52. return client.sendTime(
  53. interaction,
  54. `❌ | **You must be in ${guild.me.voice.channel} to use this command.**`
  55. );
  56. let player = await client.Manager.get(interaction.guild_id);
  57. if (!player)
  58. return client.sendTime(
  59. interaction,
  60. "❌ | **Nothing is playing right now...**"
  61. );
  62. player.destroy();
  63. client.sendTime(
  64. interaction,
  65. ":notes: | **The player has stopped and the queue has been cleared.**"
  66. );
  67. },
  68. },
  69. };