92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
// Metro module 4634 (f4635).
|
|
import SoundboardStore from "../../../../soundboard/SoundboardStore";
|
|
import MessageStore from "../../../../../stores/MessageStore";
|
|
import { MessageStates } from "../../../../../Constants";
|
|
import { getSoundmojiRenderingExperiment } from "../SoundmojiRenderingExperiment";
|
|
import isSoundValid from "./isSoundValid";
|
|
import getSoundFromMessage from "./getSoundFromMessage";
|
|
import getSoundString from "./getSoundString";
|
|
import { getEmojiURL } from "../../../../../utils/AvatarUtils";
|
|
export default function getSoundmojiASTFromString(a0, a1) {
|
|
let r25, guildId2, soundId;
|
|
L13: {
|
|
guildId2 = a0[1];
|
|
soundId = a0[2];
|
|
const { guildId, channelId, messageId, soundboardSounds } = a1;
|
|
const soundmojiRenderingExperiment = getSoundmojiRenderingExperiment({
|
|
location: "getSoundmojiASTFromString"
|
|
});
|
|
r25 = void 0;
|
|
if (soundmojiRenderingExperiment) {
|
|
const soundById = SoundboardStore.getSoundById(soundId);
|
|
const isSoundValid2 = isSoundValid(soundById, guildId, channelId);
|
|
if (messageId != null && channelId != null) {
|
|
const soundFromMessage = getSoundFromMessage(channelId, messageId, soundId, soundboardSounds);
|
|
r25 = soundFromMessage;
|
|
if (!isSoundValid2) {
|
|
break L13;
|
|
}
|
|
r25 = soundFromMessage;
|
|
if (soundFromMessage != null) {
|
|
break L13;
|
|
}
|
|
const state = MessageStore.getMessage(channelId, messageId)?.state;
|
|
const SENT = MessageStates.SENT;
|
|
r25 = soundFromMessage;
|
|
if (state === SENT) {
|
|
break L13;
|
|
}
|
|
r25 = soundById;
|
|
break L13;
|
|
}
|
|
r25 = isSoundValid2 ? soundById ?? void 0 : void 0;
|
|
}
|
|
}
|
|
if (r25 == null) {
|
|
return {
|
|
type: "text",
|
|
content: getSoundString(guildId2, soundId)
|
|
};
|
|
}
|
|
let content = r25?.name;
|
|
if (content == null) {
|
|
content = soundId;
|
|
}
|
|
return {
|
|
type: "soundboard",
|
|
soundId,
|
|
guildId: guildId2,
|
|
messageId: a1.messageId,
|
|
channelId: a1.channelId,
|
|
content,
|
|
emojiId: r25?.emojiId,
|
|
emojiName: r25?.emojiName,
|
|
emojiSrc: r25?.emojiId != null ? getEmojiURL({
|
|
id: r25?.emojiId,
|
|
animated: false,
|
|
size: 16
|
|
}) : void 0
|
|
};
|
|
};
|
|
export const soundmojiRawFormatRegex = /^<sound:(\d+):(\d+)>/;
|
|
export function getSoundmojiFromMessage(a0, a1, a2, a3, a4) {
|
|
if (getSoundmojiRenderingExperiment({
|
|
location: "getSoundmojiASTFromString"
|
|
})) {
|
|
const soundById = SoundboardStore.getSoundById(a3);
|
|
const isSoundValid2 = isSoundValid(soundById, a0, a1);
|
|
if (a2 != null && a1 != null) {
|
|
const soundFromMessage = getSoundFromMessage(a1, a2, a3, a4);
|
|
if (isSoundValid2 && soundFromMessage == null) {
|
|
if (MessageStore.getMessage(a1, a2)?.state !== MessageStates.SENT) {
|
|
return soundById;
|
|
}
|
|
}
|
|
return soundFromMessage;
|
|
}
|
|
if (isSoundValid2) {
|
|
return soundById ?? void 0;
|
|
}
|
|
}
|
|
}
|