Allow the client to interact with the discord bot

- The client can now interact with the bot, this allows the client to offer bot controls via API
- The master server will now be able to instruct a specific client to join a specific channel via channel ID (master server function coming soon)
- Suppress some debug statements to make the output easier to read when mixed in with the client debug output
This commit is contained in:
Logan Cusano
2022-12-18 20:31:54 -05:00
parent 6756a5e632
commit c8c75e8b37
9 changed files with 236 additions and 34 deletions

View File

@@ -8,11 +8,24 @@ import {replyToInteraction} from "../utilities/messageHandler.js";
* If in a voice channel for the specified guild, leave
*
* @param interaction Message interaction from discord
* @param guildID
* @param callback
*/
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.");
export default 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();
return replyToInteraction(interaction, `Goodbye`);
response = "Goodbye"
if (interaction) return replyToInteraction(interaction, response);
else callback(response);
}