mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
wip
This commit is contained in:
parent
7195d43c74
commit
6173b085a3
26 changed files with 1112 additions and 91 deletions
68
commands/message/core/help.js
Normal file
68
commands/message/core/help.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
const { codeblock, highlight, icon } = require('../../../labscore/utils/markdown')
|
||||
const { createEmbed, formatPaginationEmbeds } = require('../../../labscore/utils/embed')
|
||||
|
||||
const { paginator } = require('../../../labscore/client');
|
||||
|
||||
function createHelpPage(context, title, contents){
|
||||
return {
|
||||
"embeds": [
|
||||
createEmbed("default", context, {
|
||||
description: `${title}\n` +
|
||||
codeblock("ansi", contents) +
|
||||
`\n${icon("question")} Use ${highlight(`${context.commandClient.prefixes.custom.first()}help <command>`)} to view more information about a command.`
|
||||
})
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// These categories will be displayed to users, add them in the correct order
|
||||
const categories = {
|
||||
"core": `${icon("house")} Core Commands`,
|
||||
"search": `${icon("search")} Search Commands`,
|
||||
"dev": `${icon("analytics")} Development`
|
||||
}
|
||||
|
||||
const reactions = {
|
||||
previousPage: "⬅️",
|
||||
nextPage: "➡️"
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
label: 'command',
|
||||
metadata: {
|
||||
description: 'Command List',
|
||||
examples: ['help ping'],
|
||||
category: 'core',
|
||||
usage: 'help [<command>]'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(args.label){
|
||||
// Detailed command view
|
||||
} else {
|
||||
// Full command list
|
||||
let commands = {
|
||||
}
|
||||
let prefix = context.commandClient.prefixes.custom.first()
|
||||
for(const c of context.commandClient.commands){
|
||||
if(!categories[c.metadata.category]) continue;
|
||||
if(!commands[c.metadata.category]) commands[c.metadata.category] = []
|
||||
commands[c.metadata.category].push(`${prefix}${c.name}`)
|
||||
}
|
||||
|
||||
let pages = []
|
||||
for(const cat of Object.keys(categories)){
|
||||
pages.push(createHelpPage(context, categories[cat], commands[cat]))
|
||||
}
|
||||
|
||||
pages = formatPaginationEmbeds(pages)
|
||||
const message = context.message
|
||||
const paging = await paginator.createReactionPaginator({
|
||||
message,
|
||||
pages,
|
||||
reactions
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue