mirror of
https://github.com/System-End/Vencord.git
synced 2026-04-19 22:05:11 +00:00
FakeNitro, ExpressionCloner: fix issues with webp emojis (#3873)
This commit is contained in:
parent
eb1edef868
commit
ed1acc3baa
3 changed files with 6 additions and 17 deletions
|
|
@ -74,7 +74,7 @@ function getGuildMaxStickerSlots(guild: Guild) {
|
|||
|
||||
function getUrl(data: Data, size: number) {
|
||||
if (data.t === "Emoji")
|
||||
return `${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${data.id}.${data.isAnimated ? "gif" : "png"}?size=${size}&lossless=true`;
|
||||
return `${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${data.id}.webp?size=${size}&lossless=true`;
|
||||
|
||||
return `${window.GLOBAL_ENV.MEDIA_PROXY_ENDPOINT}/stickers/${data.id}.${StickerExtMap[data.format_type]}?size=${size}&lossless=true`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ import { addMessagePreEditListener, addMessagePreSendListener, removeMessagePreE
|
|||
import { definePluginSettings } from "@api/Settings";
|
||||
import { ApngBlendOp, ApngDisposeOp, parseAPNG } from "@utils/apng";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getCurrentGuild, getEmojiURL } from "@utils/discord";
|
||||
import { getCurrentGuild } from "@utils/discord";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin, { OptionType, Patch } from "@utils/types";
|
||||
import type { Emoji, Message, Sticker } from "@vencord/discord-types";
|
||||
import { StickerFormatType } from "@vencord/discord-types/enums";
|
||||
import { findByCodeLazy, findByPropsLazy, proxyLazyWebpack } from "@webpack";
|
||||
import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, lodash, Parser, PermissionsBits, PermissionStore, StickersStore, UploadHandler, UserSettingsActionCreators, UserSettingsProtoStore, UserStore } from "@webpack/common";
|
||||
import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, StickersStore, UploadHandler, UserSettingsActionCreators, UserSettingsProtoStore, UserStore } from "@webpack/common";
|
||||
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
||||
import type { ReactElement, ReactNode } from "react";
|
||||
|
||||
|
|
@ -878,7 +878,7 @@ export default definePlugin({
|
|||
|
||||
const emojiString = `<${emoji.animated ? "a" : ""}:${emoji.originalName || emoji.name}:${emoji.id}>`;
|
||||
|
||||
const url = new URL(getEmojiURL(emoji.id, emoji.animated, s.emojiSize));
|
||||
const url = new URL(IconUtils.getEmojiURL({ id: emoji.id, animated: emoji.animated, size: s.emojiSize }));
|
||||
url.searchParams.set("size", s.emojiSize.toString());
|
||||
url.searchParams.set("name", emoji.name);
|
||||
|
||||
|
|
@ -911,7 +911,7 @@ export default definePlugin({
|
|||
|
||||
hasBypass = true;
|
||||
|
||||
const url = new URL(getEmojiURL(emoji.id, emoji.animated, s.emojiSize));
|
||||
const url = new URL(IconUtils.getEmojiURL({ id: emoji.id, animated: emoji.animated, size: s.emojiSize }));
|
||||
url.searchParams.set("size", s.emojiSize.toString());
|
||||
url.searchParams.set("name", emoji.name);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import type { MessageObject } from "@api/MessageEvents";
|
||||
import type { Channel, CloudUpload, Guild, GuildFeatures, Message, User } from "@vencord/discord-types";
|
||||
import { ChannelActionCreators, ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, i18n, IconUtils, InviteActions, MessageActions, RestAPI, SelectedChannelStore, SelectedGuildStore, Toasts, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
||||
import { ChannelActionCreators, ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, i18n, InviteActions, MessageActions, RestAPI, SelectedChannelStore, SelectedGuildStore, Toasts, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
||||
import { Except } from "type-fest";
|
||||
|
||||
import { copyToClipboard } from "./clipboard";
|
||||
|
|
@ -236,17 +236,6 @@ export function getUniqueUsername(user: User) {
|
|||
return user.discriminator === "0" ? user.username : user.tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for an emoji. This function always returns a gif URL for animated emojis, instead of webp
|
||||
* @param id The emoji id
|
||||
* @param animated Whether the emoji is animated
|
||||
* @param size The size for the emoji
|
||||
*/
|
||||
export function getEmojiURL(id: string, animated: boolean, size: number) {
|
||||
const url = IconUtils.getEmojiURL({ id, animated, size });
|
||||
return animated ? url.replace(".webp", ".gif") : url;
|
||||
}
|
||||
|
||||
// Discord has a similar function in their code
|
||||
export function getGuildAcronym(guild: Guild): string {
|
||||
return guild.name
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue