/[sudobot]/trunk/src/utils/Help.ts
ViewVC logotype

Diff of /trunk/src/utils/Help.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/commands/help.js revision 48 by rakin, Mon Jul 29 17:28:21 2024 UTC trunk/src/utils/help.ts revision 51 by rakin, Mon Jul 29 17:28:23 2024 UTC
# Line 1  Line 1 
1  const { MessageActionRow, MessageButton } = require("discord.js");  import { CommandHelpData } from "../types/CommandHelpData";
 const MessageEmbed = require("../src/MessageEmbed");  
 const { escapeRegex } = require("../src/util");  
2    
3  module.exports = {  export default {
4      version: "1.9.0",      version: "2.0.0-beta1",
5      commands: [      commands: <CommandHelpData[]> [
6          {          {
7              name: 'about',              name: 'about',
8              shortBrief: "Show information about the bot.",              shortBrief: "Show information about the bot.",
# Line 48  module.exports = { Line 46  module.exports = {
46          {          {
47              name: 'ban',              name: 'ban',
48              shortBrief: "Ban someone in this server.",              shortBrief: "Ban someone in this server.",
49              description: "Ban a user. `-d` is the number days old messages to  delete. It must be in range 0-7. If `-d` is passed then an argument after it is required.",              description: "Ban a user in this server.",
50              structure: "<UserID|Mention> [-d=DAYS] [Reason]",              structure: "<UserID|UserTag|Mention> [-d=DAYS] [Reason]",
51              example: "`%%ban 385753607325075320`\n`%%ban @Someone You are spamming a lot`\n`%%ban @Someone -d 5`\n`%%ban 385753607325075320 -d 5 You are spamming a lot`",              example: "`%%ban 385753607325075320`\n`%%ban @Someone You are spamming a lot`\n`%%ban @Someone -d 5`\n`%%ban 385753607325075320 -d 5 You are spamming a lot`",
52              notes: null              notes: null,
53                options: {
54                    "-d": "The number of days old messages to delete. It must be in range 0-7. An argument is required.",
55                }
56          },          },
57          {          {
58              name: 'bean',              name: 'bean',
59              shortBrief: "Bean someone in this server.",              shortBrief: "Bean someone in this server.",
60              description: "Bean someone. It doesn't do anything except pretending.",              description: "Bean someone. It doesn't do anything except pretending.",
61              structure: "<UserID|Mention> [Reason]",              structure: "<UserID|UserTag|Mention> [Reason]",
62              example: "`%%bean 385753607325075320`\n`%%bean @Someone You are spamming a lot`",              example: "`%%bean 385753607325075320`\n`%%bean @Someone You are spamming a lot`",
63              notes: null              notes: null
64          },          },
# Line 73  module.exports = { Line 74  module.exports = {
74              name: 'clear',              name: 'clear',
75              shortBrief: "Clear all messages from a user.",              shortBrief: "Clear all messages from a user.",
76              description: "Clear all messages from a user, in the current channel. This might take a while.",              description: "Clear all messages from a user, in the current channel. This might take a while.",
77              structure: "<UserID|UserMention>",              structure: "<UserID|UserTag|UserMention>",
78              example: "`%%clear 83474924191884727`\n`%%clear @Someone`",              example: "`%%clear 83474924191884727`\n`%%clear @Someone`",
79              notes: null              notes: null
80          },          },
# Line 166  module.exports = { Line 167  module.exports = {
167              notes: null              notes: null
168          },          },
169          {          {
170                name: 'joke',
171                shortBrief: "Fetch a random joke from The Joke API.",
172                description: null,
173                structure: "",
174                example: "`%%joke`",
175                notes: null
176            },
177            {
178              name: 'kick',              name: 'kick',
179              shortBrief: "Kick someone from this server.",              shortBrief: "Kick someone from this server.",
180              description: null,              description: null,
181              structure: "<UserID|Mention> [Reason]",              structure: "<UserID|UserTag|Mention> [Reason]",
182              example: "`%%kick 385753607325075320`\n`%%kick @Someone You are spamming a lot`",              example: "`%%kick 385753607325075320`\n`%%kick @Someone You are spamming a lot`",
183              notes: null              notes: null
184          },          },
# Line 207  module.exports = { Line 216  module.exports = {
216              name: 'mute',              name: 'mute',
217              shortBrief: "Mute someone in this server.",              shortBrief: "Mute someone in this server.",
218              description: null,              description: null,
219              structure: "<UserID|Mention> [-t=DURATION] [Reason]",              structure: "<UserID|UserTag|Mention> [-t=DURATION] [Reason]",
220              example: "`%%mute 385753607325075320`\n`%%mute @Someone You are spamming a lot`\n`%%mute @Someone -t 10m You are spamming a lot`",              example: "`%%mute 385753607325075320`\n`%%mute @Someone You are spamming a lot`\n`%%mute @Someone -t 10m You are spamming a lot`",
221              options: {              options: {
222                  "-t": "Set the mute duration"                  "-t": "Set the mute duration"
# Line 234  module.exports = { Line 243  module.exports = {
243              name: 'note',              name: 'note',
244              shortBrief: "Take a note about an user.",              shortBrief: "Take a note about an user.",
245              description: null,              description: null,
246              structure: "<UserID|UserMention> <note>",              structure: "<UserID|UserTag|UserMention> <note>",
247              example: "`%%note @Someone Simple note.`",              example: "`%%note @Someone Simple note.`",
248              notes: null              notes: null
249          },          },
# Line 258  module.exports = { Line 267  module.exports = {
267              name: 'notes',              name: 'notes',
268              shortBrief: "Get all notes for a specific user.",              shortBrief: "Get all notes for a specific user.",
269              description: null,              description: null,
270              structure: "<UserID|UserMention>",              structure: "<UserID|UserTag|UserMention>",
271              example: "`%%notes @Someone`",              example: "`%%notes @Someone`",
272              notes: null              notes: null
273          },          },
# Line 279  module.exports = { Line 288  module.exports = {
288              notes: null              notes: null
289          },          },
290          {          {
291                name: 'queues',
292                shortBrief: "Show a list of all queue jobs.",
293                description: null,
294                structure: "",
295                example: "`%%queues`",
296                notes: null
297            },
298            {
299              name: 'schedule',              name: 'schedule',
300              shortBrief: "Echo (re-send) a message after the given time.",              shortBrief: "Echo (re-send) a message after the given time.",
301              description: "Re-send a message from the bot automatically after the given time interval.",              description: "Re-send a message from the bot automatically after the given time interval.",
# Line 298  module.exports = { Line 315  module.exports = {
315              name: 'send',              name: 'send',
316              shortBrief: "Send a DM to a user.",              shortBrief: "Send a DM to a user.",
317              description: null,              description: null,
318              structure: "<UserID|Mention> <content>",              structure: "<UserID|UserTag|Mention> <content>",
319              example: "`%%send 278358918549759428 Hello world`\n`%%send @Someone Hello world`",              example: "`%%send 278358918549759428 Hello world`\n`%%send @Someone Hello world`",
320              notes: null              notes: null
321          },          },
# Line 353  module.exports = { Line 370  module.exports = {
370              name: 'unmute',              name: 'unmute',
371              shortBrief: "Unmute someone in this server.",              shortBrief: "Unmute someone in this server.",
372              description: null,              description: null,
373              structure: "<UserID|Mention>",              structure: "<UserID|UserTag|Mention>",
374              example: "`%%unmute 385753607325075320`\n`%%unmute @Someone You are spamming a lot`",              example: "`%%unmute 385753607325075320`\n`%%unmute @Someone You are spamming a lot`",
375              notes: null              notes: null
376          },          },
# Line 361  module.exports = { Line 378  module.exports = {
378              name: 'warn',              name: 'warn',
379              shortBrief: "Warn someone in this server.",              shortBrief: "Warn someone in this server.",
380              description: null,              description: null,
381              structure: "<UserID|Mention> [Reason]",              structure: "<UserID|UserTag|Mention> [Reason]",
382              example: "`%%warn 385753607325075320`\n`%%warn @Someone You are spamming a lot`",              example: "`%%warn 385753607325075320`\n`%%warn @Someone You are spamming a lot`",
383              notes: null              notes: null
384          },          },
# Line 385  module.exports = { Line 402  module.exports = {
402              name: 'warnings',              name: 'warnings',
403              shortBrief: "Show all warnings.",              shortBrief: "Show all warnings.",
404              description: "Show all warnings in this server. Passing an user will only show their warnings.",              description: "Show all warnings in this server. Passing an user will only show their warnings.",
405              structure: "[UserId|Mention]",              structure: "[UserId|UserTag|Mention]",
406              example: "`%%warnings`\n`%%warnings 948489127957979253978538`",              example: "`%%warnings`\n`%%warnings 948489127957979253978538`",
407              notes: null              notes: null
408          },          },
     ],  
     async render() {  
         let string = '';  
   
         for (let cmd of this.commands) {  
             string += `\n\n**${cmd.name}**\n${cmd.shortBrief}`;  
         }  
   
         return string;  
     },  
     async handle(msg, cm) {  
         if (typeof cm.args[0] === 'undefined') {  
             await msg.reply({  
                 embeds: [  
                     new MessageEmbed()  
                     .setDescription("The command list.\n\n`<...>` means required argument, `[...]` means optional argument.\n\nRun `" + app.config.get('prefix') + "help <commandName>` for more information about a specific command.\n" + await this.render())  
                     .setTitle('Help')  
                 ],  
             });  
   
             return;  
         }  
   
         const cmd = this.commands.find(c => c.name === cm.args[0]);  
   
         if (!cmd) {  
             await msg.reply({  
                 embeds: [  
                     new MessageEmbed()  
                     .setColor('#f14a60')  
                     .setDescription(`Invalid command \`${cm.args[0]}\`.`)  
                 ]  
             });  
   
             return;  
         }  
   
         let fields = [  
             {  
                 name: "Usage",  
                 value: `\`${app.config.get('prefix')}${cmd.name}\`` + (cmd.structure.trim() !== '' ? ` \`${cmd.structure}\`` : '')  
             },  
             {  
                 name: 'Examples',  
                 value: cmd.example.replace(/\%\%/g, app.config.get('prefix'))  
             }  
         ];  
   
         if (cmd.options !== undefined) {  
             let str = '';  
   
             for (let opt in cmd.options)  
                 str += `\`${opt}\` - ${cmd.options[opt]}\n`;  
   
             str = str.substring(0, str.length - 1);  
   
             fields.push({  
                 name: 'Options',  
                 value: str  
             });  
         }  
   
         if (cmd.notes !== null) {  
             fields.push({  
                 name: "Notes",  
                 value: cmd.notes  
             });  
         }  
   
         await msg.reply({  
             embeds: [  
                 new MessageEmbed()  
                 .setTitle(`${app.config.get('prefix')}${cmd.name}`)  
                 .setDescription("`<...>` means required argument, `[...]` means optional argument.\n\n" + (cmd.description !== null ? cmd.description : cmd.shortBrief))  
                 .addFields(fields)  
             ]  
         });  
     }  
 };  
409        ]
410    }

Legend:
Removed from v.48  
changed lines
  Added in v.51

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26