feat: Updated /help command to be dynamic

This commit is contained in:
Marius Begby committed 2023-07-23 14:55:53 +02:00
1 parent 6af04f7b5c
commit b95a652f1c
15 files changed
+87 -13

No files matched your search

+35 -2
View File
@@ -5,8 +5,40 @@ module.exports = {
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Show a list of commands and their usage.')
.setDMPermission(false),
execute: async ({ interaction }) => {
.setDMPermission(false)
.setNSFW(false),
execute: async ({ interaction, client }) => {
const commandList = client.commands
.filter((command) => {
// don't include system commands
if (command.isSystemCommand) {
return false;
}
return true;
})
.map((command) => {
let params = command.data.options[0] ? `**\`${command.data.options[0].name}\`**` + ' ' : '';
let beta = command.isBeta ? `${embedOptions.icons.beta} ` : '';
let newCommand = command.isNew ? `${embedOptions.icons.new} ` : '';
return `- **\`/${command.data.name}\`** ${params}- ${beta}${newCommand}${command.data.description}`;
});
const commandListString = commandList.join('\n');
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`${embedOptions.icons.rule} **List of commands**\n` +
`${commandListString}\n\n` +
`${embedOptions.icons.support} **Support server**\nJoin the support server for help or suggestions: \n**${botOptions.serverInviteUrl}**\n\n` +
`${embedOptions.icons.bot} **Enjoying ${botOptions.name}?**\nAdd me to another server: \n**[Click me!](${botOptions.botInviteUrl})**`
)
.setColor(embedOptions.colors.info)
]
});
/*
return await interaction.editReply({
embeds: [
new EmbedBuilder()
@@ -30,5 +62,6 @@ module.exports = {
.setColor(embedOptions.colors.info)
]
});
*/
}
};
+4 -1
View File
@@ -13,10 +13,13 @@ const {
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: true,
data: new SlashCommandBuilder()
.setName('filters')
.setDescription('Toggle various audio filters during playback.')
.setDMPermission(false),
.setDMPermission(false)
.setNSFW(false),
execute: async ({ interaction }) => {
if (await notInVoiceChannel(interaction)) {
return;
+4 -3
View File
@@ -5,12 +5,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('leave')
.setDescription('Clear the track queue and remove the bot from voice channel.')
.setDMPermission(false),
// todo, allow command to be executed if bot is only member in voice channel
.setDMPermission(false)
.setNSFW(false),
execute: async ({ interaction }) => {
if (await notInVoiceChannel(interaction)) {
return;
+3
View File
@@ -6,10 +6,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: true,
data: new SlashCommandBuilder()
.setName('loop')
.setDescription('Toggle looping a track, the whole queue or autoplay.')
.setDMPermission(false)
.setNSFW(false)
.addStringOption((option) =>
option
.setName('mode')
+4 -1
View File
@@ -6,10 +6,13 @@ const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder } = r
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('nowplaying')
.setDescription('Show information about the track currently playing.')
.setDMPermission(false),
.setDMPermission(false)
.setNSFW(false),
execute: async ({ interaction }) => {
if (await notInVoiceChannel(interaction)) {
return;
+4 -1
View File
@@ -6,10 +6,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('pause')
.setDescription('Pause or resume the current track.')
.setDMPermission(false),
.setDMPermission(false)
.setNSFW(false),
execute: async ({ interaction }) => {
if (await notInVoiceChannel(interaction)) {
return;
+3
View File
@@ -7,10 +7,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useMainPlayer, useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Add a track or playlist to the queue by searching or url.')
.setDMPermission(false)
.setNSFW(false)
.addStringOption((option) =>
option
.setName('query')
+3
View File
@@ -5,10 +5,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('queue')
.setDescription('Show the list of tracks added to the queue.')
.setDMPermission(false)
.setNSFW(false)
.addNumberOption((option) => option.setName('page').setDescription('Page number of the queue').setMinValue(1)),
execute: async ({ interaction }) => {
if (await notInVoiceChannel(interaction)) {
+3
View File
@@ -6,10 +6,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('remove')
.setDescription('Remove a specific track from the queue.')
.setDMPermission(false)
.setNSFW(false)
.addNumberOption((option) =>
option
.setName('tracknumber')
+3
View File
@@ -6,10 +6,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('seek')
.setDescription('Seek to a specified duration in the current track.')
.setDMPermission(false)
.setNSFW(false)
.addStringOption((option) =>
option
.setName('duration')
+3
View File
@@ -6,10 +6,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('skip')
.setDescription('Skip current or specified track.')
.setDMPermission(false)
.setNSFW(false)
.addNumberOption((option) =>
option.setName('tracknumber').setDescription('Track number to skip to in the queue.').setMinValue(1)
),
+4 -3
View File
@@ -5,12 +5,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: true,
isBeta: false,
data: new SlashCommandBuilder()
.setName('stop')
.setDescription('Stop playing audio and clear the track queue.')
.setDMPermission(false),
// todo, allow command to be executed if bot is only member in voice channel
.setDMPermission(false)
.setNSFW(false),
execute: async ({ interaction }) => {
if (await notInVoiceChannel(interaction)) {
return;
+3
View File
@@ -6,10 +6,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { useQueue } = require('discord-player');
module.exports = {
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('volume')
.setDescription('Show or set the playback volume for tracks.')
.setDMPermission(false)
.setNSFW(false)
.addNumberOption((option) =>
option
.setName('percentage')
+4 -1
View File
@@ -5,10 +5,13 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
isSystemCommand: true,
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('guilds')
.setDescription('Show list of guilds where bot is added.')
.setDMPermission(false),
.setDMPermission(false)
.setNSFW(false),
execute: async ({ interaction, client }) => {
if (await notValidGuildId(interaction)) {
logger.debug(`[Shard ${client.shard.ids[0]}] Not a valid guild id.`);
+7 -1
View File
@@ -7,7 +7,13 @@ const { version, dependencies } = require('../../../package.json');
module.exports = {
isSystemCommand: true,
data: new SlashCommandBuilder().setName('status').setDescription('Show bot status.').setDMPermission(false),
isNew: false,
isBeta: false,
data: new SlashCommandBuilder()
.setName('status')
.setDescription('Show bot status.')
.setDMPermission(false)
.setNSFW(false),
execute: async ({ interaction, client }) => {
if (await notValidGuildId(interaction)) {
return;