From 3ddf9ea782d00f28a2497b5de2a67bab02de7f4a Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 26 Mar 2023 15:18:58 -0400 Subject: [PATCH] Update commands to use the new slash command builder - Updated app js to remove Emmelia remnants --- Client/app.js | 2 +- Client/commands/join.js | 17 +++++++++++++++-- Client/commands/leave.js | 13 +++++++++++++ Client/commands/ping.js | 28 +++++++++++++++++++++++++--- Client/commands/status.js | 14 +++++++++++++- 5 files changed, 67 insertions(+), 7 deletions(-) diff --git a/Client/app.js b/Client/app.js index eeadfa2..6b42513 100644 --- a/Client/app.js +++ b/Client/app.js @@ -26,7 +26,7 @@ const { var app = express(); var discordToken = process.env.TOKEN; -var port = libUtils.normalizePort(process.env.HTTP_PORT || '3000'); +var port = process.env.HTTP_PORT || '3000'; const discordClient = new Client({ intents: [ diff --git a/Client/commands/join.js b/Client/commands/join.js index 1f8c0e6..850ecc3 100644 --- a/Client/commands/join.js +++ b/Client/commands/join.js @@ -1,9 +1,10 @@ // Debug -const { DebugBuilder } = require("../utilities/debugBuilder.js"); -const log = new DebugBuilder("client-bot", "join"); +const { DebugBuilder } = require("../utilities/debugBuilder"); +const log = new DebugBuilder("client", "ping"); // Modules const { joinVoiceChannel, VoiceConnectionStatus } = require("@discordjs/voice"); const {replyToInteraction} = require("../utilities/messageHandler.js"); +const { SlashCommandBuilder } = require('discord.js'); const {createAudioInstance} = require("../controllers/audioController.js"); const OpusEncoderPkg = require("@discordjs/opus"); @@ -11,6 +12,17 @@ const OpusEncoderPkg = require("@discordjs/opus"); const { OpusEncoder } = OpusEncoderPkg; const encoder = new OpusEncoder(48000, 2); +module.exports = { + data: new SlashCommandBuilder() + .setName('join') + .setDescription('Join a voice channel'), + example: "join", + isPrivileged: false, + async execute(interaction) { + await this.join({ interaction: interaction }); + } +} + /** * Join the specified voice channel * @@ -55,4 +67,5 @@ exports.join = async function join({interaction= undefined, guildID= undefined, }) if (guildID && callback) callback(); + else return; } \ No newline at end of file diff --git a/Client/commands/leave.js b/Client/commands/leave.js index e9c1a5e..2128949 100644 --- a/Client/commands/leave.js +++ b/Client/commands/leave.js @@ -1,9 +1,22 @@ 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"); +module.exports = { + data: new SlashCommandBuilder() + .setName('leave') + .setDescription('Leave a voice channel'), + example: "leave", + isPrivileged: false, + async execute(interaction) { + await this.leave({ interaction: interaction }) + } +} + + /** * If in a voice channel for the specified guild, leave * diff --git a/Client/commands/ping.js b/Client/commands/ping.js index 7edc4b4..2be9721 100644 --- a/Client/commands/ping.js +++ b/Client/commands/ping.js @@ -1,6 +1,28 @@ // Utilities const { replyToInteraction } = require('../utilities/messageHandler.js'); +const { SlashCommandBuilder } = require('discord.js'); +const { DebugBuilder } = require("../utilities/debugBuilder"); +const log = new DebugBuilder("client", "ping"); -export default function ping(interaction) { - return replyToInteraction(interaction, "Pong! I have Aids and now you do too!"); -} \ No newline at end of file +module.exports = { + data: new SlashCommandBuilder() + .setName('ping') + .setDescription('Replies with your input!'), + /* + .addStringOption(option => + option.setName('input') + .setDescription('The input to echo back') + .setRequired(false) + .addChoices()), + */ + example: "ping", + isPrivileged: false, + async execute(interaction) { + try{ + await replyToInteraction(interaction, "Pong! I have Aids and now you do too!"); // TODO - Add insults as the response to this command + }catch(err){ + log.ERROR(err) + //await interaction.reply(err.toString()); + } + } +}; \ No newline at end of file diff --git a/Client/commands/status.js b/Client/commands/status.js index 54e016d..4eb9ffa 100644 --- a/Client/commands/status.js +++ b/Client/commands/status.js @@ -4,7 +4,19 @@ const log = new DebugBuilder("client-bot", "status"); // Modules const {getVoiceConnection} = require("@discordjs/voice"); // Utilities -const { replyToInteraction } = require('../utilities/messageHandler.js'); +const {replyToInteraction} = require("../utilities/messageHandler.js"); +const { SlashCommandBuilder } = require('discord.js'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('status') + .setDescription('Check the status of the bot'), + example: "status", + isPrivileged: false, + async execute(interaction) { + await this.status({ interaction: interaction }); + } +} exports.status = async function status({interaction= undefined, guildID= undefined, callback = undefined}) {