Adding functional usage of client self updater #10

- Added update command to the server
- Server can request nodes update
- Nodes have an 'endpoint' for updating
- Fixes to the install script
This commit is contained in:
Logan Cusano
2024-03-03 20:49:29 -05:00
parent 976c44838e
commit 956dc89107
6 changed files with 72 additions and 6 deletions

View File

@@ -0,0 +1,32 @@
import { SlashCommandBuilder } from 'discord.js';
import { requestNodeUpdate } from '../../modules/socketServerWrappers.mjs';
// Exporting data property that contains the command structure for discord including any params
export const data = new SlashCommandBuilder()
.setName('update')
.setDescription('Updates all nodes currently logged on');
// Exporting other properties
export const example = "/update"; // 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.
/**
* 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);
await sockets.map(openSocket => {
requestNodeUpdate(openSocket);
})
//await interaction.reply(`**Online Sockets: '${sockets}'**`);
await interaction.reply('**Pong.**');
//await interaction.channel.send('**Pong.**');
} catch (err) {
console.error(err);
// await interaction.reply(err.toString());
}
}