add slash command hints to help

This commit is contained in:
bignutty 2024-07-15 20:14:00 +02:00
parent 34ba5a6e94
commit 1f6e2cd1f1
19 changed files with 63 additions and 22 deletions

View file

@ -38,7 +38,7 @@ function renderCommandList(commands, descriptions, limit) {
return render.join('\n') return render.join('\n')
} }
function createCommandPage(context, prefix, command) { function createCommandPage(context, prefix, command, slashCommands) {
alias = ' ' alias = ' '
if (command.aliases.length >= 1) { if (command.aliases.length >= 1) {
for (const al of command.aliases) alias += smallPill(al) for (const al of command.aliases) alias += smallPill(al)
@ -63,10 +63,32 @@ function createCommandPage(context, prefix, command) {
} }
let cPage = createEmbed("default", context, { let cPage = createEmbed("default", context, {
description: `${icon("slash")} ${smallPill(command.name)}\n${alias}${explicit}\n${command.metadata.description}\n\n${args.join('\n\n')}`, description: `${icon("slash")} ${smallPill(command.name)}\n${alias}${explicit}\n${command.metadata.description}`,
fields: [] fields: []
}) })
if(args.length >= 1) cPage.description += `\n\n${args.join('\n\n')}`;
// Adds the slash command hint, if available
if(command.metadata.slashCommand){
let cmd = slashCommands.filter((c)=>c.name === command.metadata.slashCommand);
if(cmd.length >= 1) {
switch(cmd[0].type){
case 1:
cPage.description += `\n\n${icon("slash")} Available via **Slash Commands**.\n-# ${icon("subtext_lightbulb")} Click on </${cmd[0].name}:${cmd[0].ids.first()}> to try it out! • ${link(context.application.oauth2UrlFormat().replace("ptb.discordapp.com","discord.com"), `Add ${context.client.user.username}`, `Add ${context.client.user.username} to use this command anywhere.`)}`
break;
case 2:
cPage.description += `\n\n${icon("slash")} Available via **Context Menu Commands**\n-# ${icon("subtext_lightbulb")} Right-Click on someone's avatar! • ${link(context.application.oauth2UrlFormat().replace("ptb.discordapp.com","discord.com"), `Add ${context.client.user.username}`, `Add ${context.client.user.username} to use this command anywhere.`)}`
break;
case 3:
cPage.description += `\n\n${icon("slash")} Available via **User Context Commands**.\n-# ${icon("subtext_lightbulb")} Right-Click on any message! • ${link(context.application.oauth2UrlFormat().replace("ptb.discordapp.com","discord.com"), `Add ${context.client.user.username}`, `Add ${context.client.user.username} to use this command anywhere.`)}`
break;
default:
break;
}
}
}
// TODO: maybe try building a little parser that highlights things via ansi // TODO: maybe try building a little parser that highlights things via ansi
if (command.metadata.usage) cPage.fields.push({ if (command.metadata.usage) cPage.fields.push({
name: `${icon("settings")} Usage`, name: `${icon("settings")} Usage`,
@ -153,7 +175,7 @@ module.exports = {
// Generate command detail pages // Generate command detail pages
for (const c of results) { for (const c of results) {
pages.push(createCommandPage(context, prefix, c)) pages.push(createCommandPage(context, prefix, c, context.interactionCommandClient.commands))
} }
await paginator.createPaginator({ await paginator.createPaginator({
@ -162,7 +184,7 @@ module.exports = {
}); });
return; return;
} else { } else {
return editOrReply(context, createCommandPage(context, prefix, results[0])) return editOrReply(context, createCommandPage(context, prefix, results[0], context.interactionCommandClient.commands))
} }
} catch (e) { } catch (e) {
console.log(e) console.log(e)

View file

@ -12,7 +12,8 @@ module.exports = {
description: 'Displays a random image containing otters.', description: 'Displays a random image containing otters.',
description_short: 'Otter images', description_short: 'Otter images',
category: 'fun', category: 'fun',
usage: `otter` usage: `otter`,
slashCommand: "otter"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.ATTACH_FILES, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.ATTACH_FILES, Permissions.READ_MESSAGE_HISTORY],
run: async (context) => { run: async (context) => {

View file

@ -15,7 +15,8 @@ module.exports = {
description: `${icon("reply")} __Replying__ to a voice message when using this command will transcribe the contents of the voice message.`, description: `${icon("reply")} __Replying__ to a voice message when using this command will transcribe the contents of the voice message.`,
description_short: 'Discord voice message transcription', description_short: 'Discord voice message transcription',
category: 'utils', category: 'utils',
usage: 'transcribe' usage: 'transcribe',
slashCommand: "Transcribe Voice Message"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY, Permissions.READ_MESSAGE_HISTORY],
run: async (context) => { run: async (context) => {

View file

@ -16,7 +16,8 @@ module.exports = {
description_short: 'Get discord user avatars', description_short: 'Get discord user avatars',
examples: ['avatar labsCore'], examples: ['avatar labsCore'],
category: 'info', category: 'info',
usage: 'avatar [<user>]' usage: 'avatar [<user>]',
slashCommmand: 'avatar'
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
run: async (context, args) => { run: async (context, args) => {

View file

@ -17,7 +17,8 @@ module.exports = {
description_short: 'Information about discord users', description_short: 'Information about discord users',
examples: ['user labsCore'], examples: ['user labsCore'],
category: 'info', category: 'info',
usage: 'user [<user>]' usage: 'user [<user>]',
slashCommand: 'user'
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
run: async (context, args) => { run: async (context, args) => {

View file

@ -18,7 +18,8 @@ module.exports = {
description: `${icon("reply")} __Replying__ to a message while using this command will return a list of music streamin platforms the provided song (link) is available on.`, description: `${icon("reply")} __Replying__ to a message while using this command will return a list of music streamin platforms the provided song (link) is available on.`,
description_short: 'Cross-platform music search', description_short: 'Cross-platform music search',
category: 'search', category: 'search',
usage: 'audio' usage: 'audio',
slashCommand: "Music Platforms"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
run: async (context) => { run: async (context) => {

View file

@ -70,7 +70,8 @@ module.exports = {
description_short: 'Search on Google', description_short: 'Search on Google',
examples: ['google Eurasian Small Clawed Otter'], examples: ['google Eurasian Small Clawed Otter'],
category: 'search', category: 'search',
usage: 'google <query>' usage: 'google <query>',
slashCommand: "google"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
run: async (context, args) => { run: async (context, args) => {

View file

@ -48,7 +48,8 @@ module.exports = {
description_short: 'Search song lyrics', description_short: 'Search song lyrics',
examples: ['lyrics desert bloom man'], examples: ['lyrics desert bloom man'],
category: 'search', category: 'search',
usage: 'lyrics <query>' usage: 'lyrics <query>',
slashCommand: "lyics"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY, Permissions.READ_MESSAGE_HISTORY],
run: async (context, args) => { run: async (context, args) => {

View file

@ -40,7 +40,8 @@ module.exports = {
description: 'Performs a reverse-image-search.', description: 'Performs a reverse-image-search.',
description_short: 'Reverse image search', description_short: 'Reverse image search',
category: 'search', category: 'search',
usage: 'reverse <image>' usage: 'reverse <image>',
slashCommand: "Reverse Image Search"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
run: async (context) => { run: async (context) => {

View file

@ -49,7 +49,8 @@ module.exports = {
description_short: 'Compute via Wolfram|Alpha', description_short: 'Compute via Wolfram|Alpha',
examples: ['wa x^2+5x+6=0', 'wa 5€ to $', 'wa 5\'11 to cm'], examples: ['wa x^2+5x+6=0', 'wa 5€ to $', 'wa 5\'11 to cm'],
category: 'search', category: 'search',
usage: 'wolframalpha <query>' usage: 'wolframalpha <query>',
slashCommand: "wolframalpha"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
run: async (context, args) => { run: async (context, args) => {

View file

@ -117,7 +117,8 @@ module.exports = {
description_short: `Search YouTube videos, channels and playlists.`, description_short: `Search YouTube videos, channels and playlists.`,
examples: ['youtube otter live cam'], examples: ['youtube otter live cam'],
category: 'search', category: 'search',
usage: 'youtube <query> [-type <category>]' usage: 'youtube <query> [-type <category>]',
slashCommand: "youtube"
}, },
args: [ args: [
{name: 'type', default: 'all', type: 'string', help: `Video Category`} {name: 'type', default: 'all', type: 'string', help: `Video Category`}

View file

@ -57,9 +57,10 @@ module.exports = {
metadata: { metadata: {
description: 'Looks up words and teminology in a dictionary.', description: 'Looks up words and teminology in a dictionary.',
description_short: 'Dictionary word definitions.', description_short: 'Dictionary word definitions.',
examples: ['dictionary Gehen -lang de'], examples: ['define Gehen -lang de'],
category: 'utils', category: 'utils',
usage: 'define <query> [-lang <language>]' usage: 'dictionary <query> [-lang <language>]',
slashCommand: "dictionary"
}, },
args: [ args: [
{name: 'lang', default: 'en', type: 'language', help: "Language to define in"}, {name: 'lang', default: 'en', type: 'language', help: "Language to define in"},

View file

@ -45,7 +45,8 @@ module.exports = {
examples: ['e 😀', 'emojimix 🐱 🍞'], examples: ['e 😀', 'emojimix 🐱 🍞'],
category: 'utils', category: 'utils',
usage: 'emoji <emoji> [<emoji to mix>]', usage: 'emoji <emoji> [<emoji to mix>]',
use_custom_ingest: true use_custom_ingest: true,
slashCommand: "emoji"
}, },
args: [ args: [
{name: 'type', default: 'twitter', type: 'string', help: `Emoji platform type`} {name: 'type', default: 'twitter', type: 'string', help: `Emoji platform type`}

View file

@ -40,7 +40,8 @@ module.exports = {
description_short: 'Detailed information about an emoji.', description_short: 'Detailed information about an emoji.',
examples: ['ei 😀'], examples: ['ei 😀'],
category: 'utils', category: 'utils',
usage: 'emojiinfo <emoji>' usage: 'emojipedia <emoji>',
slashCommand: "emojipedia"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.READ_MESSAGE_HISTORY, Permissions.USE_EXTERNAL_EMOJIS], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.READ_MESSAGE_HISTORY, Permissions.USE_EXTERNAL_EMOJIS],
run: async (context, args) => { run: async (context, args) => {

View file

@ -15,7 +15,8 @@ module.exports = {
description: `${smallIconPill("reply", "Supports Replies")}\n\nUses Optical Character Recognition to detect text in images.`, description: `${smallIconPill("reply", "Supports Replies")}\n\nUses Optical Character Recognition to detect text in images.`,
description_short: 'Image text recognition.', description_short: 'Image text recognition.',
category: 'utils', category: 'utils',
usage: 'ocr <attachment>' usage: 'ocr <attachment>',
slashCommand: "OCR"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.READ_MESSAGE_HISTORY, Permissions.USE_EXTERNAL_EMOJIS], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.READ_MESSAGE_HISTORY, Permissions.USE_EXTERNAL_EMOJIS],
run: async (context) => { run: async (context) => {

View file

@ -20,7 +20,8 @@ module.exports = {
description_short: 'Image text recognition + translation.', description_short: 'Image text recognition + translation.',
examples: ['ocrtr en -from pl'], examples: ['ocrtr en -from pl'],
category: 'utils', category: 'utils',
usage: 'ocrtr <language> [-from <origin language>]' usage: 'ocrtr <language> [-from <origin language>]',
slashCommand: "OCR Translate"
}, },
args: [ args: [
{name: 'from', default: 'auto', type: 'string', help: "Language to translate from"} {name: 'from', default: 'auto', type: 'string', help: "Language to translate from"}

View file

@ -15,7 +15,8 @@ module.exports = {
description_short: 'Screenshot websites.', description_short: 'Screenshot websites.',
examples: ['ss google.com'], examples: ['ss google.com'],
category: 'utils', category: 'utils',
usage: 'screenshot <url>' usage: 'screenshot <url>',
slashCommand: "screenshot"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.ATTACH_FILES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.ATTACH_FILES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
run: async (context, args) => { run: async (context, args) => {

View file

@ -17,7 +17,8 @@ module.exports = {
description_short: 'Local weather information', description_short: 'Local weather information',
examples: ['weather Otter, Germany'], examples: ['weather Otter, Germany'],
category: 'utils', category: 'utils',
usage: 'weather <location>' usage: 'weather <location>',
slashCommand: "weather"
}, },
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY],
run: async (context, args) => { run: async (context, args) => {

View file

@ -56,7 +56,9 @@ module.exports.BADGE_ICONS = Object.freeze({
module.exports.ICONS = Object.freeze({ module.exports.ICONS = Object.freeze({
"brand": "<:ico_brand:1237843729880977459>", "brand": "<:ico_brand:1237843729880977459>",
"flask_mini": "<:ico_flask_mini:1260342544600928286>", "flask_mini": "<:ico_flask_mini:1260342544600928286>",
"subtext_lightbulb": "<:ico_subt_lightbulb:1262470784224591934>",
"home": "<:ico_home:1165257185488551976>", "home": "<:ico_home:1165257185488551976>",
"image": "<:ico_image:1165257188235825274>", "image": "<:ico_image:1165257188235825274>",