Update bot to use command controller for interactions and calls

This commit is contained in:
Logan Cusano
2023-03-26 16:43:51 -04:00
parent 95c714f0aa
commit e537ce8778
5 changed files with 123 additions and 121 deletions

View File

@@ -1,9 +1,9 @@
const {getVoiceConnection} = require("@discordjs/voice");
const {replyToInteraction} = require("../utilities/messageHandler.js");
const { SlashCommandBuilder } = require('discord.js');
// Debug
const { DebugBuilder } = require("../utilities/debugBuilder.js");
const log = new DebugBuilder("client-bot", "leave");
// Modules
const { SlashCommandBuilder } = require('discord.js');
const { leave } = require("../controllers/commandController")
module.exports = {
data: new SlashCommandBuilder()
@@ -12,33 +12,6 @@ module.exports = {
example: "leave",
isPrivileged: false,
async execute(interaction) {
await this.leave({ interaction: interaction })
await leave({ interaction: interaction })
}
}
/**
* If in a voice channel for the specified guild, leave
*
* @param interaction Message interaction from discord
* @param guildID
* @param callback
*/
exports.leave = async function leave({interaction = undefined, guildID= undefined, callback = undefined}) {
if(interaction) {
guildID = interaction.guild.id;
}
const voiceConnection = getVoiceConnection(guildID);
let response;
if (!voiceConnection){
response = "Not in a voice channel."
if (interaction) return replyToInteraction(interaction, response);
else callback(response);
}
voiceConnection.destroy();
response = "Goodbye"
if (interaction) return replyToInteraction(interaction, response);
else callback(response);
}