feat(fakeNitro): add an option to change emote sizes (#225)

closes https://github.com/Vendicated/Vencord/issues/204
This commit is contained in:
obscurity 2022-11-21 02:43:16 +00:00 committed by GitHub
parent bb14d4989d
commit 58e28b4281
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,7 +60,7 @@ migratePluginSettings("FakeNitro", "NitroBypass");
export default definePlugin({ export default definePlugin({
name: "FakeNitro", name: "FakeNitro",
authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven], authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.obscurity],
description: "Allows you to stream in nitro quality and send fake emojis/stickers.", description: "Allows you to stream in nitro quality and send fake emojis/stickers.",
dependencies: ["MessageEventsAPI"], dependencies: ["MessageEventsAPI"],
@ -125,6 +125,12 @@ export default definePlugin({
default: true, default: true,
restartNeeded: true, restartNeeded: true,
}, },
emojiSize: {
description: "Size of the emojis when sending",
type: OptionType.SLIDER,
default: 48,
markers: [32, 48, 64, 128, 160, 256, 512],
},
enableStickerBypass: { enableStickerBypass: {
description: "Allow sending fake stickers", description: "Allow sending fake stickers",
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
@ -270,7 +276,7 @@ export default definePlugin({
if (emoji.guildId === guildId && !emoji.animated) continue; if (emoji.guildId === guildId && !emoji.animated) continue;
const emojiString = `<${emoji.animated ? "a" : ""}:${emoji.originalName || emoji.name}:${emoji.id}>`; const emojiString = `<${emoji.animated ? "a" : ""}:${emoji.originalName || emoji.name}:${emoji.id}>`;
const url = emoji.url.replace(/\?size=\d+/, "?size=48"); const url = emoji.url.replace(/\?size=\d+/, `?size=${Settings.plugins.FakeNitro.emojiSize}`);
messageObj.content = messageObj.content.replace(emojiString, (match, offset, origStr) => { messageObj.content = messageObj.content.replace(emojiString, (match, offset, origStr) => {
return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`; return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`;
}); });
@ -289,7 +295,7 @@ export default definePlugin({
if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue; if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue;
if (!emoji.require_colons) continue; if (!emoji.require_colons) continue;
const url = emoji.url.replace(/\?size=\d+/, "?size=48"); const url = emoji.url.replace(/\?size=\d+/, `?size=${Settings.plugins.FakeNitro.emojiSize}`);
messageObj.content = messageObj.content.replace(emojiStr, (match, offset, origStr) => { messageObj.content = messageObj.content.replace(emojiStr, (match, offset, origStr) => {
return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`; return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`;
}); });