-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop.js
30 lines (28 loc) · 1.09 KB
/
stop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const { MessageEmbed } = require("discord.js");
const sendError = require("../util/error");
module.exports = {
info: {
name: "stop",
description: "Para a música e limpa ela da fila",
usage: "",
aliases: [],
},
run: async function (client, message, args) {
const channel = message.member.voice.channel
if (!channel)return sendError("Você precisa está em um canal de voz para executar este comando", message.channel);
const serverQueue = message.client.queue.get(message.guild.id);
if (!serverQueue)return sendError("Não há uma música tocando agora", message.channel);
if(!serverQueue.connection)return
if(!serverQueue.connection.dispatcher)return
try{
serverQueue.connection.dispatcher.end();
} catch (error) {
message.guild.me.voice.channel.leave();
message.client.queue.delete(message.guild.id);
return sendError(`:notes: The player has stopped and the queue has been cleared.: ${error}`, message.channel);
}
message.client.queue.delete(message.guild.id);
serverQueue.songs = [];
message.react("✅")
},
};