FakeNitro: Fix sending unavailable emotes of the current server
This commit is contained in:
parent
69b349da77
commit
b158cecd4b
2 changed files with 14 additions and 13 deletions
|
@ -25,6 +25,7 @@ import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
|
import { findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
|
||||||
import { Alerts, ChannelStore, EmojiStore, FluxDispatcher, Forms, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
import { Alerts, ChannelStore, EmojiStore, FluxDispatcher, Forms, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
||||||
|
import type { CustomEmoji } from "@webpack/types";
|
||||||
import type { Message } from "discord-types/general";
|
import type { Message } from "discord-types/general";
|
||||||
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
import { applyPalette, GIFEncoder, quantize } from "gifenc";
|
||||||
import type { ReactElement, ReactNode } from "react";
|
import type { ReactElement, ReactNode } from "react";
|
||||||
|
@ -784,6 +785,16 @@ export default definePlugin({
|
||||||
UploadHandler.promptToUpload([file], ChannelStore.getChannel(channelId), DRAFT_TYPE);
|
UploadHandler.promptToUpload([file], ChannelStore.getChannel(channelId), DRAFT_TYPE);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
canUseEmote(e: CustomEmoji, channelId: string) {
|
||||||
|
if (e.require_colons === false) return true;
|
||||||
|
if (e.available === false) return false;
|
||||||
|
|
||||||
|
if (this.canUseEmotes)
|
||||||
|
return e.guildId === this.guildId || hasExternalEmojiPerms(channelId);
|
||||||
|
else
|
||||||
|
return !e.animated && e.guildId === this.guildId;
|
||||||
|
},
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
const s = settings.store;
|
const s = settings.store;
|
||||||
|
|
||||||
|
@ -882,12 +893,8 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.enableEmojiBypass) {
|
if (s.enableEmojiBypass) {
|
||||||
const canUseEmotes = this.canUseEmotes && hasExternalEmojiPerms(channelId);
|
|
||||||
|
|
||||||
for (const emoji of messageObj.validNonShortcutEmojis) {
|
for (const emoji of messageObj.validNonShortcutEmojis) {
|
||||||
if (!emoji.require_colons) continue;
|
if (this.canUseEmote(emoji, channelId)) continue;
|
||||||
if (emoji.available !== false && canUseEmotes) continue;
|
|
||||||
if (emoji.guildId === guildId && !emoji.animated) continue;
|
|
||||||
|
|
||||||
hasBypass = true;
|
hasBypass = true;
|
||||||
|
|
||||||
|
@ -917,18 +924,12 @@ export default definePlugin({
|
||||||
this.preEdit = addPreEditListener(async (channelId, __, messageObj) => {
|
this.preEdit = addPreEditListener(async (channelId, __, messageObj) => {
|
||||||
if (!s.enableEmojiBypass) return;
|
if (!s.enableEmojiBypass) return;
|
||||||
|
|
||||||
const { guildId } = this;
|
|
||||||
|
|
||||||
let hasBypass = false;
|
let hasBypass = false;
|
||||||
|
|
||||||
const canUseEmotes = this.canUseEmotes && hasExternalEmojiPerms(channelId);
|
|
||||||
|
|
||||||
messageObj.content = messageObj.content.replace(/(?<!\\)<a?:(?:\w+):(\d+)>/ig, (emojiStr, emojiId, offset, origStr) => {
|
messageObj.content = messageObj.content.replace(/(?<!\\)<a?:(?:\w+):(\d+)>/ig, (emojiStr, emojiId, offset, origStr) => {
|
||||||
const emoji = EmojiStore.getCustomEmojiById(emojiId);
|
const emoji = EmojiStore.getCustomEmojiById(emojiId);
|
||||||
if (emoji == null) return emojiStr;
|
if (emoji == null) return emojiStr;
|
||||||
if (!emoji.require_colons) return emojiStr;
|
if (this.canUseEmote(emoji, channelId)) return emojiStr;
|
||||||
if (emoji.available !== false && canUseEmotes) return emojiStr;
|
|
||||||
if (emoji.guildId === guildId && !emoji.animated) return emojiStr;
|
|
||||||
|
|
||||||
hasBypass = true;
|
hasBypass = true;
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
},
|
},
|
||||||
kemo: {
|
kemo: {
|
||||||
name: "kemo",
|
name: "kemo",
|
||||||
id: 299693897859465228n
|
id: 715746190813298788n
|
||||||
},
|
},
|
||||||
dzshn: {
|
dzshn: {
|
||||||
name: "dzshn",
|
name: "dzshn",
|
||||||
|
|
Loading…
Reference in a new issue