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 = { module.exports = {
name: 'help', name: 'help',
description: 'List all commands or get details about a specific command', description: 'List all commands or get details about a specific command',
aliases: ['h'],
execute(message, args) { execute(message, args) {
const { commands } = message.client; const { commands } = message.client;
const commandsArray = Array.from(commands.values()); const commandsArray = Array.from(commands.values());

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@ const { skipTrack, getCurrentTrack, getQueue } = require('../utils/queueManager'
module.exports = { module.exports = {
name: 'skip', name: 'skip',
description: 'Skip the current track', description: 'Skip the current track',
aliases: ['s'],
execute(message) { execute(message) {
const guildId = message.guild.id; const guildId = message.guild.id;
const voiceChannel = message.member.voice.channel; 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 args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase(); 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 { try {
await client.commands.get(commandName).execute(message, args); await command.execute(message, args);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
message.reply('There was an error trying to execute that command!'); message.reply('There was an error trying to execute that command!');