Implement aliases

This commit is contained in:
Wizzard 2024-08-17 20:13:09 -04:00
parent f24da4ef20
commit ecb5a75de1
6 changed files with 10 additions and 2 deletions

View File

@ -3,6 +3,7 @@ const { EmbedBuilder } = require('discord.js');
module.exports = {
name: 'help',
description: 'List all commands or get details about a specific command',
aliases: ['h'],
execute(message, args) {
const { commands } = message.client;
const commandsArray = Array.from(commands.values());

View File

@ -8,6 +8,7 @@ const { exec, spawn } = require('child_process');
module.exports = {
name: 'play',
description: 'Play a song from YouTube, a URL, or an uploaded media file',
aliases: ['p'],
async execute(message, args) {
const fetch = await import('node-fetch').then(module => module.default);
const searchQuery = args.join(' ');

View File

@ -4,6 +4,7 @@ const { EmbedBuilder } = require('discord.js');
module.exports = {
name: 'queue',
description: 'Show the current songs in queue',
aliases: ['q'],
execute(message) {
const queue = getQueue(message.guild.id);
const currentTrack = getCurrentTrack(message.guild.id);

View File

@ -3,6 +3,7 @@ const { getQueue, removeFromQueue } = require('../utils/queueManager');
module.exports = {
name: 'remove',
description: 'Remove a specific song from the queue by its number',
aliases: ['rm'],
execute(message, args) {
const queue = getQueue(message.guild.id);
const indexToRemove = parseInt(args[0], 10) - 1;

View File

@ -3,6 +3,7 @@ const { skipTrack, getCurrentTrack, getQueue } = require('../utils/queueManager'
module.exports = {
name: 'skip',
description: 'Skip the current track',
aliases: ['s'],
execute(message) {
const guildId = message.guild.id;
const voiceChannel = message.member.voice.channel;

View File

@ -64,10 +64,13 @@ client.on('messageCreate', async message => {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName) ||
Array.from(client.commands.values()).find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return;
try {
await client.commands.get(commandName).execute(message, args);
await command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('There was an error trying to execute that command!');