diff --git a/backend/src/plugins/Utility.ts b/backend/src/plugins/Utility.ts index 348cb90a..ac00f9cc 100644 --- a/backend/src/plugins/Utility.ts +++ b/backend/src/plugins/Utility.ts @@ -42,6 +42,7 @@ import { successMessage, trimLines, UnknownUser, + downloadFile, } from "../utils"; import { GuildLogs } from "../data/GuildLogs"; import { LogType } from "../data/LogType"; @@ -60,7 +61,9 @@ import { ICommandDefinition } from "knub-command-manager"; import path from "path"; import escapeStringRegexp from "escape-string-regexp"; import safeRegex from "safe-regex"; +import fs from "fs"; +import { Url, URL, URLSearchParams } from "url"; const ConfigSchema = t.type({ can_roles: t.boolean, can_level: t.boolean, @@ -76,6 +79,8 @@ const ConfigSchema = t.type({ can_help: t.boolean, can_about: t.boolean, can_context: t.boolean, + can_jumbo: t.boolean, + jumbo_size: t.Integer, }); type TConfigSchema = t.TypeOf; @@ -91,6 +96,7 @@ const MEMBER_REFRESH_FREQUENCY = 10 * 60 * 1000; // How often to do a full membe const SEARCH_EXPORT_LIMIT = 1_000_000; const activeReloads: Map = new Map(); +const fsp = fs.promises; type MemberSearchParams = { query?: string; @@ -137,6 +143,8 @@ export class UtilityPlugin extends ZeppelinPlugin { can_help: false, can_about: false, can_context: false, + can_jumbo: false, + jumbo_size: 128, }, overrides: [ { @@ -152,6 +160,7 @@ export class UtilityPlugin extends ZeppelinPlugin { can_vcmove: true, can_help: true, can_context: true, + can_jumbo: true, }, }, { @@ -1426,4 +1435,44 @@ export class UtilityPlugin extends ZeppelinPlugin { msg.channel.createMessage("Reloading..."); this.knub.reloadGuild(this.guildId); } + + @d.command("jumbo", "", { + extra: { + info: { + description: "Makes an emoji jumbo", + }, + }, + }) + @d.permission("can_jumbo") + async jumboCmd(msg: Message, args: {emoji: string}){ + let config = this.getConfig(); + + //get emoji url + let emojiRegex = new RegExp(`(<.*:).*:(\\d+)`); + let results = emojiRegex.exec(args.emoji); + let url = "https://cdn.discordapp.com/emojis/"; + let name; + switch(results[1]){ + case "<:": + url += `${results[2]}.png`; + name = "emoji.png" + break; + case "