mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
added a limit of 2048 to the resize command so it cant cripple the bot
This commit is contained in:
parent
60fdae5df9
commit
22982b8113
1 changed files with 4 additions and 3 deletions
|
@ -1539,6 +1539,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
|||
async jumboCmd(msg: Message, args: { emoji: string }) {
|
||||
// Get emoji url
|
||||
const config = this.getConfig();
|
||||
const size = config.jumbo_size > 2048 ? 2048 : config.jumbo_size;
|
||||
const emojiRegex = new RegExp(`(<.*:).*:(\\d+)`);
|
||||
const results = emojiRegex.exec(args.emoji);
|
||||
let extention = ".png";
|
||||
|
@ -1551,7 +1552,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
|||
}
|
||||
url += `${results[2]}${extention}`;
|
||||
if (extention === ".png") {
|
||||
const image = await this.resizeBuffer(await this.getBufferFromUrl(url), config.jumbo_size, config.jumbo_size);
|
||||
const image = await this.resizeBuffer(await this.getBufferFromUrl(url), size, size);
|
||||
file = {
|
||||
name: `emoji${extention}`,
|
||||
file: image,
|
||||
|
@ -1567,11 +1568,11 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
|||
let url = CDN_URL + `/${twemoji.convert.toCodePoint(args.emoji)}.svg`;
|
||||
let image;
|
||||
try {
|
||||
image = await this.resizeBuffer(await this.getBufferFromUrl(url), config.jumbo_size, config.jumbo_size);
|
||||
image = await this.resizeBuffer(await this.getBufferFromUrl(url), size, size);
|
||||
} catch {
|
||||
if (url.toLocaleLowerCase().endsWith("fe0f.svg")) {
|
||||
url = url.slice(0, url.lastIndexOf("-fe0f")) + ".svg";
|
||||
image = await this.resizeBuffer(await this.getBufferFromUrl(url), config.jumbo_size, config.jumbo_size);
|
||||
image = await this.resizeBuffer(await this.getBufferFromUrl(url), size, size);
|
||||
}
|
||||
}
|
||||
file = {
|
||||
|
|
Loading…
Add table
Reference in a new issue