Highly biased code review

This commit is contained in:
WatDuhHekBro 2021-03-30 18:14:15 -05:00
parent 02c18f57c7
commit 86ccb74ac2
8 changed files with 182 additions and 152 deletions

View File

@ -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"
}
}

View File

@ -100,24 +100,28 @@ export default new Command({
})
}),
purge: new Command({
description: "Purges bot messages.",
description: "Purges the bot's own messages.",
permission: PERMISSIONS.BOT_SUPPORT,
async run($) {
if ($.message.channel instanceof discord.DMChannel) {
return;
}
$.message.delete();
const msgs = await $.channel.messages.fetch({
limit: 100
});
const travMessages = msgs.filter((m) => m.author.id === $.client.user?.id);
// 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) && $.channel.type !== "dm") {
$.message.delete();
const msgs = await $.channel.messages.fetch({
limit: 100
});
const travMessages = msgs.filter((m) => m.author.id === $.client.user?.id);
await $.message.channel.send(`Found ${travMessages.size} messages to delete.`).then((m) =>
m.delete({
timeout: 5000
})
);
await $.message.channel.bulkDelete(travMessages);
await $.channel.send(`Found ${travMessages.size} messages to delete.`).then((m) =>
m.delete({
timeout: 5000
})
);
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({
@ -172,7 +176,7 @@ export default new Command({
permission: PERMISSIONS.BOT_SUPPORT,
async run($) {
const guildList = $.client.guilds.cache.array().map((e) => e.name);
$.channel.send(guildList);
$.channel.send(guildList, {split: true});
}
}),
activity: new Command({

View File

@ -1,51 +1,58 @@
import {User} from "discord.js";
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({
description: "Gives specified user a cookie.",
usage: "['all'/@user]",
run: ":cookie: Here's a cookie!",
any: new Command({
async run($) {
if ($.args[0] == "all") $.channel.send(`${$.author} gave everybody a cookie!`);
}
}),
subcommands: {
all: new Command({
async run($) {
$.channel.send(`${$.author} gave everybody a cookie!`);
}
})
},
user: new Command({
description: "User to give cookie to.",
async run($) {
const sender = $.author;
const mention = $.message.mentions.users.first();
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.`
];
const mention: User = $.args[0];
if (mention.id == sender.id) {
$.channel.send("You can't give yourself cookies!");
return;
}
$.channel.send(`:cookie: <@${sender.id}> ` + cookies[Math.floor(Math.random() * cookies.length)]);
$.channel.send(
`:cookie: <@${sender.id}> ${parseVars(random(cookies), {
target: mention.toString()
})}`
);
}
})
});

View File

@ -1,15 +1,42 @@
/// @ts-nocheck
import {URL} from "url";
import FileManager from "../../core/storage";
import Command from "../../core/command";
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({
description: "Provides you with a random image with the selected argument.",
async run($) {
console.log(endpoints.sfw);
$.channel.send(
`Please provide an image type. Available arguments:\n\`[${Object.keys(endpoints.sfw).join(", ")}]\`.`
);
@ -17,10 +44,14 @@ export default new Command({
any: new Command({
description: "Image type to send.",
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";
let url = new URL(`${baseURL}${endpoints.sfw[$.args[0]]}`);
if (!(arg in endpoints.sfw)) {
$.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());
$.channel.send(content.url);
}

View File

@ -1,66 +1,67 @@
import Command from "../../core/command";
import {random} from "../../core/lib";
const responses = [
"boomer",
"zoomer",
"the last generationer",
"the last airbender",
"fire nation",
"fire lord",
"guy fieri",
"guy from final fight",
"haggar",
"Max Thunder from Streets of Rage 2",
"police guy who fires bazookas",
"Mr. X",
"Leon Its Wrong If Its Not Ada Wong S. Kennedy.",
"Jill",
"JFK",
"george bush",
"obama",
"the world",
"copy of scott pilgrim vs the world",
"ok",
"ko",
"Hot Daddy Venomous",
"big daddy",
"John Cena",
"BubbleSpurJarJarBinks",
"T-Series",
"pewdiepie",
"markiplier",
"jacksepticeye",
"vanossgaming",
"miniladd",
"Traves",
"Wilbur Soot",
"sootrhianna",
"person with tiny ears",
"anti-rabbit",
"homo sapiens",
"homo",
"cute kitty",
"ugly kitty",
"sadness",
"doomer",
"gloomer",
"bloomer",
"edgelord",
"weeb",
"m'lady",
"Mr. Crabs",
"hand",
"lahoma",
"big man",
"fox",
"pear",
"cat",
"large man"
];
export default new Command({
description: "Sends random ok message.",
async run($) {
const responses = [
"boomer",
"zoomer",
"the last generationer",
"the last airbender",
"fire nation",
"fire lord",
"guy fieri",
"guy from final fight",
"haggar",
"Max Thunder from Streets of Rage 2",
"police guy who fires bazookas",
"Mr. X",
"Leon Its Wrong If Its Not Ada Wong S. Kennedy.",
"Jill",
"JFK",
"george bush",
"obama",
"the world",
"copy of scott pilgrim vs the world",
"ok",
"ko",
"Hot Daddy Venomous",
"big daddy",
"John Cena",
"BubbleSpurJarJarBinks",
"T-Series",
"pewdiepie",
"markiplier",
"jacksepticeye",
"vanossgaming",
"miniladd",
"Traves",
"Wilbur Soot",
"sootrhianna",
"person with tiny ears",
"anti-rabbit",
"homo sapiens",
"homo",
"cute kitty",
"ugly kitty",
"sadness",
"doomer",
"gloomer",
"bloomer",
"edgelord",
"weeb",
"m'lady",
"Mr. Crabs",
"hand",
"lahoma",
"big man",
"fox",
"pear",
"cat",
"large man"
];
$.channel.send("ok " + responses[Math.floor(Math.random() * responses.length)]);
$.channel.send(`ok ${random(responses)}`);
}
});

View File

@ -2,14 +2,12 @@ import {MessageEmbed, version as djsversion} from "discord.js";
import ms from "ms";
import os from "os";
import Command from "../core/command";
import {formatBytes, trimArray} from "../core/libd";
import {verificationLevels, filterLevels, regions, flags} from "../defs/info";
import {formatBytes, trimArray, getMemberByUsername} from "../core/libd";
import {verificationLevels, filterLevels, regions} from "../defs/info";
import moment from "moment";
import utc from "moment";
import {Guild} from "discord.js";
const {version} = require("../../package.json");
export default new Command({
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`.",
@ -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({

View File

@ -381,9 +381,9 @@ export function formatBytes(bytes: any) {
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) => {
get(url, (res: {resume?: any; setEncoding?: any; on?: any; statusCode?: any}) => {
get(url, (res) => {
const {statusCode} = res;
if (statusCode !== 200) {
res.resume();

View File

@ -53,7 +53,7 @@ export const client = new discord.Client();
}
]
},
prefix: "!!",
prefix: Config.prefix,
helpCmd: "mhelp",
admins: ["717352467280691331"]
});