/[sudobot]/trunk/commands/help.js
ViewVC logotype

Annotation of /trunk/commands/help.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (hide annotations)
Mon Jul 29 17:28:13 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 14468 byte(s)
Initial release v1.0.0
1 rakin 11 const { MessageActionRow, MessageButton } = require("discord.js");
2     const MessageEmbed = require("../src/MessageEmbed");
3     const { escapeRegex } = require("../src/util");
4    
5     module.exports = {
6     version: "1.0.0-beta",
7     commands: [
8     {
9     name: 'addsnippet',
10     shortBrief: "Adds a snippet.",
11     description: null,
12     structure: "<Name> <Content>",
13     example: "`%%addsnippet roles There are 2 roles`\n`%%addsnippet roles There are 2 roles\nAdmin - Administrator\nMod - Moderator`",
14     notes: null
15     },
16     {
17     name: 'announce',
18     shortBrief: "Announce something in the given channel.",
19     description: "Announce something in the given channel. The channel should be set in the configuration.",
20     structure: "<Content>",
21     example: "`%%announce Hello there!\nWe've just finished our job!\n@everyone`",
22     notes: null
23     },
24     {
25     name: 'ban',
26     shortBrief: "Ban someone in this server.",
27     description: null,
28     structure: "<UserID|Mention> [Reason]",
29     example: "`%%ban 385753607325075320`\n`%%ban @Someone You are spamming a lot`",
30     notes: null
31     },
32     {
33     name: 'bean',
34     shortBrief: "Bean someone in this server.",
35     description: "Bean someone. It doesn't do anything except pretending.",
36     structure: "<UserID|Mention> [Reason]",
37     example: "`%%bean 385753607325075320`\n`%%bean @Someone You are spamming a lot`",
38     notes: null
39     },
40     {
41     name: 'cat',
42     shortBrief: "Get a random kitty picture.",
43     description: "Fetches a random cat picture from `thecatapi.com` API.",
44     structure: "",
45     example: "`%%cat`",
46     notes: null
47     },
48     {
49     name: 'delsnippet',
50     shortBrief: "Deletes a snippet.",
51     description: null,
52     structure: "<Name>",
53     example: "`%%delsnippet roles`",
54     notes: null
55     },
56     {
57     name: 'dog',
58     shortBrief: "Get a random doggy picture.",
59     description: "Fetches a random cat picture from `thedogapi.com` API.",
60     structure: "",
61     example: "`%%dog`",
62     notes: null
63     },
64     {
65     name: 'echo',
66     shortBrief: "Echo (re-send) a message.",
67     description: "Re-send a message from the bot.",
68     structure: "<content> [channelMention]",
69     example: "`%%echo Something\nVery Cool`\n`%%echo Something\nVery Cool #general`",
70     notes: null
71     },
72     {
73     name: 'general-role',
74     shortBrief: "Set the general role.",
75     description: null,
76     structure: "<RoleID|RoleMention>",
77     example: "`%%general-role 937923625698638`\n`%%general-role @General`",
78     notes: null
79     },
80     {
81     name: 'help',
82     shortBrief: "Show this help and exit.",
83     description: null,
84     structure: "[command]",
85     example: "`%%help`\n`%%help mute`",
86     notes: null
87     },
88     {
89     name: 'httpcat',
90     shortBrief: "Get some funny cat memes related to HTTP.",
91     description: "Get some funny cat memes related to HTTP status codes, using http.cat API.",
92     structure: "<status>",
93     example: "`%%httpcat 403`",
94     notes: null
95     },
96     {
97     name: 'httpdog',
98     shortBrief: "Get some funny dog memes related to HTTP.",
99     description: "Get some funny dog memes related to HTTP status codes, using http.dog API.",
100     structure: "<status>",
101     example: "`%%httpdog 403`",
102     notes: null
103     },
104     {
105     name: 'kick',
106     shortBrief: "Kick someone from this server.",
107     description: null,
108     structure: "<UserID|Mention> [Reason]",
109     example: "`%%kick 385753607325075320`\n`%%kick @Someone You are spamming a lot`",
110     notes: null
111     },
112     {
113     name: 'lock',
114     shortBrief: "Lock a specific channel.",
115     description: "Makes the given channel read-only for the general members. If no channel is present, the current channel will be locked.",
116     structure: "[ChannelID|ChannelMention] [...options]",
117     example: "`%%lock 385753607325075320`\n`%%lock #general`\n`%%lock`",
118     notes: null,
119     options: {
120     "--no-send": "Do not send a confirmation message to the locked channel",
121     "--everyone": "Lock the channels for @everyone rather than the general role",
122     }
123     },
124     {
125     name: 'lockall',
126     shortBrief: "Lock all the channels given in the configuration.",
127     description: "Makes the given channels read-only for the general members.",
128     structure: "[...options]",
129     example: "`%%lockall --no-send\n`%%lockall`\n`%%lockall --everyone`",
130     notes: null,
131     options: {
132     "--no-send": "Do not send a confirmation message to the locked channel",
133     "--everyone": "Lock the channels for @everyone rather than the general role",
134     }
135     },
136     {
137     name: 'mod-role',
138     shortBrief: "Set the moderator role.",
139     description: null,
140     structure: "<RoleID|RoleMention>",
141     example: "`%%mod-role 937923625698638`\n`%%mod-role @Moderator`",
142     notes: null
143     },
144     {
145     name: 'mute',
146     shortBrief: "Mute someone in this server.",
147     description: null,
148     structure: "<UserID|Mention> [-t=DURATION] [Reason]",
149     example: "`%%mute 385753607325075320`\n`%%mute @Someone You are spamming a lot`\n`%%mute @Someone -t 10m You are spamming a lot`",
150     options: {
151     "-t": "Set the mute duration"
152     },
153     notes: null
154     },
155     {
156     name: 'muted-role',
157     shortBrief: "Set the muted role.",
158     description: null,
159     structure: "<RoleID|RoleMention>",
160     example: "`%%muted-role 937923625698638`\n`%%muted-role @Muted`",
161     notes: null
162     },
163     {
164     name: 'mvsnippet',
165     shortBrief: "Rename a snippet.",
166     description: null,
167     structure: "<oldName> <newName>",
168     example: "`%%mvsnippet abc bca`",
169     notes: null
170     },
171     {
172     name: 'note',
173     shortBrief: "Take a note about an user.",
174     description: null,
175     structure: "<UserID|UserMention> <note>",
176     example: "`%%note @Someone Simple note.`",
177     notes: null
178     },
179     {
180     name: 'note',
181     shortBrief: "Take a note about an user.",
182     description: null,
183     structure: "<UserID|UserMention> <note>",
184     example: "`%%note @Someone Simple note.`",
185     notes: null
186     },
187     {
188     name: 'notedel',
189     shortBrief: "Delete a note.",
190     description: null,
191     structure: "<NoteID>",
192     example: "`%%notedel 922`",
193     notes: null
194     },
195     {
196     name: 'noteget',
197     shortBrief: "Get a note.",
198     description: null,
199     structure: "<NoteID>",
200     example: "`%%noteget 922`",
201     notes: null
202     },
203     {
204     name: 'notes',
205     shortBrief: "Get all notes for a specific user.",
206     description: null,
207     structure: "<UserID|UserMention>",
208     example: "`%%notes @Someone`",
209     notes: null
210     },
211     {
212     name: 'pixabay',
213     shortBrief: "Fetch images from Pixabay.",
214     description: "Search & fetch images from Pixabay API.\n\nAvailable Subcommands:\n\tphoto - Fetch photos only.\n\tvector - Fetch vectors only.\n\tillustration - Fetch illustrations only\n\timage - Fetch any image.",
215     structure: "<subcommand> [query]",
216     example: "`%%pixabay image`\n`%%pixabay photo birds`",
217     notes: null
218     },
219     {
220     name: 'prefix',
221     shortBrief: "Change the bot prefix.",
222     description: null,
223     structure: "<NewPrefix>",
224     example: "`%%prefix -`",
225     notes: null
226     },
227     {
228     name: 'setconfig',
229     shortBrief: "Change the bot configuration keys.",
230     description: null,
231     structure: "<key> <value>",
232     example: "`%%setconfig debug true`",
233     notes: null
234     },
235     {
236     name: 'spamfilter',
237     shortBrief: "Change the spam filter configuration keys.",
238     description: null,
239     structure: "<key> <value>",
240     example: "`%%spamfilter include #general`",
241     notes: null
242     },
243     {
244     name: 'unban',
245     shortBrief: "Unban a user from this server.",
246     description: null,
247     structure: "<UserID>",
248     example: "`%%unban 2946255269594753792`",
249     notes: null
250     },
251     {
252     name: 'unlock',
253     shortBrief: "Unock a specific channel.",
254     description: "Makes the given channel writable for the general members. If no channel is present, the current channel is unlocked.",
255     structure: "[ChannelID|ChannelMention] [...options]",
256     example: "`%%unlock 385753607325075320`\n`%%unlock #general`\n`%%unlock`",
257     notes: null,
258     options: {
259     "--no-send": "Do not send a confirmation message to the locked channel",
260     "--everyone": "Unock the channels for @everyone rather than the general role",
261     }
262     },
263     {
264     name: 'unlockall',
265     shortBrief: "Unlock all the channels given in the configuration.",
266     description: "Makes the given channels writable for the general members.",
267     structure: "[...options]",
268     example: "`%%unlockall --no-send\n`%%unlockall`\n`%%unlockall --everyone`",
269     notes: null,
270     options: {
271     "--no-send": "Do not send a confirmation message to the locked channel",
272     "--everyone": "Lock the channels for @everyone rather than the general role",
273     }
274     },
275     {
276     name: 'unmute',
277     shortBrief: "Unute someone in this server.",
278     description: null,
279     structure: "<UserID|Mention>",
280     example: "`%%unmute 385753607325075320`\n`%%unmute @Someone You are spamming a lot`",
281     notes: null
282     },
283     {
284     name: 'warn',
285     shortBrief: "Warn someone in this server.",
286     description: null,
287     structure: "<UserID|Mention> [Reason]",
288     example: "`%%warn 385753607325075320`\n`%%warn @Someone You are spamming a lot`",
289     notes: null
290     },
291     {
292     name: 'warndel',
293     shortBrief: "Delete a warning.",
294     description: null,
295     structure: "<ID>",
296     example: "`%%warndel 39`",
297     notes: null
298     },
299     {
300     name: 'warning',
301     shortBrief: "Show a warning.",
302     description: null,
303     structure: "<ID>",
304     example: "`%%warning 39`",
305     notes: null
306     },
307     {
308     name: 'warnings',
309     shortBrief: "Show all warnings.",
310     description: "Show all warnings in this server. Passing an user will only show their warnings.",
311     structure: "[UserId|Mention]",
312     example: "`%%warnings`\n`%%warnings 948489127957979253978538`",
313     notes: null
314     },
315     ],
316     async render() {
317     let string = '';
318    
319     for (let cmd of this.commands) {
320     string += `\n\n**${cmd.name}**\n${cmd.shortBrief}`;
321     }
322    
323     return string;
324     },
325     async handle(msg, cm) {
326     if (typeof cm.args[0] === 'undefined') {
327     // await msg.reply({
328     // embeds: [
329     // new MessageEmbed()
330     // .setColor('#f14a60')
331     // .setDescription(`This command requires at least one argument.`)
332     // ]
333     // });
334    
335     await msg.reply({
336     embeds: [
337     new MessageEmbed()
338     .setDescription("The command list. Run `" + app.config.get('prefix') + "help <commandName>` for more information about a specific command.\n" + await this.render())
339     .setTitle('Help')
340     ],
341     });
342    
343     return;
344     }
345    
346     const cmd = this.commands.find(c => c.name === cm.args[0]);
347    
348     if (!cmd) {
349     await msg.reply({
350     embeds: [
351     new MessageEmbed()
352     .setColor('#f14a60')
353     .setDescription(`Invalid command \`${cm.args[0]}\`.`)
354     ]
355     });
356    
357     return;
358     }
359    
360     let fields = [
361     {
362     name: "Usage",
363     value: `\`${app.config.get('prefix')}${cmd.name}\`` + (cmd.structure.trim() !== '' ? ` \`${cmd.structure}\`` : '')
364     },
365     {
366     name: 'Examples',
367     value: cmd.example.replace(/\%\%/g, app.config.get('prefix'))
368     }
369     ];
370    
371     if (cmd.options !== undefined) {
372     let str = '';
373    
374     for (let opt in cmd.options)
375     str += `\`${opt}\` - ${cmd.options[opt]}\n`;
376    
377     str = str.substring(0, str.length - 1);
378    
379     fields.push({
380     name: 'Options',
381     value: str
382     });
383     }
384    
385     if (cmd.notes !== null) {
386     fields.push({
387     name: "Notes",
388     value: cmd.notes
389     });
390     }
391    
392     await msg.reply({
393     embeds: [
394     new MessageEmbed()
395     .setTitle(`${app.config.get('prefix')}${cmd.name}`)
396     .setDescription(cmd.description !== null ? cmd.description : cmd.shortBrief)
397     .addFields(fields)
398     ]
399     });
400     }
401     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26