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
const commands = [
// new SlashCommandBuilder().setName('api-key-time').setDescription('Get the server time'),
new SlashCommandBuilder().setName('server-stats').setDescription('Get the server statistics'),
new SlashCommandBuilder().setName('server-log').setDescription('Get the server log'),
new SlashCommandBuilder().setName('stats').setDescription('Get the server statistics'),
new SlashCommandBuilder().setName('logs').setDescription('Get the server log'),
new SlashCommandBuilder().setName('start-server').setDescription('Start 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('create-link').setDescription('Create a custom server link'),
new SlashCommandBuilder().setName('create-sftp-link').setDescription('Create an SFTP link'),
new SlashCommandBuilder().setName('my-mc-link').setDescription('Create a custom server 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-sftp').setDescription('Get the SFTP connection hash'),
new SlashCommandBuilder().setName('get-players').setDescription('Get a list of online players'),
new SlashCommandBuilder().setName('get-website-url').setDescription('Get the server website URL'),
new SlashCommandBuilder().setName('get-map-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('unban-player').setDescription('Unban a player by username').addStringOption(option => option.setName('username').setDescription('Player username').setRequired(true)),
new SlashCommandBuilder().setName('list-players').setDescription('Get a list of online players'),
new SlashCommandBuilder().setName('my-website-url').setDescription('Get the server website URL'),
new SlashCommandBuilder().setName('bluemap-url ').setDescription('Get the server map URL'),
new SlashCommandBuilder().setName('ban').setDescription('Ban 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-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('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('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').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('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
@ -227,12 +227,12 @@ client.on('interactionCreate', async interaction => {
// handleResponse(timeData, interaction);
// break;
case 'server-stats':
case 'stats':
const stats = await handleApiCall(() => MyMC.getStats(), userId, interaction);
handleResponse(stats, interaction);
break;
case 'server-log':
case 'logs':
const log = await handleApiCall(() => MyMC.getLog(), userId, interaction);
handleResponse(log, interaction);
break;
@ -252,7 +252,7 @@ client.on('interactionCreate', async interaction => {
handleResponse(restartResult, interaction);
break;
case 'create-link':
case 'my-mc-link':
try {
// Check if the server is running
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);
} catch (error) {
console.error('Error during create-link command:', error);
console.error('Error during my-mc-link command:', error);
const response = {
success: false,
fields: [
@ -296,7 +296,7 @@ client.on('interactionCreate', async interaction => {
case 'create-sftp-link':
case 'my-mc-link':
try {
// Check if the server is running
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);
} catch (error) {
console.error('Error during create-sftp-link command:', error);
console.error('Error during my-mc-link command:', error);
const response = {
success: false,
fields: [
@ -349,28 +349,28 @@ client.on('interactionCreate', async interaction => {
handleResponse(sftpHash, interaction, true);
break;
case 'get-players':
case 'list-players':
const players = await handleApiCall(() => MyMC.getOnlinePlayers(), userId, interaction);
handleResponse(players, interaction);
break;
case 'get-website-url':
case 'my-website-url':
const websiteURL = await handleApiCall(() => MyMC.getWebsiteURL(), userId, interaction);
handleResponse(websiteURL, interaction);
break;
case 'get-map-url':
case 'bluemap-url ':
const mapURL = await handleApiCall(() => MyMC.getMapURL(), userId, interaction);
handleResponse(mapURL, interaction);
break;
case 'ban-player':
case 'ban':
const banUsername = interaction.options.getString('username');
const banResult = await handleApiCall(() => MyMC.postBan(banUsername), userId, interaction);
handleResponse(banResult, interaction, true);
break;
case 'unban-player':
case 'unban':
const unbanUsername = interaction.options.getString('username');
const unbanResult = await handleApiCall(() => MyMC.postUnban(unbanUsername), userId, interaction);
handleResponse(unbanResult, interaction, true);
@ -389,13 +389,13 @@ client.on('interactionCreate', async interaction => {
handleResponse(tellResult, interaction, true);
break;
case 'execute-console-command':
case 'mc-cmd':
const command = interaction.options.getString('command');
const consoleResult = await handleApiCall(() => MyMC.postConsole(command), userId, interaction);
handleResponse(consoleResult, interaction, true);
break;
case 'give-item':
case 'give':
const giveUsername = interaction.options.getString('username');
const item = interaction.options.getString('item');
const amount = interaction.options.getInteger('amount');
@ -415,7 +415,7 @@ client.on('interactionCreate', async interaction => {
handleResponse(uninstallResult, interaction);
break;
case 'get-installed-mods':
case 'mod-list':
const installedMods = await handleApiCall(() => MyMC.getInstalledMods(), userId, interaction);
handleResponse(installedMods, interaction);
break;