Implement aliases
This commit is contained in:
parent
f24da4ef20
commit
ecb5a75de1
|
@ -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());
|
||||||
|
|
|
@ -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(' ');
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
7
index.js
7
index.js
|
@ -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!');
|
||||||
|
|
Loading…
Reference in New Issue