Linting
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { requestBotLeaveServer, getSocketIdByNuid } from '../../modules/socketServerWrappers.mjs';
|
||||
import { checkOnlineBotsInGuild } from '../modules/wrappers.mjs';
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import {
|
||||
requestBotLeaveServer,
|
||||
getSocketIdByNuid,
|
||||
} from "../../modules/socketServerWrappers.mjs";
|
||||
import { checkOnlineBotsInGuild } from "../modules/wrappers.mjs";
|
||||
|
||||
const log = new DebugBuilder("server", "discordBot.command.leave");
|
||||
|
||||
// Exporting data property
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName('leave')
|
||||
.setDescription('Disconnect a bot from the server')
|
||||
.addStringOption(system =>
|
||||
system.setName('bot')
|
||||
.setDescription('The bot you would like to disconnect')
|
||||
.setName("leave")
|
||||
.setDescription("Disconnect a bot from the server")
|
||||
.addStringOption((system) =>
|
||||
system
|
||||
.setName("bot")
|
||||
.setDescription("The bot you would like to disconnect")
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true)
|
||||
.setAutocomplete(true),
|
||||
);
|
||||
|
||||
// Exporting other properties
|
||||
@@ -32,15 +36,14 @@ export async function autocomplete(nodeIo, interaction) {
|
||||
log.DEBUG(choices);
|
||||
|
||||
const filtered = choices
|
||||
.filter(choice => choice.name.startsWith(focusedValue))
|
||||
.map(choice => ({ name: choice.name, value: choice.nuid }));
|
||||
.filter((choice) => choice.name.startsWith(focusedValue))
|
||||
.map((choice) => ({ name: choice.name, value: choice.nuid }));
|
||||
|
||||
log.DEBUG(focusedValue, choices, filtered);
|
||||
|
||||
try{
|
||||
try {
|
||||
await interaction.respond(filtered);
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
log.WARN("Autocomplete interaction failure", e);
|
||||
}
|
||||
}
|
||||
@@ -52,19 +55,27 @@ export async function autocomplete(nodeIo, interaction) {
|
||||
*/
|
||||
export async function execute(nodeIo, interaction) {
|
||||
try {
|
||||
const selectedNode = interaction.options.getString('bot');
|
||||
const selectedNode = interaction.options.getString("bot");
|
||||
const socket = await getSocketIdByNuid(nodeIo, selectedNode);
|
||||
|
||||
if (!socket) {
|
||||
await interaction.editReply({ content: `Bot '${selectedNode}' not found or not connected.`, ephemeral: true });
|
||||
await interaction.editReply({
|
||||
content: `Bot '${selectedNode}' not found or not connected.`,
|
||||
ephemeral: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await requestBotLeaveServer(socket, interaction.guild.id);
|
||||
|
||||
await interaction.editReply(`Ok <@${interaction.member.id}>, the bot is leaving shortly.`);
|
||||
await interaction.editReply(
|
||||
`Ok <@${interaction.member.id}>, the bot is leaving shortly.`,
|
||||
);
|
||||
} catch (err) {
|
||||
log.ERROR("Failed to disconnect bot:", err);
|
||||
await interaction.editReply({ content: `An error occurred: ${err.message}`, ephemeral: true });
|
||||
await interaction.editReply({
|
||||
content: `An error occurred: ${err.message}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user