update command names

This commit is contained in:
MCHost 2024-10-02 02:27:21 -04:00
parent e45113f078
commit b28b67f248

View File

@ -159,27 +159,27 @@ function handleResponse(response, interaction, ephemeral = false) {
// Slash command definitions // Slash command definitions
const commands = [ const commands = [
// new SlashCommandBuilder().setName('api-key-time').setDescription('Get the server time'), // new SlashCommandBuilder().setName('api-key-time').setDescription('Get the server time'),
new SlashCommandBuilder().setName('server-stats').setDescription('Get the server statistics'), new SlashCommandBuilder().setName('stats').setDescription('Get the server statistics'),
new SlashCommandBuilder().setName('server-log').setDescription('Get the server log'), new SlashCommandBuilder().setName('logs').setDescription('Get the server log'),
new SlashCommandBuilder().setName('start-server').setDescription('Start the Minecraft server'), new SlashCommandBuilder().setName('start-server').setDescription('Start the Minecraft server'),
new SlashCommandBuilder().setName('stop-server').setDescription('Stop the Minecraft server'), new SlashCommandBuilder().setName('stop-server').setDescription('Stop the Minecraft server'),
new SlashCommandBuilder().setName('restart-server').setDescription('Restart the Minecraft server'), new SlashCommandBuilder().setName('restart-server').setDescription('Restart the Minecraft server'),
new SlashCommandBuilder().setName('create-link').setDescription('Create a custom server link'), new SlashCommandBuilder().setName('my-mc-link').setDescription('Create a custom server link'),
new SlashCommandBuilder().setName('create-sftp-link').setDescription('Create an SFTP link'), new SlashCommandBuilder().setName('my-sftp-link').setDescription('Create an SFTP link'),
new SlashCommandBuilder().setName('get-connection-hash').setDescription('Get the connection hash'), new SlashCommandBuilder().setName('get-connection-hash').setDescription('Get the connection hash'),
new SlashCommandBuilder().setName('get-connection-hash-sftp').setDescription('Get the SFTP connection hash'), new SlashCommandBuilder().setName('get-connection-hash-sftp').setDescription('Get the SFTP connection hash'),
new SlashCommandBuilder().setName('get-players').setDescription('Get a list of online players'), new SlashCommandBuilder().setName('list-players').setDescription('Get a list of online players'),
new SlashCommandBuilder().setName('get-website-url').setDescription('Get the server website URL'), new SlashCommandBuilder().setName('my-website-url').setDescription('Get the server website URL'),
new SlashCommandBuilder().setName('get-map-url').setDescription('Get the server map URL'), new SlashCommandBuilder().setName('bluemap-url ').setDescription('Get the server map URL'),
new SlashCommandBuilder().setName('ban-player').setDescription('Ban a player by username').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)), new SlashCommandBuilder().setName('ban').setDescription('Ban a player by username').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)),
new SlashCommandBuilder().setName('unban-player').setDescription('Unban a player by username').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)), new SlashCommandBuilder().setName('unban').setDescription('Unban a player by username').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)),
new SlashCommandBuilder().setName('send-message').setDescription('Send a message to all players').addStringOption(option => option.setName('message').setDescription('Message to send').setRequired(true)), new SlashCommandBuilder().setName('send-message').setDescription('Send a message to all players').addStringOption(option => option.setName('message').setDescription('Message to send').setRequired(true)),
new SlashCommandBuilder().setName('send-private-message').setDescription('Send a private message to a player').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)).addStringOption(option => option.setName('message').setDescription('Message to send').setRequired(true)), new SlashCommandBuilder().setName('send-private-message').setDescription('Send a private message to a player').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)).addStringOption(option => option.setName('message').setDescription('Message to send').setRequired(true)),
new SlashCommandBuilder().setName('execute-console-command').setDescription('Execute a command in the server console').addStringOption(option => option.setName('command').setDescription('Command to execute').setRequired(true)), new SlashCommandBuilder().setName('mc-cmd').setDescription('Execute a command in the server console').addStringOption(option => option.setName('command').setDescription('Command to execute').setRequired(true)),
new SlashCommandBuilder().setName('give-item').setDescription('Give an item to a player').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)).addStringOption(option => option.setName('item').setDescription('Item to give').setRequired(true)).addIntegerOption(option => option.setName('amount').setDescription('Amount to give').setRequired(true)), new SlashCommandBuilder().setName('give').setDescription('Give an item to a player').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)).addStringOption(option => option.setName('item').setDescription('Item to give').setRequired(true)).addIntegerOption(option => option.setName('amount').setDescription('Amount to give').setRequired(true)),
new SlashCommandBuilder().setName('install-mod').setDescription('Install a mod by ID').addStringOption(option => option.setName('modid').setDescription('Mod ID').setRequired(true)), new SlashCommandBuilder().setName('install-mod').setDescription('Install a mod by ID').addStringOption(option => option.setName('modid').setDescription('Mod ID').setRequired(true)),
new SlashCommandBuilder().setName('uninstall-mod').setDescription('Uninstall a mod by ID').addStringOption(option => option.setName('modid').setDescription('Mod ID').setRequired(true)), new SlashCommandBuilder().setName('uninstall-mod').setDescription('Uninstall a mod by ID').addStringOption(option => option.setName('modid').setDescription('Mod ID').setRequired(true)),
new SlashCommandBuilder().setName('get-installed-mods').setDescription('Get a list of installed mods'), new SlashCommandBuilder().setName('mod-list').setDescription('Get a list of installed mods'),
]; ];
// Prepare extra data for user commands // Prepare extra data for user commands
@ -227,12 +227,12 @@ client.on('interactionCreate', async interaction => {
// handleResponse(timeData, interaction); // handleResponse(timeData, interaction);
// break; // break;
case 'server-stats': case 'stats':
const stats = await handleApiCall(() => MyMC.getStats(), userId, interaction); const stats = await handleApiCall(() => MyMC.getStats(), userId, interaction);
handleResponse(stats, interaction); handleResponse(stats, interaction);
break; break;
case 'server-log': case 'logs':
const log = await handleApiCall(() => MyMC.getLog(), userId, interaction); const log = await handleApiCall(() => MyMC.getLog(), userId, interaction);
handleResponse(log, interaction); handleResponse(log, interaction);
break; break;
@ -252,7 +252,7 @@ client.on('interactionCreate', async interaction => {
handleResponse(restartResult, interaction); handleResponse(restartResult, interaction);
break; break;
case 'create-link': case 'my-mc-link':
try { try {
// Check if the server is running // Check if the server is running
const runningCheck = await cmd(`node /home/mchost/scripts/docker_exec.js mc_${interaction.user.id} "/" "echo test"`); const runningCheck = await cmd(`node /home/mchost/scripts/docker_exec.js mc_${interaction.user.id} "/" "echo test"`);
@ -282,7 +282,7 @@ client.on('interactionCreate', async interaction => {
handleResponse(customLinkResult, interaction); handleResponse(customLinkResult, interaction);
} catch (error) { } catch (error) {
console.error('Error during create-link command:', error); console.error('Error during my-mc-link command:', error);
const response = { const response = {
success: false, success: false,
fields: [ fields: [
@ -296,7 +296,7 @@ client.on('interactionCreate', async interaction => {
case 'create-sftp-link': case 'my-mc-link':
try { try {
// Check if the server is running // Check if the server is running
const runningCheck = await cmd(`node /home/mchost/scripts/docker_exec.js mc_${interaction.user.id} "/" "echo test"`); const runningCheck = await cmd(`node /home/mchost/scripts/docker_exec.js mc_${interaction.user.id} "/" "echo test"`);
@ -326,7 +326,7 @@ client.on('interactionCreate', async interaction => {
handleResponse(sftpLinkResult, interaction, true); handleResponse(sftpLinkResult, interaction, true);
} catch (error) { } catch (error) {
console.error('Error during create-sftp-link command:', error); console.error('Error during my-mc-link command:', error);
const response = { const response = {
success: false, success: false,
fields: [ fields: [
@ -349,28 +349,28 @@ client.on('interactionCreate', async interaction => {
handleResponse(sftpHash, interaction, true); handleResponse(sftpHash, interaction, true);
break; break;
case 'get-players': case 'list-players':
const players = await handleApiCall(() => MyMC.getOnlinePlayers(), userId, interaction); const players = await handleApiCall(() => MyMC.getOnlinePlayers(), userId, interaction);
handleResponse(players, interaction); handleResponse(players, interaction);
break; break;
case 'get-website-url': case 'my-website-url':
const websiteURL = await handleApiCall(() => MyMC.getWebsiteURL(), userId, interaction); const websiteURL = await handleApiCall(() => MyMC.getWebsiteURL(), userId, interaction);
handleResponse(websiteURL, interaction); handleResponse(websiteURL, interaction);
break; break;
case 'get-map-url': case 'bluemap-url ':
const mapURL = await handleApiCall(() => MyMC.getMapURL(), userId, interaction); const mapURL = await handleApiCall(() => MyMC.getMapURL(), userId, interaction);
handleResponse(mapURL, interaction); handleResponse(mapURL, interaction);
break; break;
case 'ban-player': case 'ban':
const banUsername = interaction.options.getString('username'); const banUsername = interaction.options.getString('username');
const banResult = await handleApiCall(() => MyMC.postBan(banUsername), userId, interaction); const banResult = await handleApiCall(() => MyMC.postBan(banUsername), userId, interaction);
handleResponse(banResult, interaction, true); handleResponse(banResult, interaction, true);
break; break;
case 'unban-player': case 'unban':
const unbanUsername = interaction.options.getString('username'); const unbanUsername = interaction.options.getString('username');
const unbanResult = await handleApiCall(() => MyMC.postUnban(unbanUsername), userId, interaction); const unbanResult = await handleApiCall(() => MyMC.postUnban(unbanUsername), userId, interaction);
handleResponse(unbanResult, interaction, true); handleResponse(unbanResult, interaction, true);
@ -389,13 +389,13 @@ client.on('interactionCreate', async interaction => {
handleResponse(tellResult, interaction, true); handleResponse(tellResult, interaction, true);
break; break;
case 'execute-console-command': case 'mc-cmd':
const command = interaction.options.getString('command'); const command = interaction.options.getString('command');
const consoleResult = await handleApiCall(() => MyMC.postConsole(command), userId, interaction); const consoleResult = await handleApiCall(() => MyMC.postConsole(command), userId, interaction);
handleResponse(consoleResult, interaction, true); handleResponse(consoleResult, interaction, true);
break; break;
case 'give-item': case 'give':
const giveUsername = interaction.options.getString('username'); const giveUsername = interaction.options.getString('username');
const item = interaction.options.getString('item'); const item = interaction.options.getString('item');
const amount = interaction.options.getInteger('amount'); const amount = interaction.options.getInteger('amount');
@ -415,7 +415,7 @@ client.on('interactionCreate', async interaction => {
handleResponse(uninstallResult, interaction); handleResponse(uninstallResult, interaction);
break; break;
case 'get-installed-mods': case 'mod-list':
const installedMods = await handleApiCall(() => MyMC.getInstalledMods(), userId, interaction); const installedMods = await handleApiCall(() => MyMC.getInstalledMods(), userId, interaction);
handleResponse(installedMods, interaction); handleResponse(installedMods, interaction);
break; break;