Functional joining and leaving

- Needs to be tested on multiple servers
- Needs to be tested with multiple nodes
#1 #9
This commit is contained in:
Logan Cusano
2024-02-18 20:05:10 -05:00
parent 6bc09df824
commit 42784f1852
7 changed files with 210 additions and 42 deletions

View File

@@ -12,7 +12,16 @@ export const data = new SlashCommandBuilder()
.setRequired(true)
.setAutocomplete(true));
export async function autocomplete(interaction) {
// Exporting other properties
export const example = "/join";
export const deferInitialReply = true;
/**
* 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 = await getAllSystems();
const filtered = choices.filter(choice => choice.name.startsWith(focusedValue));
@@ -24,14 +33,14 @@ export async function autocomplete(interaction) {
);
}
// Exporting other properties
export const example = "/join";
export const deferInitialReply = true;
// Exporting execute function
/**
* 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 async function execute(nodeIo, interaction) {
// Check if the user is in a VC
if (!interaction.member.voice.channel) { return await interaction.reply({ content: 'You need to enter a voice channel before use the command', ephemeral: true }) }
if (!interaction.member.voice.channel) { return await interaction.reply({ content: `<@${interaction.member.id}>, you need to enter a voice channel before use the command`, ephemeral: true }) }
// Grab the channel if the user is connected to VC
const channelToJoin = interaction.member.voice.channel;
@@ -74,7 +83,7 @@ export async function execute(nodeIo, interaction) {
// If there are no available nodes, let the user know there are none available
if (availableNodes.length == 0) {
// There are no nodes availble for the requested system
return await interaction.editReply("The selected system has no available nodes");
return await interaction.editReply(`<@${interaction.member.id}>, the selected system has no available nodes`);
} else if (availableNodes.length == 1) {
// There is only one node available for the requested system
// Request the node to join
@@ -94,7 +103,7 @@ export async function execute(nodeIo, interaction) {
// Reply to the user with the button prompts
const response = await interaction.editReply({
content: "Please select the Node you would like to join with this system",
content: `<@${interaction.member.id}>, Please select the Node you would like to join with this system`,
components: [actionRow]
});