mrmBot-Matrix/commands/music/stop.js

29 lines
1.2 KiB
JavaScript
Raw Normal View History

import { manager, players, queues } from "../../utils/soundplayer.js";
import MusicCommand from "../../classes/musicCommand.js";
class StopCommand extends MusicCommand {
async run() {
this.success = false;
if (!this.guild) return "This command only works in servers!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
2022-01-06 00:55:42 +00:00
if (!this.connection) {
await manager.getNode().leaveChannel(this.guild.id);
this.success = true;
2022-01-06 00:55:42 +00:00
return "🔊 The current voice channel session has ended.";
}
if (this.connection.host !== this.author.id && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can stop the music!";
const connection = this.connection.player;
connection.node.leaveChannel(this.guild.id);
players.delete(this.guild.id);
queues.delete(this.guild.id);
this.success = true;
return `🔊 The voice channel session in \`${this.connection.voiceChannel.name}\` has ended.`;
}
static description = "Stops the music";
static aliases = ["disconnect"];
}
2021-12-13 22:09:12 +00:00
export default StopCommand;