mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Highly biased code review
This commit is contained in:
		
							parent
							
								
									02c18f57c7
								
							
						
					
					
						commit
						86ccb74ac2
					
				
					 8 changed files with 182 additions and 152 deletions
				
			
		|  | @ -1,31 +0,0 @@ | ||||||
| { |  | ||||||
|   "sfw": { |  | ||||||
|     "tickle": "/img/tickle", |  | ||||||
|     "slap": "/img/slap", |  | ||||||
|     "poke": "/img/poke", |  | ||||||
|     "pat": "/img/pat", |  | ||||||
|     "neko": "/img/neko", |  | ||||||
|     "meow": "/img/meow", |  | ||||||
|     "lizard": "/img/lizard", |  | ||||||
|     "kiss": "/img/kiss", |  | ||||||
|     "hug": "/img/hug", |  | ||||||
|     "foxGirl": "/img/fox_girl", |  | ||||||
|     "feed": "/img/feed", |  | ||||||
|     "cuddle": "/img/cuddle", |  | ||||||
|     "why": "/why", |  | ||||||
|     "catText": "/cat", |  | ||||||
|     "fact": "/fact", |  | ||||||
|     "nekoGif": "/img/ngif", |  | ||||||
|     "kemonomimi": "/img/kemonomimi", |  | ||||||
|     "holo": "/img/holo", |  | ||||||
|     "smug": "/img/smug", |  | ||||||
|     "baka": "/img/baka", |  | ||||||
|     "woof": "/img/woof", |  | ||||||
|     "spoiler": "/spoiler", |  | ||||||
|     "wallpaper": "/img/wallpaper", |  | ||||||
|     "goose": "/img/goose", |  | ||||||
|     "gecg": "/img/gecg", |  | ||||||
|     "avatar": "/img/avatar", |  | ||||||
|     "waifu": "/img/waifu" |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  | @ -100,24 +100,28 @@ export default new Command({ | ||||||
|             }) |             }) | ||||||
|         }), |         }), | ||||||
|         purge: new Command({ |         purge: new Command({ | ||||||
|             description: "Purges bot messages.", |             description: "Purges the bot's own messages.", | ||||||
|             permission: PERMISSIONS.BOT_SUPPORT, |             permission: PERMISSIONS.BOT_SUPPORT, | ||||||
|             async run($) { |             async run($) { | ||||||
|                 if ($.message.channel instanceof discord.DMChannel) { |                 // It's probably better to go through the bot's own messages instead of calling bulkDelete which requires MANAGE_MESSAGES.
 | ||||||
|                     return; |                 if (botHasPermission($.guild, Permissions.FLAGS.MANAGE_MESSAGES) && $.channel.type !== "dm") { | ||||||
|                 } |  | ||||||
|                     $.message.delete(); |                     $.message.delete(); | ||||||
|                     const msgs = await $.channel.messages.fetch({ |                     const msgs = await $.channel.messages.fetch({ | ||||||
|                         limit: 100 |                         limit: 100 | ||||||
|                     }); |                     }); | ||||||
|                     const travMessages = msgs.filter((m) => m.author.id === $.client.user?.id); |                     const travMessages = msgs.filter((m) => m.author.id === $.client.user?.id); | ||||||
| 
 | 
 | ||||||
|                 await $.message.channel.send(`Found ${travMessages.size} messages to delete.`).then((m) => |                     await $.channel.send(`Found ${travMessages.size} messages to delete.`).then((m) => | ||||||
|                         m.delete({ |                         m.delete({ | ||||||
|                             timeout: 5000 |                             timeout: 5000 | ||||||
|                         }) |                         }) | ||||||
|                     ); |                     ); | ||||||
|                 await $.message.channel.bulkDelete(travMessages); |                     await $.channel.bulkDelete(travMessages); | ||||||
|  |                 } else { | ||||||
|  |                     $.channel.send( | ||||||
|  |                         "This command must be executed in a guild where I have the `MANAGE_MESSAGES` permission." | ||||||
|  |                     ); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         }), |         }), | ||||||
|         clear: new Command({ |         clear: new Command({ | ||||||
|  | @ -172,7 +176,7 @@ export default new Command({ | ||||||
|             permission: PERMISSIONS.BOT_SUPPORT, |             permission: PERMISSIONS.BOT_SUPPORT, | ||||||
|             async run($) { |             async run($) { | ||||||
|                 const guildList = $.client.guilds.cache.array().map((e) => e.name); |                 const guildList = $.client.guilds.cache.array().map((e) => e.name); | ||||||
|                 $.channel.send(guildList); |                 $.channel.send(guildList, {split: true}); | ||||||
|             } |             } | ||||||
|         }), |         }), | ||||||
|         activity: new Command({ |         activity: new Command({ | ||||||
|  |  | ||||||
|  | @ -1,51 +1,58 @@ | ||||||
|  | import {User} from "discord.js"; | ||||||
| import Command from "../../core/command"; | import Command from "../../core/command"; | ||||||
|  | import {random} from "../../core/lib"; | ||||||
|  | import {parseVars} from "../../core/libd"; | ||||||
|  | 
 | ||||||
|  | const cookies = [ | ||||||
|  |     `has given %target% a chocolate chip cookie!`, | ||||||
|  |     `has given %target% a soft homemade oatmeal cookie!`, | ||||||
|  |     `has given %target% a plain, dry, old cookie. It was the last one in the bag. Gross.`, | ||||||
|  |     `gives %target% a sugar cookie. What, no frosting and sprinkles? 0/10 would not touch.`, | ||||||
|  |     `gives %target% a chocolate chip cookie. Oh wait, those are raisins. Bleck!`, | ||||||
|  |     `gives %target% an enormous cookie. Poking it gives you more cookies. Weird.`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "Why aren't you working on any projects?"`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "Give that special someone a compliment"`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "Take a risk!"`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "Go outside."`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "Don't forget to eat your veggies!"`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "Do you even lift?"`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "m808 pls"`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "If you move your hips, you'll get all the ladies."`, | ||||||
|  |     `gives %target% a fortune cookie. It reads "I love you."`, | ||||||
|  |     `gives %target% a Golden Cookie. You can't eat it because it is made of gold. Dammit.`, | ||||||
|  |     `gives %target% an Oreo cookie with a glass of milk!`, | ||||||
|  |     `gives %target% a rainbow cookie made with love :heart:`, | ||||||
|  |     `gives %target% an old cookie that was left out in the rain, it's moldy.`, | ||||||
|  |     `bakes %target% fresh cookies, it smells amazing.` | ||||||
|  | ]; | ||||||
| 
 | 
 | ||||||
| export default new Command({ | export default new Command({ | ||||||
|     description: "Gives specified user a cookie.", |     description: "Gives specified user a cookie.", | ||||||
|     usage: "['all'/@user]", |     usage: "['all'/@user]", | ||||||
|     run: ":cookie: Here's a cookie!", |     run: ":cookie: Here's a cookie!", | ||||||
|     any: new Command({ |     subcommands: { | ||||||
|  |         all: new Command({ | ||||||
|             async run($) { |             async run($) { | ||||||
|             if ($.args[0] == "all") $.channel.send(`${$.author} gave everybody a cookie!`); |                 $.channel.send(`${$.author} gave everybody a cookie!`); | ||||||
|             } |             } | ||||||
|     }), |         }) | ||||||
|  |     }, | ||||||
|     user: new Command({ |     user: new Command({ | ||||||
|         description: "User to give cookie to.", |         description: "User to give cookie to.", | ||||||
|         async run($) { |         async run($) { | ||||||
|             const sender = $.author; |             const sender = $.author; | ||||||
|             const mention = $.message.mentions.users.first(); |             const mention: User = $.args[0]; | ||||||
| 
 |  | ||||||
|             if (!mention) return; |  | ||||||
| 
 |  | ||||||
|             const cookies = [ |  | ||||||
|                 `has given <@${mention.id}> a chocolate chip cookie!`, |  | ||||||
|                 `has given <@${mention.id}> a soft homemade oatmeal cookie!`, |  | ||||||
|                 `has given <@${mention.id}> a plain, dry, old cookie. It was the last one in the bag. Gross.`, |  | ||||||
|                 `gives <@${mention.id}> a sugar cookie. What, no frosting and sprinkles? 0/10 would not touch.`, |  | ||||||
|                 `gives <@${mention.id}> a chocolate chip cookie. Oh wait, those are raisins. Bleck!`, |  | ||||||
|                 `gives <@${mention.id}> an enormous cookie. Poking it gives you more cookies. Weird.`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "Why aren't you working on any projects?"`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "Give that special someone a compliment"`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "Take a risk!"`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "Go outside."`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "Don't forget to eat your veggies!"`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "Do you even lift?"`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "m808 pls"`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "If you move your hips, you'll get all the ladies."`, |  | ||||||
|                 `gives <@${mention.id}> a fortune cookie. It reads "I love you."`, |  | ||||||
|                 `gives <@${mention.id}> a Golden Cookie. You can't eat it because it is made of gold. Dammit.`, |  | ||||||
|                 `gives <@${mention.id}> an Oreo cookie with a glass of milk!`, |  | ||||||
|                 `gives <@${mention.id}> a rainbow cookie made with love :heart:`, |  | ||||||
|                 `gives <@${mention.id}> an old cookie that was left out in the rain, it's moldy.`, |  | ||||||
|                 `bakes <@${mention.id}> fresh cookies, it smells amazing.` |  | ||||||
|             ]; |  | ||||||
| 
 | 
 | ||||||
|             if (mention.id == sender.id) { |             if (mention.id == sender.id) { | ||||||
|                 $.channel.send("You can't give yourself cookies!"); |                 $.channel.send("You can't give yourself cookies!"); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             $.channel.send(`:cookie: <@${sender.id}> ` + cookies[Math.floor(Math.random() * cookies.length)]); |             $.channel.send( | ||||||
|  |                 `:cookie: <@${sender.id}> ${parseVars(random(cookies), { | ||||||
|  |                     target: mention.toString() | ||||||
|  |                 })}` | ||||||
|  |             ); | ||||||
|         } |         } | ||||||
|     }) |     }) | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -1,15 +1,42 @@ | ||||||
| /// @ts-nocheck
 |  | ||||||
| import {URL} from "url"; | import {URL} from "url"; | ||||||
| import FileManager from "../../core/storage"; |  | ||||||
| import Command from "../../core/command"; | import Command from "../../core/command"; | ||||||
| import {getContent} from "../../core/libd"; | import {getContent} from "../../core/libd"; | ||||||
| 
 | 
 | ||||||
| const endpoints = FileManager.read("endpoints"); | const endpoints: {sfw: {[key: string]: string}} = { | ||||||
|  |     sfw: { | ||||||
|  |         tickle: "/img/tickle", | ||||||
|  |         slap: "/img/slap", | ||||||
|  |         poke: "/img/poke", | ||||||
|  |         pat: "/img/pat", | ||||||
|  |         neko: "/img/neko", | ||||||
|  |         meow: "/img/meow", | ||||||
|  |         lizard: "/img/lizard", | ||||||
|  |         kiss: "/img/kiss", | ||||||
|  |         hug: "/img/hug", | ||||||
|  |         foxGirl: "/img/fox_girl", | ||||||
|  |         feed: "/img/feed", | ||||||
|  |         cuddle: "/img/cuddle", | ||||||
|  |         why: "/why", | ||||||
|  |         catText: "/cat", | ||||||
|  |         fact: "/fact", | ||||||
|  |         nekoGif: "/img/ngif", | ||||||
|  |         kemonomimi: "/img/kemonomimi", | ||||||
|  |         holo: "/img/holo", | ||||||
|  |         smug: "/img/smug", | ||||||
|  |         baka: "/img/baka", | ||||||
|  |         woof: "/img/woof", | ||||||
|  |         spoiler: "/spoiler", | ||||||
|  |         wallpaper: "/img/wallpaper", | ||||||
|  |         goose: "/img/goose", | ||||||
|  |         gecg: "/img/gecg", | ||||||
|  |         avatar: "/img/avatar", | ||||||
|  |         waifu: "/img/waifu" | ||||||
|  |     } | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| export default new Command({ | export default new Command({ | ||||||
|     description: "Provides you with a random image with the selected argument.", |     description: "Provides you with a random image with the selected argument.", | ||||||
|     async run($) { |     async run($) { | ||||||
|         console.log(endpoints.sfw); |  | ||||||
|         $.channel.send( |         $.channel.send( | ||||||
|             `Please provide an image type. Available arguments:\n\`[${Object.keys(endpoints.sfw).join(", ")}]\`.` |             `Please provide an image type. Available arguments:\n\`[${Object.keys(endpoints.sfw).join(", ")}]\`.` | ||||||
|         ); |         ); | ||||||
|  | @ -17,10 +44,14 @@ export default new Command({ | ||||||
|     any: new Command({ |     any: new Command({ | ||||||
|         description: "Image type to send.", |         description: "Image type to send.", | ||||||
|         async run($) { |         async run($) { | ||||||
|             if (!($.args[0] in endpoints.sfw)) return $.channel.send("Couldn't find that endpoint!"); |             const arg = $.args[0]; | ||||||
| 
 | 
 | ||||||
|             let baseURL = "https://nekos.life/api/v2"; |             if (!(arg in endpoints.sfw)) { | ||||||
|             let url = new URL(`${baseURL}${endpoints.sfw[$.args[0]]}`); |                 $.channel.send("Couldn't find that endpoint!"); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             let url = new URL(`https://nekos.life/api/v2${endpoints.sfw[arg]}`); | ||||||
|             const content = await getContent(url.toString()); |             const content = await getContent(url.toString()); | ||||||
|             $.channel.send(content.url); |             $.channel.send(content.url); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -1,8 +1,6 @@ | ||||||
| import Command from "../../core/command"; | import Command from "../../core/command"; | ||||||
|  | import {random} from "../../core/lib"; | ||||||
| 
 | 
 | ||||||
| export default new Command({ |  | ||||||
|     description: "Sends random ok message.", |  | ||||||
|     async run($) { |  | ||||||
| const responses = [ | const responses = [ | ||||||
|     "boomer", |     "boomer", | ||||||
|     "zoomer", |     "zoomer", | ||||||
|  | @ -61,6 +59,9 @@ export default new Command({ | ||||||
|     "large man" |     "large man" | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
|         $.channel.send("ok " + responses[Math.floor(Math.random() * responses.length)]); | export default new Command({ | ||||||
|  |     description: "Sends random ok message.", | ||||||
|  |     async run($) { | ||||||
|  |         $.channel.send(`ok ${random(responses)}`); | ||||||
|     } |     } | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -2,14 +2,12 @@ import {MessageEmbed, version as djsversion} from "discord.js"; | ||||||
| import ms from "ms"; | import ms from "ms"; | ||||||
| import os from "os"; | import os from "os"; | ||||||
| import Command from "../core/command"; | import Command from "../core/command"; | ||||||
| import {formatBytes, trimArray} from "../core/libd"; | import {formatBytes, trimArray, getMemberByUsername} from "../core/libd"; | ||||||
| import {verificationLevels, filterLevels, regions, flags} from "../defs/info"; | import {verificationLevels, filterLevels, regions} from "../defs/info"; | ||||||
| import moment from "moment"; | import moment from "moment"; | ||||||
| import utc from "moment"; | import utc from "moment"; | ||||||
| import {Guild} from "discord.js"; | import {Guild} from "discord.js"; | ||||||
| 
 | 
 | ||||||
| const {version} = require("../../package.json"); |  | ||||||
| 
 |  | ||||||
| export default new Command({ | export default new Command({ | ||||||
|     description: "Command to provide all sorts of info about the current server, a user, etc.", |     description: "Command to provide all sorts of info about the current server, a user, etc.", | ||||||
|     run: "Please provide an argument.\nFor help, run `%prefix%help info`.", |     run: "Please provide an argument.\nFor help, run `%prefix%help info`.", | ||||||
|  | @ -30,6 +28,26 @@ export default new Command({ | ||||||
|                         }) |                         }) | ||||||
|                     ); |                     ); | ||||||
|                 } |                 } | ||||||
|  |             }), | ||||||
|  |             any: new Command({ | ||||||
|  |                 description: "Shows another user's avatar by searching their name", | ||||||
|  |                 async run($) { | ||||||
|  |                     if ($.guild) { | ||||||
|  |                         const name = $.args.join(" "); | ||||||
|  |                         const member = await getMemberByUsername($.guild, name); | ||||||
|  | 
 | ||||||
|  |                         if (member) { | ||||||
|  |                             $.channel.send( | ||||||
|  |                                 member.user.displayAvatarURL({ | ||||||
|  |                                     dynamic: true, | ||||||
|  |                                     size: 2048 | ||||||
|  |                                 }) | ||||||
|  |                             ); | ||||||
|  |                         } else { | ||||||
|  |                             $.channel.send(`No user found by the name \`${name}\`!`); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|             }) |             }) | ||||||
|         }), |         }), | ||||||
|         bot: new Command({ |         bot: new Command({ | ||||||
|  |  | ||||||
|  | @ -381,9 +381,9 @@ export function formatBytes(bytes: any) { | ||||||
|     return `${parseFloat((bytes / Math.pow(1024, i)).toFixed(2))} ${sizes[i]}`; |     return `${parseFloat((bytes / Math.pow(1024, i)).toFixed(2))} ${sizes[i]}`; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function getContent(url: any) { | export function getContent(url: string): Promise<{url: string}> { | ||||||
|     return new Promise((resolve, reject) => { |     return new Promise((resolve, reject) => { | ||||||
|         get(url, (res: {resume?: any; setEncoding?: any; on?: any; statusCode?: any}) => { |         get(url, (res) => { | ||||||
|             const {statusCode} = res; |             const {statusCode} = res; | ||||||
|             if (statusCode !== 200) { |             if (statusCode !== 200) { | ||||||
|                 res.resume(); |                 res.resume(); | ||||||
|  |  | ||||||
|  | @ -53,7 +53,7 @@ export const client = new discord.Client(); | ||||||
|             } |             } | ||||||
|         ] |         ] | ||||||
|     }, |     }, | ||||||
|     prefix: "!!", |     prefix: Config.prefix, | ||||||
|     helpCmd: "mhelp", |     helpCmd: "mhelp", | ||||||
|     admins: ["717352467280691331"] |     admins: ["717352467280691331"] | ||||||
| }); | }); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue