big help upgrades

- short descriptions for command list
  - argument descriptions
  - render argument list on detailed help page
This commit is contained in:
derpystuff 2022-12-06 10:26:34 +01:00
parent 5e5a738b74
commit f9c627ada1
55 changed files with 114 additions and 30 deletions

View file

@ -1,4 +1,4 @@
const { codeblock, highlight, icon, link, pill } = require('../../../labscore/utils/markdown')
const { codeblock, highlight, icon, link, pill, smallPill } = require('../../../labscore/utils/markdown')
const { createEmbed, formatPaginationEmbeds } = require('../../../labscore/utils/embed')
const { DISCORD_INVITES } = require('../../../labscore/constants')
@ -45,8 +45,24 @@ function createCommandPage(context, prefix, command){
alias += "\n"
}
let explicit = '';
if(command.metadata.explicit) explicit = `\n${icon('nsfw')} This command contains explicit content and can only be used in Age-Restricted channels. ${link("https://support.discord.com/hc/en-us/articles/115000084051-Age-Restricted-Channels-and-Content", "Learn More")}\n`
// Render argument pills if present
let args = [];
if(command.argParser.args){
for(const a of command.argParser.args){
let argument = `-${a._name} <${a._type.replace('bool','true/false')}>`
argument = pill(argument)
if(a.help) argument += ` ${a.help}`
argument += `\n ${smallPill(`default: ${a.default}`)} `
if(!a.required) argument += smallPill('optional')
args.push(argument)
}
}
let page = createEmbed("default", context, {
description: `${icon("command")} ${pill(command.name)}\n${alias}\n${command.metadata.description}`,
description: `${icon("command")} ${pill(command.name)}\n${alias}${explicit}\n${command.metadata.description}\n\n${args.join('\n\n')}`,
fields: []
})
@ -86,6 +102,7 @@ module.exports = {
label: 'command',
metadata: {
description: 'List all commands, get more information about individual commands.',
description_short: 'Display dommand list',
examples: ['help ping'],
category: 'core',
usage: 'help [<command>]'
@ -96,7 +113,10 @@ module.exports = {
let results = []
for(const c of context.commandClient.commands){
if(c.name.includes(args.command) || c.aliases.filter((f)=>{return f.includes(args.command)}).length >= 1) results.push(c)
if(c.name.includes(args.command) || c.aliases.filter((f)=>{return f.includes(args.command)}).length >= 1){
if(c.metadata.explicit && !context.channel.nsfw) continue;
results.push(c)
}
}
let pages = []
@ -109,7 +129,7 @@ module.exports = {
// Command overview
let cmds = results.map((m)=>{return m.name})
let dscs = results.map((m)=>{return m.metadata.description})
let dscs = results.map((m)=>{return m.metadata.description_short})
pages.push({embeds:[
createEmbed("default", context, {
description: `Check pages for detailed command descriptions.\n\n` + renderCommandList(cmds, dscs, 15) + `\n\n${icon("question")} Need help with something else? Contact us via our ${link(DISCORD_INVITES.support, "Support Server")}.`
@ -141,10 +161,11 @@ module.exports = {
let prefix = context.commandClient.prefixes.custom.first()
for(const c of context.commandClient.commands){
if(!categories[c.metadata.category]) continue;
if(c.metadata.explicit && !context.channel.nsfw) continue;
if(!commands[c.metadata.category]) commands[c.metadata.category] = []
if(!descriptions[c.metadata.category]) descriptions[c.metadata.category] = []
commands[c.metadata.category].push(`${c.name}`);
descriptions[c.metadata.category].push(`${c.metadata.description}`);
descriptions[c.metadata.category].push(`${c.metadata.description_short}`);
}
let pages = []

View file

@ -7,7 +7,8 @@ module.exports = {
description: 'ping!',
name: 'ping',
metadata: {
description: 'Displays information about the bots connection to discord..',
description: 'Displays information about the bots connection to discord.',
description_short: 'Bot connection details',
examples: ['ping'],
category: 'core',
usage: 'ping'

View file

@ -7,6 +7,7 @@ module.exports = {
name: 'privacy',
metadata: {
description: 'Shows the bots privacy policy.',
description_short: 'Privacy policy',
examples: ['privacy'],
category: 'core',
usage: 'privacy'

View file

@ -7,6 +7,7 @@ module.exports = {
name: 'shard',
metadata: {
description: 'Details about the bots connection to this server.',
description_short: 'Shard information',
examples: ['shard'],
category: 'core',
usage: 'shard'

View file

@ -7,6 +7,7 @@ module.exports = {
label: 'amount',
metadata: {
description: 'Remove recent command responses from chat.',
description_short: 'Undo last command',
examples: ['undo 5'],
category: 'core',
usage: 'undo [<amount (1-5)>]'

View file

@ -8,10 +8,16 @@ module.exports = {
label: 'text',
metadata: {
description: 'test',
description_short: 'Bot test',
examples: ['test'],
category: 'dev',
usage: 'test'
},
args: [
{ default: false, name: "noreply", type: "bool", help: "Should this command return the output?" },
{ default: 2, name: "jsonspacing", type: "number", help: "JSON spacing sizes" },
{ default: true, name: "async", type: "bool", help: "Compute async?" }
],
run: async (context, args) => {
if(context.user.id !== "223518178100248576") return;
let image = await getRecentImage(context, 50)

View file

@ -9,14 +9,15 @@ module.exports = {
name: "dev",
metadata: {
description: 'Evaluate code.',
description_short: 'Bot eval',
examples: ['dev console.log(\'ping\'); -async false'],
category: 'dev',
usage: 'eval <code> [-async <true|false>] [-noreply <true|false>] [-jsonspacing <integer>]'
},
args: [
{ default: false, name: "noreply", type: "bool" },
{ default: 2, name: "jsonspacing", type: "number" },
{ default: true, name: "async", type: "bool" }
{ default: false, name: "noreply", type: "bool", help: "Reply with evaluated output" },
{ default: 2, name: "jsonspacing", type: "number", help: "Spacing for formatted json" },
{ default: true, name: "async", type: "bool", help: "Async evaluation" }
],
onBefore: context => context.user.isClientOwner,
onCancel: context =>

View file

@ -5,6 +5,7 @@ module.exports = {
aliases: ["rl"],
metadata: {
description: 'Reloads commands on all shards.',
description_short: 'Bot reload',
examples: ['reload'],
category: 'dev',
usage: 'reload'

View file

@ -8,12 +8,13 @@ module.exports = {
name: "update",
metadata: {
description: 'Fetches latest bot version.',
description_short: 'Bot update',
examples: ['update'],
category: 'dev',
usage: 'update [-force true]'
},
args: [
{ default: false, name: "force", type: "bool" }
{ default: false, name: "force", type: "bool", help: "Force update" }
],
onBefore: context => context.user.isClientOwner,
onCancel: context =>

View file

@ -16,6 +16,7 @@ module.exports = {
name: "uptime",
metadata: {
description: 'Displays the bots uptime.',
description_short: 'Bot uptime',
examples: ['uptime'],
category: 'dev',
usage: 'uptime'

View file

@ -20,16 +20,17 @@ module.exports = {
name: 'art',
aliases: ['wallpaper'],
metadata: {
description: 'Creates colorful generative art created by JetBrains LIMB.',
description: 'Creates colorful generative art using JetBrains LIMB.',
description_short: 'AI wallpaper generation',
examples: ['art -type wallpaper -seed 839648 -variance 8866 -rotate 1', 'wallpaper -type phone'],
category: 'fun',
usage: `art [-type <${Object.keys(SIZES).join('|')}>] [-seed <10000-999999>] [-variance <1000-9999>] [-rotate <0-360>]`
},
args: [
{ name: 'type', default: 'wallpaper', required: false },
{ name: 'seed', default: 'rand', required: false },
{ name: 'variance', default: 'rand', required: false },
{ name: 'rotate', default: 'rand', required: false }
{ name: 'type', default: 'wallpaper', required: false, help: `Image Type \` ${Object.keys(SIZES).join(', ')} \`` },
{ name: 'seed', default: 'rand', required: false, help: "Image Seed (10000-999999)" },
{ name: 'variance', default: 'rand', required: false, help: "Variance (1000-9999)" },
{ name: 'rotate', default: 'rand', required: false, help: "Rotation amount (0-360)" }
],
run: async (context, args) => {
let response = await editOrReply(context, createEmbed("loading", context, `Generating image...`))

View file

@ -12,6 +12,7 @@ module.exports = {
label: 'text',
metadata: {
description: 'Uses InferKit to generate text from a small input snippet.',
description_short: 'AI text generation',
examples: ['complete The Fitness Gram Pacer'],
category: 'fun',
usage: 'inferkit <prompt>'

View file

@ -7,6 +7,7 @@ module.exports = {
name: 'otter',
metadata: {
description: 'Displays a random image containing otters.',
description_short: 'Otter images',
examples: ['otter'],
category: 'fun',
usage: `otter`

View file

@ -8,6 +8,7 @@ module.exports = {
name: 'labels',
metadata: {
description: 'Applies labels to an image based on its visual contents.',
description_short: 'Image content label detection',
examples: ['labels'],
category: 'utils',
usage: 'labels <attachment>'

View file

@ -8,6 +8,7 @@ module.exports = {
name: 'safetylabels',
metadata: {
description: 'Applies detection labels for potentially sensitive content of an image.',
description_short: 'Sentivite content detection labels',
examples: ['safetylabels'],
category: 'utils',
usage: 'safetylabels <attachment>'

View file

@ -9,6 +9,7 @@ module.exports = {
aliases: ['craiyon'],
metadata: {
description: 'Uses Craiyon to generate four images from a text prompt.',
description_short: 'Craiyon AI image generation',
examples: ['dalle'],
category: 'image',
usage: 'dalle <text>'

View file

@ -9,6 +9,7 @@ module.exports = {
aliases: ['dd'],
metadata: {
description: 'Processes an image with DeepAI DeepDream.',
description_short: 'DeepDream image processing',
examples: ['deepdream'],
category: 'image',
usage: 'deepdream <image>'

View file

@ -9,6 +9,7 @@ module.exports = {
aliases: ['sr'],
metadata: {
description: 'Upscales an image with SuperResolution.',
description_short: 'SuperResolution upscaling',
examples: ['superresolution'],
category: 'image',
usage: 'superresolution <image>'

View file

@ -10,6 +10,7 @@ module.exports = {
aliases: ['t2i'],
metadata: {
description: 'Generates an image with DeepAI Text2Image using a text prompt.',
description_short: 'Image from text prompt',
examples: ['text2image Mushroom'],
category: 'image',
usage: 'text2image <image>'

View file

@ -9,6 +9,7 @@ module.exports = {
aliases: ['w2x'],
metadata: {
description: 'Processes an image with Waifu2x.',
description_short: 'Waifu2x upscaling',
examples: ['waifu2x'],
category: 'image',
usage: 'waifu2x <image>'

View file

@ -11,6 +11,7 @@ module.exports = {
label: 'text',
metadata: {
description: 'Generates an animated gif with the MakeSweet billboard template.',
description_short: 'Animated billboard generation',
examples: ['billboard'],
category: 'image',
usage: 'billboard'

View file

@ -11,6 +11,7 @@ module.exports = {
label: 'text',
metadata: {
description: 'Generates an animated gif with the MakeSweet circuit board template.',
description_short: 'Animated circuit board generation',
examples: ['circuitboard'],
category: 'image',
usage: 'circuitboard'

View file

@ -11,6 +11,7 @@ module.exports = {
label: 'text',
metadata: {
description: 'Generates an animated gif with the MakeSweet flag template.',
description_short: 'Animated flag generation',
examples: ['flag'],
category: 'image',
usage: 'flag'

View file

@ -11,6 +11,7 @@ module.exports = {
label: 'text',
metadata: {
description: 'Generates an animated gif with the MakeSweet heart locket template. Accepts text as an optional input.',
description_short: 'Animated heart locket generation',
examples: ['heartlocket Big Nutty'],
category: 'image',
usage: 'heartlocket [<text>]'

View file

@ -9,13 +9,14 @@ module.exports = {
label: 'text',
metadata: {
description: 'Generates an image with a retro style.',
description_short: 'Retro-styled text',
examples: ['retro cyberspace|chaos|crazy'],
category: 'image',
usage: 'retro <line1|line2|line3> [-background <1-5>] [-style <1-4>]'
},
args: [
{default: 5, name: 'background', type: 'integer'},
{default: 4, name: 'style', type: 'integer'},
{default: 5, name: 'background', type: 'integer', help: "Background Style ` 1, 2, 3, 4, 5 `"},
{default: 4, name: 'style', type: 'integer', help: "Text Style ` 1, 2, 3, 4 `"},
],
run: async (context, args) => {
context.triggerTyping();

View file

@ -9,6 +9,7 @@ module.exports = {
label: 'text',
metadata: {
description: 'Generates an image with custom text on a yacht.',
description_short: 'Custom text on a yacht',
examples: ['yacht Im on a boat.'],
category: 'image',
usage: 'yacht <text>'

View file

@ -37,6 +37,7 @@ module.exports = {
aliases: ['ai'],
metadata: {
description: 'Displays information about a discord application.',
description_short: 'Discord application information',
examples: ['ai 682654466453012553'],
category: 'info',
usage: 'appinfo <application id>'

View file

@ -8,9 +8,10 @@ module.exports = {
aliases: ['a'],
metadata: {
description: 'Displays someones discord avatar. Accepts IDs, Mentions, or Usernames.',
description_short: 'User avatar',
examples: ['avatar labsCore'],
category: 'info',
usage: 'avatar [<id|user>]'
usage: 'avatar [<user>]'
},
run: async (context, args) => {
context.triggerTyping();

View file

@ -9,6 +9,7 @@ module.exports = {
aliases: ['guild', 'guildinfo'],
metadata: {
description: 'Displays information about the server.',
description_short: 'Server information',
examples: ['guild'],
category: 'info',
usage: 'server'

View file

@ -6,6 +6,7 @@ module.exports = {
aliases: ["guildicon","gi","si","groupicon"],
metadata: {
description: 'Displays the server icon.',
description_short: 'Server Icon',
examples: ['gi'],
category: 'info',
usage: 'guildicon'

View file

@ -9,6 +9,7 @@ module.exports = {
aliases: ['inviteinfo'],
metadata: {
description: 'Displays information about a discord invite code.',
description_short: 'Invite link information',
examples: ['invite discord-townhall'],
category: 'info',
usage: 'invite <invite code>'

View file

@ -12,9 +12,10 @@ module.exports = {
aliases: ['u', 'profile'],
metadata: {
description: 'Displays information about a discord user. Accepts IDs, Mentions and Usernames.',
description_short: 'User information',
examples: ['user labsCore'],
category: 'info',
usage: 'user [<id|user>]'
usage: 'user [<user>]'
},
run: async (context, args) => {
context.triggerTyping();

View file

@ -1,7 +1,7 @@
const { Constants } = require("detritus-client");
const Permissions = Constants.Permissions;
const { icon } = require("../../../labscore/utils/markdown");
const { icon, pill } = require("../../../labscore/utils/markdown");
// TODO: copy pasted from v1, rework this eventually
@ -9,14 +9,15 @@ module.exports = {
label: "filter",
name: "purge",
metadata: {
description: 'Removes recent messages in chat. Allows you to optionally filter by message content to remove spam.\n\n`-amount` allows you to specify how many messages should be searched (default: 20)\n`-case` specifies if the provided query should be case sensitive or not (default: true)',
description: `Removes recent messages in chat. Allows you to optionally filter by message content to remove spam.`,
description_short: 'Mass-delete recent messages',
examples: ['purge Spam -amount 25'],
category: 'mod',
usage: 'purge [<content>] [-amount <1-50>] [-case <true|false>]'
},
args: [
{default: 20, name: 'amount', type: 'integer'},
{default: true, name: 'case', type: 'bool'},
{default: 20, name: 'amount', type: 'integer', help: "Amount of messages to be checked (1-20)"},
{default: true, name: 'case', type: 'bool', help: "If provided, should the search query be case sensitive"},
],
permissionsClient: [Permissions.MANAGE_MESSAGES],
permissions: [Permissions.MANAGE_MESSAGES],

View file

@ -14,6 +14,7 @@ module.exports = {
aliases: ['aud'],
metadata: {
description: '**Audio Detection**\nUsing the audio command without replying to a message will try to identify the song in the most recent video in chat.\n\n**Music Platform Links**\n__Replying__ to a message while using this command will return a list of music platforms the provided music (link) is available on.',
description_short: 'Audio detection',
examples: ['aud'],
category: 'search',
usage: 'audio'

View file

@ -31,6 +31,7 @@ module.exports = {
aliases: ['bi', 'img2'],
metadata: {
description: 'Returns image search results from Microsoft Bing.',
description_short: 'Bing Image Search',
examples: ['bing Large Magenta Sphere'],
category: 'search',
usage: 'bing <query>'

View file

@ -27,6 +27,7 @@ module.exports = {
aliases: ['b', 'search2'],
metadata: {
description: 'Returns search results from Microsoft Bing.',
description_short: 'Bing Search',
examples: ['bing Flask'],
category: 'search',
usage: 'bing <query>'

View file

@ -31,6 +31,7 @@ module.exports = {
aliases: ['i', 'img'],
metadata: {
description: 'Returns image search results from Google.',
description_short: 'Google Image Search',
examples: ['image Large Magenta Sphere'],
category: 'search',
usage: 'image <query>'

View file

@ -28,6 +28,7 @@ module.exports = {
aliases: ['g', 'search'],
metadata: {
description: 'Returns search results from Google.',
description_short: 'Google Search',
examples: ['google Flask'],
category: 'search',
usage: 'google <query>'

View file

@ -23,6 +23,7 @@ module.exports = {
label: 'query',
metadata: {
description: 'Searches for song lyrics on Genius.',
description_short: 'Lyric/Song Search',
examples: ['lyrics desert bloom man'],
category: 'search',
usage: 'lyrics <query>'

View file

@ -48,12 +48,13 @@ module.exports = {
aliases: ['r'],
metadata: {
description: 'Returns search results from reddit. Allows global and subreddit-specific search.',
description_short: 'Reddit Search',
examples: ['reddit r/otters'],
category: 'search',
usage: 'reddit [r/<subreddit>] <query> [-type image]'
},
args: [
{ default: "all", name: "type", type: "image" }
{ default: "all", name: "type", type: "image", help: "Types of post the search query should return" }
],
run: async (context, args) => {
context.triggerTyping();

View file

@ -34,6 +34,7 @@ module.exports = {
aliases: ['reverse', 'tineye','reverseimage'],
metadata: {
description: 'Performs a reverse-image-search.',
description_short: 'Reverse Image Search',
examples: ['reverseimage'],
category: 'search',
usage: 'reverse <image>'

View file

@ -46,13 +46,15 @@ module.exports = {
label: 'query',
aliases: ['r34'],
metadata: {
description: 'Returns image search results from various rule34-focused sites.\n\nSupported Sites: `' + Object.keys(SITES).join(', ') + '`',
description: 'Returns image search results from various rule34-focused sites.',
description_short: 'Rule34 Search',
explicit: true,
examples: ['r34 sex -site rule34'],
category: 'search',
usage: 'rule34 <query> [-site <service>]'
},
args: [
{name: 'site', default: 'rule34'}
{name: 'site', default: 'rule34', type: 'string', help: `Site to search on \` ${Object.keys(SITES).join(', ')} \``}
],
run: async (context, args) => {
context.triggerTyping();

View file

@ -40,6 +40,7 @@ module.exports = {
aliases: ['urban', 'ud'],
metadata: {
description: 'Returns search results from UrbanDictionary. Might include profanity.\nProviding no search query will return random results.',
description_short: 'UrbanDictionary Search',
examples: ['ud Flask'],
category: 'search',
usage: 'urbandictionary <query>'

View file

@ -10,6 +10,7 @@ module.exports = {
label: 'query',
metadata: {
description: 'Displays information about the weather.',
description_short: 'Weather information',
examples: ['weather Berlin'],
category: 'search',
usage: 'weather <location>'

View file

@ -27,6 +27,7 @@ module.exports = {
aliases: ['wh', 'how'],
metadata: {
description: 'Returns search results from WikiHow.',
description_short: 'WikiHow Search',
examples: ['wh download'],
category: 'search',
usage: 'wikihow <query>'

View file

@ -28,6 +28,7 @@ module.exports = {
aliases: ['wa', 'wolfram-alpha'],
metadata: {
description: 'Computes a query using Wolfram|Alpha.',
description_short: 'Compute Wolfram|Alpha queries',
examples: ['wa 1+1'],
category: 'search',
usage: 'wolframalpha <query>'

View file

@ -30,6 +30,7 @@ module.exports = {
aliases: ['yt'],
metadata: {
description: 'Returns search results from YouTube.',
description_short: 'YouTube Search',
examples: ['youtube Google'],
category: 'search',
usage: 'youtube <query>'

View file

@ -38,6 +38,7 @@ module.exports = {
aliases: ['dictionary', 'dict'],
metadata: {
description: 'Returns dictionary definitions for words.',
description_short: 'Dictionary definitions.',
examples: ['dictionary Flask'],
category: 'search',
usage: 'define <query>'

View file

@ -14,12 +14,13 @@ module.exports = {
aliases: ['e', 'emote', 'enlarge', 'em', 'emojimix'],
metadata: {
description: 'Displays information about emoji. Supports regular emoji and discord emoji.\n\nUsing two emoji will mix the two emoji together.',
description_short: 'Emoji Information, Emoji Mixing',
examples: ['enlarge 😀', 'emojimix 🐱 🍞'],
category: 'utils',
usage: 'emoji <emoji> [<emoji to mix>]'
},
args: [
{name: 'type', default: 'twitter'}
{name: 'type', default: 'twitter', type: 'string', help: `Emoji platform type`}
],
run: async (context, args) => {
await context.triggerTyping()

View file

@ -9,6 +9,7 @@ module.exports = {
name: 'ocr',
metadata: {
description: 'Uses Optical Character Recognition to detect text in images.',
description_short: 'Image Text Recognition',
examples: ['ocr'],
category: 'utils',
usage: 'ocr <attachment>'

View file

@ -11,12 +11,13 @@ module.exports = {
label: 'to',
metadata: {
description: 'Uses Optical Character Recognition to translate text in an image.',
description_short: 'Image Text Translation',
examples: ['ocrtr en'],
category: 'utils',
usage: 'ocrtr <language> [-from <origin language>]'
},
args: [
{name: 'from', default: 'auto'}
{name: 'from', default: 'auto', type: 'string', help: "Language to translate from"}
],
run: async (context, args) => {
context.triggerTyping();

View file

@ -12,6 +12,7 @@ module.exports = {
aliases: ['scan'],
metadata: {
description: 'Generates a QR code. If no input is provided acts as a QR code scanner.',
description_short: 'QR Code Scanner/Creator',
examples: ['qr big nutty'],
category: 'utils',
usage: `qr <contents>`

View file

@ -17,6 +17,7 @@ module.exports = {
aliases: ['ss'],
metadata: {
description: 'Takes screenshots of a website.',
description_short: 'Screenshot websites.',
examples: ['ss google.com'],
category: 'utils',
usage: 'screenshot <url>'

View file

@ -13,13 +13,14 @@ module.exports = {
aliases: ['tr'],
metadata: {
description: 'Translates text. Supports automatic source language detection.',
description_short: 'Translates text',
examples: ['tr groß nussig -from de -to en'],
category: 'utils',
usage: `tr <text> [-to <target language>] [-from <origin language>]`
},
args: [
{name: 'to', default: 'en'},
{name: 'from', default: 'auto'}
{name: 'to', default: 'en', type: 'language', help: "Target Language"},
{name: 'from', default: 'auto', type: 'language', help: "Source Language"}
],
run: async (context, args) => {
await context.triggerTyping();

View file

@ -27,6 +27,10 @@ module.exports.pill = function(content){
return " **` " + content + " `**"
}
module.exports.smallPill = function(content){
return " ` " + content + " `"
}
module.exports.iconPill = function(icon, content){
if(!ICONS[icon]) icon = "question"
return ICONS[icon] + " **` " + content + " `**"