nyx/commands/Music/leave.js
night0721 bc346138dd Bot
2021-06-12 18:53:51 +08:00

35 lines
1.1 KiB
JavaScript

const { Client, Message, MessageEmbed } = require("discord.js");
module.exports = {
name: "disconnect",
aliases: ["dc"],
description: "Leave The Voice Channel",
category: "Music",
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
let channel = message.member.voice.channel;
if (!channel) return client.err(message, "Music", "disconnect", 35);
if (!message.guild.me.voice.channel)
return client.err(message, "Music", "disconnect", 41);
try {
await message.guild.me.voice.channel.leave();
} catch (error) {
await message.guild.me.voice.kick(message.guild.me.id);
}
const Embed = new MessageEmbed()
.setAuthor("Left Voice Channel", client.user.displayAvatarURL())
.setColor("GREEN")
.setTitle(
`By user: ${message.author.tag}`,
message.author.displayAvatarURL({ dynamic: true })
)
.setDescription("🎶 Left The Voice Channel.")
.setTimestamp();
return message.channel.send(Embed);
},
};