Compare commits
3 Commits
7d8ad68e27
...
fc11324714
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc11324714 | ||
|
|
c6c048c919 | ||
|
|
8ab611836b |
@@ -1,11 +1,9 @@
|
|||||||
// Modules
|
// Modules
|
||||||
const { customSlashCommandBuilder } = require('../utilities/customSlashCommandBuilder');
|
const { customSlashCommandBuilder } = require('../utilities/customSlashCommandBuilder');
|
||||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||||
const { BufferToJson, getMembersInRole, getKeyByArrayValue } = require("../utilities/utils");
|
const { getMembersInRole, getAllClientIds } = require("../utilities/utils");
|
||||||
const { requestOptions, sendHttpRequest } = require("../utilities/httpRequests");
|
const { requestOptions, sendHttpRequest } = require("../utilities/httpRequests");
|
||||||
const { readFileSync } = require('fs');
|
const { getOnlineNodes, updateNodeInfo } = require("../utilities/mysqlHandler");
|
||||||
const { getOnlineNodes, getNodeInfoFromId, updateNodeInfo } = require("../utilities/mysqlHandler");
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
// Global Vars
|
// Global Vars
|
||||||
const log = new DebugBuilder("server", "join");
|
const log = new DebugBuilder("server", "join");
|
||||||
@@ -44,7 +42,7 @@ async function joinServerWrapper(presetName, channelId, clientIdsUsed) {
|
|||||||
if (!nodesCurrentlyAvailable.length > 0) return Error("All nodes with this channel are unavailable, consider swapping one of the currently joined bots.");
|
if (!nodesCurrentlyAvailable.length > 0) return Error("All nodes with this channel are unavailable, consider swapping one of the currently joined bots.");
|
||||||
|
|
||||||
// If so, join with the first node
|
// If so, join with the first node
|
||||||
var availableClientIds = await Object(JSON.parse(readFileSync(path.resolve(__dirname, '../clientIds.json'))));
|
var availableClientIds = await getAllClientIds();
|
||||||
log.DEBUG("All clients: ", Object.keys(availableClientIds));
|
log.DEBUG("All clients: ", Object.keys(availableClientIds));
|
||||||
|
|
||||||
var selectedClientId;
|
var selectedClientId;
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ module.exports = {
|
|||||||
requiresTokens: false,
|
requiresTokens: false,
|
||||||
defaultTokenUsage: 0,
|
defaultTokenUsage: 0,
|
||||||
deferInitialReply: false,
|
deferInitialReply: false,
|
||||||
|
/*async autocomplete(interaction) {
|
||||||
|
const focusedValue = interaction.options.getFocused();
|
||||||
|
},*/
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
try{
|
try{
|
||||||
await interaction.channel.send('**Pong.**'); // TODO - Add insults as the response to this command
|
await interaction.channel.send('**Pong.**'); // TODO - Add insults as the response to this command
|
||||||
|
|||||||
@@ -8,45 +8,53 @@ const log = new DebugBuilder("server", "interactionCreate");
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.InteractionCreate,
|
name: Events.InteractionCreate,
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
|
const command = interaction.client.commands.get(interaction.commandName);
|
||||||
|
log.VERBOSE("Interaction for command: ", command);
|
||||||
|
|
||||||
|
// Execute autocomplete if the user is checking autocomplete
|
||||||
|
if (interaction.isAutocomplete()) {
|
||||||
|
log.DEBUG("Running autocomplete for command: ", command.data.name);
|
||||||
|
return await command.autocomplete(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the interaction is a command
|
||||||
if (!interaction.isChatInputCommand()) return;
|
if (!interaction.isChatInputCommand()) return;
|
||||||
|
|
||||||
const command = interaction.client.commands.get(interaction.commandName);
|
if (!command) {
|
||||||
|
log.ERROR(`No command matching ${interaction.commandName} was found.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!command) {
|
log.DEBUG(`${interaction.member.user} is running '${interaction.commandName}'`);
|
||||||
log.ERROR(`No command matching ${interaction.commandName} was found.`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.DEBUG(`${interaction.member.user} is running '${interaction.commandName}'`);
|
await authorizeCommand(interaction, command, async () => {
|
||||||
|
await authorizeTokenUsage(interaction, command, undefined, async () => {
|
||||||
await authorizeCommand(interaction, command, async () => {
|
try {
|
||||||
await authorizeTokenUsage(interaction, command, undefined, async () => {
|
if (command.deferInitialReply) {
|
||||||
try {
|
try {
|
||||||
if (command.deferInitialReply) {
|
if (interaction.options.getBool('public') && interaction.options.getBool('public') == false) await interaction.deferReply({ ephemeral: true });
|
||||||
try {
|
else await interaction.deferReply({ ephemeral: false });
|
||||||
if (interaction.options.getBool('public') && interaction.options.getBool('public') == false) await interaction.deferReply({ ephemeral: true });
|
|
||||||
else await interaction.deferReply({ ephemeral: false });
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
if (err instanceof TypeError) {
|
|
||||||
// The public option doesn't exist in this command
|
|
||||||
await interaction.deferReply({ ephemeral: false });
|
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
}
|
||||||
|
catch (err) {
|
||||||
|
if (err instanceof TypeError) {
|
||||||
|
// The public option doesn't exist in this command
|
||||||
|
await interaction.deferReply({ ephemeral: false });
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command.execute(interaction);
|
||||||
|
} catch (error) {
|
||||||
|
log.ERROR(error);
|
||||||
|
if (interaction.replied || interaction.deferred) {
|
||||||
|
interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
|
||||||
|
} else {
|
||||||
|
interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command.execute(interaction);
|
})
|
||||||
} catch (error) {
|
});
|
||||||
log.ERROR(error);
|
|
||||||
if (interaction.replied || interaction.deferred) {
|
|
||||||
interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
|
|
||||||
} else {
|
|
||||||
interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// Debug
|
// Debug
|
||||||
const { DebugBuilder } = require("../utilities/debugBuilder");
|
const { DebugBuilder } = require("../utilities/debugBuilder");
|
||||||
|
const { readFileSync } = require('fs');
|
||||||
const log = new DebugBuilder("server", "utils");
|
const log = new DebugBuilder("server", "utils");
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
// Convert a JSON object to a buffer for the DB
|
// Convert a JSON object to a buffer for the DB
|
||||||
exports.JsonToBuffer = (jsonObject) => {
|
exports.JsonToBuffer = (jsonObject) => {
|
||||||
@@ -73,3 +75,12 @@ exports.isJsonString = (str) => {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all client IDs from the saved JSON file
|
||||||
|
*
|
||||||
|
* @returns Object of Client IDs
|
||||||
|
*/
|
||||||
|
exports.getAllClientIds = () => {
|
||||||
|
return Object(JSON.parse(readFileSync(path.resolve(__dirname, '../clientIds.json'))));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user