From e431db1337f7432813062281fc835da70fd0d3aa Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 18 Feb 2024 20:06:08 -0500 Subject: [PATCH] Update the example/ping command - Added the auto complete function commented out - Added JSDoc and comments for clarity --- server/discordBot/commands/ping.mjs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/server/discordBot/commands/ping.mjs b/server/discordBot/commands/ping.mjs index 4a18209..6b4cc2e 100644 --- a/server/discordBot/commands/ping.mjs +++ b/server/discordBot/commands/ping.mjs @@ -1,16 +1,35 @@ import { SlashCommandBuilder } from 'discord.js'; -// Exporting data property +// Exporting data property that contains the command structure for discord including any params export const data = new SlashCommandBuilder() .setName('ping') .setDescription('Replies with your input!'); // Exporting other properties -export const example = "/ping"; -export const deferInitialReply = false; +export const example = "/ping"; // An example of how the command would be run in discord chat, this will be used for the help command +export const deferInitialReply = false; // If we the initial reply in discord should be deferred. This gives extra time to respond, however the method of replying is different. -// Exporting execute function -export async function execute(nodeIo, interaction) { +/** + * Function to give the user auto-reply suggestions + * @param {any} nodeIo The nodeIO server for manipulation of sockets + * @param {any} interaction The interaction object + */ +/* +export async function autocomplete(nodeIo, interaction) { + const focusedValue = interaction.options.getFocused(); + const choices = []; + const filtered = choices.filter(choice => choice.name.startsWith(focusedValue)); + console.log(focusedValue, choices, filtered); + await interaction.respond(filtered); +} +*/ + +/** + * The function to run when the command is called by a discord user + * @param {any} nodeIo The nodeIO server for manipulation of sockets + * @param {any} interaction The interaction object + */ +export const execute = async (nodeIo, interaction) => { try { const sockets = await nodeIo.allSockets(); console.log("All open sockets: ",sockets);