- Added update command to the server - Server can request nodes update - Nodes have an 'endpoint' for updating - Fixes to the install script
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
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());
|
|
}
|
|
} |