18 lines
694 B
JavaScript
18 lines
694 B
JavaScript
import {getVoiceConnection} from "@discordjs/voice";
|
|
import {replyToInteraction} from "../utilities/messageHandler.js";
|
|
// Debug
|
|
//import debugBuilder from "../utilities/moduleDebugBuilder.js";
|
|
//const log = new debugBuilder("bot", "leave");
|
|
|
|
/**
|
|
* If in a voice channel for the specified guild, leave
|
|
*
|
|
* @param interaction Message interaction from discord
|
|
*/
|
|
export default async function leave(interaction){
|
|
const guildId = interaction.guild.id;
|
|
const voiceConnection = getVoiceConnection(guildId);
|
|
if (!voiceConnection) return replyToInteraction(interaction, "Not in a voice channel.");
|
|
voiceConnection.destroy();
|
|
return replyToInteraction(interaction, `Goodbye`);
|
|
} |