mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Fixed help/thonk bugs and removed more unused vars
This commit is contained in:
		
							parent
							
								
									4241f57f46
								
							
						
					
					
						commit
						8142709581
					
				
					 5 changed files with 60 additions and 39 deletions
				
			
		|  | @ -41,7 +41,7 @@ export const AwardCommand = new NamedCommand({ | ||||||
|     aliases: ["give"], |     aliases: ["give"], | ||||||
|     run: "You need to specify a user!", |     run: "You need to specify a user!", | ||||||
|     user: new Command({ |     user: new Command({ | ||||||
|         async run({send, message, channel, guild, author, member, client, args}) { |         async run({send, author, args}) { | ||||||
|             if (author.id === "394808963356688394" || IS_DEV_MODE) { |             if (author.id === "394808963356688394" || IS_DEV_MODE) { | ||||||
|                 const target = args[0] as User; |                 const target = args[0] as User; | ||||||
|                 const user = Storage.getUser(target.id); |                 const user = Storage.getUser(target.id); | ||||||
|  | @ -53,7 +53,7 @@ export const AwardCommand = new NamedCommand({ | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|         number: new Command({ |         number: new Command({ | ||||||
|             async run({send, message, channel, guild, author, member, client, args}) { |             async run({send, author, args}) { | ||||||
|                 if (author.id === "394808963356688394" || IS_DEV_MODE) { |                 if (author.id === "394808963356688394" || IS_DEV_MODE) { | ||||||
|                     const target = args[0] as User; |                     const target = args[0] as User; | ||||||
|                     const amount = Math.floor(args[1]); |                     const amount = Math.floor(args[1]); | ||||||
|  |  | ||||||
|  | @ -49,7 +49,7 @@ export const BuyCommand = new NamedCommand({ | ||||||
|     usage: "<item>", |     usage: "<item>", | ||||||
|     run: "You need to specify an item to buy.", |     run: "You need to specify an item to buy.", | ||||||
|     any: new RestCommand({ |     any: new RestCommand({ | ||||||
|         async run({send, guild, channel, args, message, author, combined}) { |         async run({send, guild, channel, message, author, combined}) { | ||||||
|             if (isAuthorized(guild, channel)) { |             if (isAuthorized(guild, channel)) { | ||||||
|                 let found = false; |                 let found = false; | ||||||
|                 let amount = 1; // The amount the user is buying.
 |                 let amount = 1; // The amount the user is buying.
 | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ let phrase = "I have no currently set phrase!"; | ||||||
| 
 | 
 | ||||||
| export default new NamedCommand({ | export default new NamedCommand({ | ||||||
|     description: "Transforms your text into vietnamese.", |     description: "Transforms your text into vietnamese.", | ||||||
|     usage: "thonk ([text])", |     usage: "([text])", | ||||||
|     async run({send, author}) { |     async run({send, author}) { | ||||||
|         const msg = await send(transform(phrase)); |         const msg = await send(transform(phrase)); | ||||||
|         msg.createReactionCollector( |         msg.createReactionCollector( | ||||||
|  | @ -46,7 +46,8 @@ export default new NamedCommand({ | ||||||
|     }, |     }, | ||||||
|     any: new RestCommand({ |     any: new RestCommand({ | ||||||
|         async run({send, author, combined}) { |         async run({send, author, combined}) { | ||||||
|             const msg = await send(transform(combined)); |             phrase = combined; | ||||||
|  |             const msg = await send(transform(phrase)); | ||||||
|             msg.createReactionCollector( |             msg.createReactionCollector( | ||||||
|                 (reaction, user) => { |                 (reaction, user) => { | ||||||
|                     if (user.id === author.id && reaction.emoji.name === "❌") msg.delete(); |                     if (user.id === author.id && reaction.emoji.name === "❌") msg.delete(); | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ const statuses = ["online", "idle", "dnd", "invisible"]; | ||||||
| export default new NamedCommand({ | export default new NamedCommand({ | ||||||
|     description: |     description: | ||||||
|         "An all-in-one command to do admin stuff. You need to be either an admin of the server or one of the bot's mechanics to use this command.", |         "An all-in-one command to do admin stuff. You need to be either an admin of the server or one of the bot's mechanics to use this command.", | ||||||
|     async run({send, message, channel, guild, author, member, client, args}) { |     async run({send, author, member}) { | ||||||
|         const permLevel = getPermissionLevel(author, member); |         const permLevel = getPermissionLevel(author, member); | ||||||
|         return send(`${author}, your permission level is \`${getPermissionName(permLevel)}\` (${permLevel}).`); |         return send(`${author}, your permission level is \`${getPermissionName(permLevel)}\` (${permLevel}).`); | ||||||
|     }, |     }, | ||||||
|  | @ -43,7 +43,7 @@ export default new NamedCommand({ | ||||||
|                 prefix: new NamedCommand({ |                 prefix: new NamedCommand({ | ||||||
|                     description: "Set a custom prefix for your guild. Removes your custom prefix if none is provided.", |                     description: "Set a custom prefix for your guild. Removes your custom prefix if none is provided.", | ||||||
|                     usage: "(<prefix>) (<@bot>)", |                     usage: "(<prefix>) (<@bot>)", | ||||||
|                     async run({send, message, channel, guild, author, member, client, args}) { |                     async run({send, guild}) { | ||||||
|                         Storage.getGuild(guild!.id).prefix = null; |                         Storage.getGuild(guild!.id).prefix = null; | ||||||
|                         Storage.save(); |                         Storage.save(); | ||||||
|                         send( |                         send( | ||||||
|  | @ -51,14 +51,14 @@ export default new NamedCommand({ | ||||||
|                         ); |                         ); | ||||||
|                     }, |                     }, | ||||||
|                     any: new Command({ |                     any: new Command({ | ||||||
|                         async run({send, message, channel, guild, author, member, client, args}) { |                         async run({send, guild, args}) { | ||||||
|                             Storage.getGuild(guild!.id).prefix = args[0]; |                             Storage.getGuild(guild!.id).prefix = args[0]; | ||||||
|                             Storage.save(); |                             Storage.save(); | ||||||
|                             send(`The custom prefix for this guild is now \`${args[0]}\`.`); |                             send(`The custom prefix for this guild is now \`${args[0]}\`.`); | ||||||
|                         }, |                         }, | ||||||
|                         user: new Command({ |                         user: new Command({ | ||||||
|                             description: "Specifies the bot in case of conflicting prefixes.", |                             description: "Specifies the bot in case of conflicting prefixes.", | ||||||
|                             async run({send, message, channel, guild, author, member, client, args}) { |                             async run({send, guild, client, args}) { | ||||||
|                                 if ((args[1] as User).id === client.user!.id) { |                                 if ((args[1] as User).id === client.user!.id) { | ||||||
|                                     Storage.getGuild(guild!.id).prefix = args[0]; |                                     Storage.getGuild(guild!.id).prefix = args[0]; | ||||||
|                                     Storage.save(); |                                     Storage.save(); | ||||||
|  | @ -77,7 +77,7 @@ export default new NamedCommand({ | ||||||
|                             description: |                             description: | ||||||
|                                 "Sets how welcome messages are displayed for your server. Removes welcome messages if unspecified.", |                                 "Sets how welcome messages are displayed for your server. Removes welcome messages if unspecified.", | ||||||
|                             usage: "`none`/`text`/`graphical`", |                             usage: "`none`/`text`/`graphical`", | ||||||
|                             async run({send, message, channel, guild, author, member, client, args}) { |                             async run({send, guild}) { | ||||||
|                                 Storage.getGuild(guild!.id).welcomeType = "none"; |                                 Storage.getGuild(guild!.id).welcomeType = "none"; | ||||||
|                                 Storage.save(); |                                 Storage.save(); | ||||||
|                                 send("Set this server's welcome type to `none`."); |                                 send("Set this server's welcome type to `none`."); | ||||||
|  | @ -85,14 +85,14 @@ export default new NamedCommand({ | ||||||
|                             // I should probably make this a bit more dynamic... Oh well.
 |                             // I should probably make this a bit more dynamic... Oh well.
 | ||||||
|                             subcommands: { |                             subcommands: { | ||||||
|                                 text: new NamedCommand({ |                                 text: new NamedCommand({ | ||||||
|                                     async run({send, message, channel, guild, author, member, client, args}) { |                                     async run({send, guild}) { | ||||||
|                                         Storage.getGuild(guild!.id).welcomeType = "text"; |                                         Storage.getGuild(guild!.id).welcomeType = "text"; | ||||||
|                                         Storage.save(); |                                         Storage.save(); | ||||||
|                                         send("Set this server's welcome type to `text`."); |                                         send("Set this server's welcome type to `text`."); | ||||||
|                                     } |                                     } | ||||||
|                                 }), |                                 }), | ||||||
|                                 graphical: new NamedCommand({ |                                 graphical: new NamedCommand({ | ||||||
|                                     async run({send, message, channel, guild, author, member, client, args}) { |                                     async run({send, guild}) { | ||||||
|                                         Storage.getGuild(guild!.id).welcomeType = "graphical"; |                                         Storage.getGuild(guild!.id).welcomeType = "graphical"; | ||||||
|                                         Storage.save(); |                                         Storage.save(); | ||||||
|                                         send("Set this server's welcome type to `graphical`."); |                                         send("Set this server's welcome type to `graphical`."); | ||||||
|  | @ -103,14 +103,14 @@ export default new NamedCommand({ | ||||||
|                         channel: new NamedCommand({ |                         channel: new NamedCommand({ | ||||||
|                             description: "Sets the welcome channel for your server. Type `#` to reference the channel.", |                             description: "Sets the welcome channel for your server. Type `#` to reference the channel.", | ||||||
|                             usage: "(<channel mention>)", |                             usage: "(<channel mention>)", | ||||||
|                             async run({send, message, channel, guild, author, member, client, args}) { |                             async run({send, channel, guild}) { | ||||||
|                                 Storage.getGuild(guild!.id).welcomeChannel = channel.id; |                                 Storage.getGuild(guild!.id).welcomeChannel = channel.id; | ||||||
|                                 Storage.save(); |                                 Storage.save(); | ||||||
|                                 send(`Successfully set ${channel} as the welcome channel for this server.`); |                                 send(`Successfully set ${channel} as the welcome channel for this server.`); | ||||||
|                             }, |                             }, | ||||||
|                             id: "channel", |                             id: "channel", | ||||||
|                             channel: new Command({ |                             channel: new Command({ | ||||||
|                                 async run({send, message, channel, guild, author, member, client, args}) { |                                 async run({send, guild, args}) { | ||||||
|                                     const result = args[0] as TextChannel; |                                     const result = args[0] as TextChannel; | ||||||
|                                     Storage.getGuild(guild!.id).welcomeChannel = result.id; |                                     Storage.getGuild(guild!.id).welcomeChannel = result.id; | ||||||
|                                     Storage.save(); |                                     Storage.save(); | ||||||
|  | @ -122,13 +122,13 @@ export default new NamedCommand({ | ||||||
|                             description: |                             description: | ||||||
|                                 "Sets a custom welcome message for your server. Use `%user%` as the placeholder for the user.", |                                 "Sets a custom welcome message for your server. Use `%user%` as the placeholder for the user.", | ||||||
|                             usage: "(<message>)", |                             usage: "(<message>)", | ||||||
|                             async run({send, message, channel, guild, author, member, client, args}) { |                             async run({send, guild}) { | ||||||
|                                 Storage.getGuild(guild!.id).welcomeMessage = null; |                                 Storage.getGuild(guild!.id).welcomeMessage = null; | ||||||
|                                 Storage.save(); |                                 Storage.save(); | ||||||
|                                 send("Reset your server's welcome message to the default."); |                                 send("Reset your server's welcome message to the default."); | ||||||
|                             }, |                             }, | ||||||
|                             any: new RestCommand({ |                             any: new RestCommand({ | ||||||
|                                 async run({send, message, channel, guild, author, member, client, args, combined}) { |                                 async run({send, guild, combined}) { | ||||||
|                                     Storage.getGuild(guild!.id).welcomeMessage = combined; |                                     Storage.getGuild(guild!.id).welcomeMessage = combined; | ||||||
|                                     Storage.save(); |                                     Storage.save(); | ||||||
|                                     send(`Set your server's welcome message to \`${combined}\`.`); |                                     send(`Set your server's welcome message to \`${combined}\`.`); | ||||||
|  | @ -140,7 +140,7 @@ export default new NamedCommand({ | ||||||
|                 stream: new NamedCommand({ |                 stream: new NamedCommand({ | ||||||
|                     description: "Set a channel to send stream notifications. Type `#` to reference the channel.", |                     description: "Set a channel to send stream notifications. Type `#` to reference the channel.", | ||||||
|                     usage: "(<channel mention>)", |                     usage: "(<channel mention>)", | ||||||
|                     async run({send, message, channel, guild, author, member, client, args}) { |                     async run({send, channel, guild}) { | ||||||
|                         const targetGuild = Storage.getGuild(guild!.id); |                         const targetGuild = Storage.getGuild(guild!.id); | ||||||
| 
 | 
 | ||||||
|                         if (targetGuild.streamingChannel) { |                         if (targetGuild.streamingChannel) { | ||||||
|  | @ -155,7 +155,7 @@ export default new NamedCommand({ | ||||||
|                     }, |                     }, | ||||||
|                     id: "channel", |                     id: "channel", | ||||||
|                     channel: new Command({ |                     channel: new Command({ | ||||||
|                         async run({send, message, channel, guild, author, member, client, args}) { |                         async run({send, guild, args}) { | ||||||
|                             const result = args[0] as TextChannel; |                             const result = args[0] as TextChannel; | ||||||
|                             Storage.getGuild(guild!.id).streamingChannel = result.id; |                             Storage.getGuild(guild!.id).streamingChannel = result.id; | ||||||
|                             Storage.save(); |                             Storage.save(); | ||||||
|  | @ -168,12 +168,12 @@ export default new NamedCommand({ | ||||||
|         diag: new NamedCommand({ |         diag: new NamedCommand({ | ||||||
|             description: 'Requests a debug log with the "info" verbosity level.', |             description: 'Requests a debug log with the "info" verbosity level.', | ||||||
|             permission: PERMISSIONS.BOT_SUPPORT, |             permission: PERMISSIONS.BOT_SUPPORT, | ||||||
|             async run({send, message, channel, guild, author, member, client, args}) { |             async run({send}) { | ||||||
|                 send(getLogBuffer("info")); |                 send(getLogBuffer("info")); | ||||||
|             }, |             }, | ||||||
|             any: new Command({ |             any: new Command({ | ||||||
|                 description: `Select a verbosity to listen to. Available levels: \`[${Object.keys(logs).join(", ")}]\``, |                 description: `Select a verbosity to listen to. Available levels: \`[${Object.keys(logs).join(", ")}]\``, | ||||||
|                 async run({send, message, channel, guild, author, member, client, args}) { |                 async run({send, args}) { | ||||||
|                     const type = args[0]; |                     const type = args[0]; | ||||||
| 
 | 
 | ||||||
|                     if (type in logs) send(getLogBuffer(type)); |                     if (type in logs) send(getLogBuffer(type)); | ||||||
|  | @ -189,12 +189,12 @@ export default new NamedCommand({ | ||||||
|         status: new NamedCommand({ |         status: new NamedCommand({ | ||||||
|             description: "Changes the bot's status.", |             description: "Changes the bot's status.", | ||||||
|             permission: PERMISSIONS.BOT_SUPPORT, |             permission: PERMISSIONS.BOT_SUPPORT, | ||||||
|             async run({send, message, channel, guild, author, member, client, args}) { |             async run({send}) { | ||||||
|                 send("Setting status to `online`..."); |                 send("Setting status to `online`..."); | ||||||
|             }, |             }, | ||||||
|             any: new Command({ |             any: new Command({ | ||||||
|                 description: `Select a status to set to. Available statuses: \`[${statuses.join(", ")}]\`.`, |                 description: `Select a status to set to. Available statuses: \`[${statuses.join(", ")}]\`.`, | ||||||
|                 async run({send, message, channel, guild, author, member, client, args}) { |                 async run({send, client, args}) { | ||||||
|                     if (!statuses.includes(args[0])) { |                     if (!statuses.includes(args[0])) { | ||||||
|                         return send("That status doesn't exist!"); |                         return send("That status doesn't exist!"); | ||||||
|                     } else { |                     } else { | ||||||
|  | @ -208,7 +208,7 @@ export default new NamedCommand({ | ||||||
|             description: "Purges the bot's own messages.", |             description: "Purges the bot's own messages.", | ||||||
|             permission: PERMISSIONS.BOT_SUPPORT, |             permission: PERMISSIONS.BOT_SUPPORT, | ||||||
|             channelType: CHANNEL_TYPE.GUILD, |             channelType: CHANNEL_TYPE.GUILD, | ||||||
|             async run({send, message, channel, guild, author, member, client, args}) { |             async run({send, message, channel, guild, client}) { | ||||||
|                 // It's probably better to go through the bot's own messages instead of calling bulkDelete which requires MANAGE_MESSAGES.
 |                 // It's probably better to go through the bot's own messages instead of calling bulkDelete which requires MANAGE_MESSAGES.
 | ||||||
|                 if (botHasPermission(guild, Permissions.FLAGS.MANAGE_MESSAGES)) { |                 if (botHasPermission(guild, Permissions.FLAGS.MANAGE_MESSAGES)) { | ||||||
|                     message.delete(); |                     message.delete(); | ||||||
|  | @ -235,7 +235,7 @@ export default new NamedCommand({ | ||||||
|             run: "A number was not provided.", |             run: "A number was not provided.", | ||||||
|             number: new Command({ |             number: new Command({ | ||||||
|                 description: "Amount of messages to delete.", |                 description: "Amount of messages to delete.", | ||||||
|                 async run({send, message, channel, guild, author, member, client, args}) { |                 async run({message, channel, args}) { | ||||||
|                     message.delete(); |                     message.delete(); | ||||||
|                     const fetched = await channel.messages.fetch({ |                     const fetched = await channel.messages.fetch({ | ||||||
|                         limit: args[0] |                         limit: args[0] | ||||||
|  | @ -251,7 +251,7 @@ export default new NamedCommand({ | ||||||
|             run: "You have to enter some code to execute first.", |             run: "You have to enter some code to execute first.", | ||||||
|             any: new RestCommand({ |             any: new RestCommand({ | ||||||
|                 // You have to bring everything into scope to use them. AFAIK, there isn't a more maintainable way to do this, but at least TS will let you know if anything gets removed.
 |                 // You have to bring everything into scope to use them. AFAIK, there isn't a more maintainable way to do this, but at least TS will let you know if anything gets removed.
 | ||||||
|                 async run({send, message, channel, guild, author, member, client, args, combined}) { |                 async run({send, combined}) { | ||||||
|                     try { |                     try { | ||||||
|                         let evaled = eval(combined); |                         let evaled = eval(combined); | ||||||
|                         if (typeof evaled !== "string") evaled = require("util").inspect(evaled); |                         if (typeof evaled !== "string") evaled = require("util").inspect(evaled); | ||||||
|  | @ -268,7 +268,7 @@ export default new NamedCommand({ | ||||||
|             channelType: CHANNEL_TYPE.GUILD, |             channelType: CHANNEL_TYPE.GUILD, | ||||||
|             run: "You have to specify a nickname to set for the bot", |             run: "You have to specify a nickname to set for the bot", | ||||||
|             any: new RestCommand({ |             any: new RestCommand({ | ||||||
|                 async run({send, message, channel, guild, author, member, client, args, combined}) { |                 async run({send, message, guild, combined}) { | ||||||
|                     await guild!.me?.setNickname(combined); |                     await guild!.me?.setNickname(combined); | ||||||
|                     if (botHasPermission(guild, Permissions.FLAGS.MANAGE_MESSAGES)) message.delete({timeout: 5000}); |                     if (botHasPermission(guild, Permissions.FLAGS.MANAGE_MESSAGES)) message.delete({timeout: 5000}); | ||||||
|                     send(`Nickname set to \`${combined}\``).then((m) => m.delete({timeout: 5000})); |                     send(`Nickname set to \`${combined}\``).then((m) => m.delete({timeout: 5000})); | ||||||
|  | @ -278,7 +278,7 @@ export default new NamedCommand({ | ||||||
|         guilds: new NamedCommand({ |         guilds: new NamedCommand({ | ||||||
|             description: "Shows a list of all guilds the bot is a member of.", |             description: "Shows a list of all guilds the bot is a member of.", | ||||||
|             permission: PERMISSIONS.BOT_SUPPORT, |             permission: PERMISSIONS.BOT_SUPPORT, | ||||||
|             async run({send, message, channel, guild, author, member, client, args}) { |             async run({send, client}) { | ||||||
|                 const guildList = client.guilds.cache.array().map((e) => e.name); |                 const guildList = client.guilds.cache.array().map((e) => e.name); | ||||||
|                 send(guildList, {split: true}); |                 send(guildList, {split: true}); | ||||||
|             } |             } | ||||||
|  | @ -287,7 +287,7 @@ export default new NamedCommand({ | ||||||
|             description: "Set the activity of the bot.", |             description: "Set the activity of the bot.", | ||||||
|             permission: PERMISSIONS.BOT_SUPPORT, |             permission: PERMISSIONS.BOT_SUPPORT, | ||||||
|             usage: "<type> <string>", |             usage: "<type> <string>", | ||||||
|             async run({send, message, channel, guild, author, member, client, args}) { |             async run({send, client}) { | ||||||
|                 client.user?.setActivity(".help", { |                 client.user?.setActivity(".help", { | ||||||
|                     type: "LISTENING" |                     type: "LISTENING" | ||||||
|                 }); |                 }); | ||||||
|  | @ -295,7 +295,7 @@ export default new NamedCommand({ | ||||||
|             }, |             }, | ||||||
|             any: new RestCommand({ |             any: new RestCommand({ | ||||||
|                 description: `Select an activity type to set. Available levels: \`[${activities.join(", ")}]\``, |                 description: `Select an activity type to set. Available levels: \`[${activities.join(", ")}]\``, | ||||||
|                 async run({send, message, channel, guild, author, member, client, args}) { |                 async run({send, client, args}) { | ||||||
|                     const type = args[0]; |                     const type = args[0]; | ||||||
| 
 | 
 | ||||||
|                     if (activities.includes(type)) { |                     if (activities.includes(type)) { | ||||||
|  | @ -316,13 +316,13 @@ export default new NamedCommand({ | ||||||
|             description: "Sets up the current channel to receive system logs.", |             description: "Sets up the current channel to receive system logs.", | ||||||
|             permission: PERMISSIONS.BOT_ADMIN, |             permission: PERMISSIONS.BOT_ADMIN, | ||||||
|             channelType: CHANNEL_TYPE.GUILD, |             channelType: CHANNEL_TYPE.GUILD, | ||||||
|             async run({send, message, channel, guild, author, member, client, args}) { |             async run({send, channel}) { | ||||||
|                 Config.systemLogsChannel = channel.id; |                 Config.systemLogsChannel = channel.id; | ||||||
|                 Config.save(); |                 Config.save(); | ||||||
|                 send(`Successfully set ${channel} as the system logs channel.`); |                 send(`Successfully set ${channel} as the system logs channel.`); | ||||||
|             }, |             }, | ||||||
|             channel: new Command({ |             channel: new Command({ | ||||||
|                 async run({send, message, channel, guild, author, member, client, args}) { |                 async run({send, args}) { | ||||||
|                     const targetChannel = args[0] as TextChannel; |                     const targetChannel = args[0] as TextChannel; | ||||||
|                     Config.systemLogsChannel = targetChannel.id; |                     Config.systemLogsChannel = targetChannel.id; | ||||||
|                     Config.save(); |                     Config.save(); | ||||||
|  |  | ||||||
|  | @ -11,28 +11,48 @@ import {requireAllCasesHandledFor} from "../../lib"; | ||||||
| import {MessageEmbed} from "discord.js"; | import {MessageEmbed} from "discord.js"; | ||||||
| 
 | 
 | ||||||
| const EMBED_COLOR = "#158a28"; | const EMBED_COLOR = "#158a28"; | ||||||
|  | const LEGEND = "Legend: `<type>`, `[list/of/stuff]`, `(optional)`, `(<optional type>)`, `([optional/list/...])`\n"; | ||||||
| 
 | 
 | ||||||
| export default new NamedCommand({ | export default new NamedCommand({ | ||||||
|     description: "Lists all commands. If a command is specified, their arguments are listed as well.", |     description: "Lists all commands. If a command is specified, their arguments are listed as well.", | ||||||
|     usage: "([command, [subcommand/type], ...])", |     usage: "([command, [subcommand/type], ...])", | ||||||
|     aliases: ["h"], |     aliases: ["h"], | ||||||
|     async run({send, message, channel, guild, author, member, client, args}) { |     async run({send, author}) { | ||||||
|         const commands = await getCommandList(); |         const commands = await getCommandList(); | ||||||
|         const categoryArray = commands.keyArray(); |         const helpMenuPages: [string, string][] = []; // An array of (category, description) tuples.
 | ||||||
| 
 | 
 | ||||||
|         paginate(send, author.id, categoryArray.length, (page, hasMultiplePages) => { |         // Prevent the description of one category from overflowing by splitting it into multiple pages if needed.
 | ||||||
|             const category = categoryArray[page]; |         for (const category of commands.keyArray()) { | ||||||
|             const commandList = commands.get(category)!; |             const commandList = commands.get(category)!; | ||||||
|             let output = `Legend: \`<type>\`, \`[list/of/stuff]\`, \`(optional)\`, \`(<optional type>)\`, \`([optional/list/...])\`\n`; |             let output = LEGEND; | ||||||
|             for (const command of commandList) output += `\n❯ \`${command.name}\`: ${command.description}`; | 
 | ||||||
|  |             for (const command of commandList) { | ||||||
|  |                 const field = `\n❯ \`${command.name}\`: ${command.description}`.repeat(2); | ||||||
|  |                 const newOutput = output + field; | ||||||
|  | 
 | ||||||
|  |                 // Push then reset the output if it overflows, otherwise, continue as normal.
 | ||||||
|  |                 if (newOutput.length > 2048) { | ||||||
|  |                     helpMenuPages.push([category, output]); | ||||||
|  |                     output = LEGEND + field; | ||||||
|  |                 } else { | ||||||
|  |                     output = newOutput; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             // Then push whatever's remaining.
 | ||||||
|  |             helpMenuPages.push([category, output]); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         paginate(send, author.id, helpMenuPages.length, (page, hasMultiplePages) => { | ||||||
|  |             const [category, output] = helpMenuPages[page]; | ||||||
|             return new MessageEmbed() |             return new MessageEmbed() | ||||||
|                 .setTitle(hasMultiplePages ? `${category} (Page ${page + 1} of ${categoryArray.length})` : category) |                 .setTitle(hasMultiplePages ? `${category} (Page ${page + 1} of ${helpMenuPages.length})` : category) | ||||||
|                 .setDescription(output) |                 .setDescription(output) | ||||||
|                 .setColor(EMBED_COLOR); |                 .setColor(EMBED_COLOR); | ||||||
|         }); |         }); | ||||||
|     }, |     }, | ||||||
|     any: new Command({ |     any: new Command({ | ||||||
|         async run({send, message, channel, guild, author, member, client, args}) { |         async run({send, args}) { | ||||||
|             const resultingBlob = await getCommandInfo(args); |             const resultingBlob = await getCommandInfo(args); | ||||||
|             if (typeof resultingBlob === "string") return send(resultingBlob); |             if (typeof resultingBlob === "string") return send(resultingBlob); | ||||||
|             const [result, category] = resultingBlob; |             const [result, category] = resultingBlob; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue