decord/stable/source/modules/messages/createMessage.tsx
github-actions 57c2214117 chore: update source for stable 347.12
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4973.js (118.4 MB)
2026-09-29 21:26:22 +00:00

102 lines
4.9 KiB
TypeScript

// Module ID: 8026
// Function ID: 8027
// Name: createMessage
// Dependencies: [7867, 1386, 1372, 1074, 38, 8027, 2]
// Exports: createBotMessage, default, userRecordToServer
// Module 8026 (createMessage)
import _modDef38 from "module_38" /* 38 */;
import createNonce from "createNonce" /* 8027 */;
import ReferencedMessageStore from "ReferencedMessageStore" /* 7867 */;
import UserRecord from "UserRecord" /* 1386 */;
import UserStore from "UserStore" /* 1372 */;
require = fn;
const ReferencedMessageState = fn(7867).ReferencedMessageState;
const Constants = fn(1074);
({ MessageStates: closure_7, MessageTypes: closure_8, LOCAL_BOT_ID: closure_9, NON_USER_BOT_DISCRIMINATOR: c10, MessageFlags: closure_11 } = Constants);
const size = fn(2);
const result = size.fileFinishedImporting("modules/messages/createMessage.tsx");
export default function createMessage(tts) {
let flag = tts.tts;
({ channelId, content } = tts);
if (flag === undefined) {
flag = false;
}
let DEFAULT = tts.type;
if (DEFAULT === undefined) {
DEFAULT = constants2.DEFAULT;
}
({ messageReference, allowedMentions, author, nonce, state } = tts);
const items = [];
({ flags, poll, sharedCustomTheme, changelogId, giftingPrompt, boostingPrompt, mediaMention } = tts);
if (DEFAULT === constants2.REPLY) {
_modDef38(null != messageReference, "Replies must have a message reference");
if (null == allowedMentions) {
const messageByReference = ReferencedMessageStore.getMessageByReference(messageReference);
let state1;
if (messageByReference != null) {
state1 = messageByReference.state;
}
if (state1 === ReferencedMessageState.LOADED) {
const obj = { id: null, username: null, avatar: null, discriminator: null, bot: null, global_name: null, primary_guild: null };
({ id: obj.id, username: obj.username, avatar: obj.avatar, discriminator: obj.discriminator, bot: obj.bot, globalName: obj.global_name, primaryGuild: obj.primary_guild } = messageByReference.message.author);
items.push(obj);
}
}
}
if (null == author) {
author = UserStore.getCurrentUser();
}
let tmp8 = author;
if (author instanceof UserRecord) {
({ id: obj2.id, username: obj2.username, avatar: obj2.avatar, discriminator: obj2.discriminator, bot: obj2.bot, globalName: obj2.global_name, primaryGuild: obj2.primary_guild } = author);
tmp8 = { id: null, username: null, avatar: null, discriminator: null, bot: null, global_name: null, primary_guild: null };
const obj4 = { id: null, username: null, avatar: null, discriminator: null, bot: null, global_name: null, primary_guild: null };
}
_modDef38(null != tmp8, "createMessage: author cannot be undefined");
let nonce1 = nonce;
if (nonce == null) {
nonce1 = createNonce.createNonce();
}
const obj5 = { id: nonce1, type: DEFAULT, content, channel_id: channelId, author: tmp8, attachments: [], embeds: [], pinned: false, mentions: items, mention_channels: [], mention_roles: [], mention_everyone: false, timestamp: new Date().toISOString(), state: null, tts: null, message_reference: null, message_snapshots: null, flags: null, nonce: null, poll: null, shared_client_theme: null, changelog_id: null, gifting_prompt: null, boosting_prompt: null, media_mention: null };
if (state == null) {
state = constants.SENDING;
}
obj5.state = state;
obj5.tts = flag;
obj5.message_reference = messageReference;
obj5.message_snapshots = [];
obj5.flags = flags;
obj5.nonce = nonce;
obj5.poll = poll;
obj5.shared_client_theme = sharedCustomTheme;
obj5.changelog_id = changelogId;
obj5.gifting_prompt = giftingPrompt;
obj5.boosting_prompt = boostingPrompt;
obj5.media_mention = mediaMention;
return obj5;
};
export const userRecordToServer = function userRecordToServer(currentUser) {
return { id: currentUser.id, username: currentUser.username, avatar: currentUser.avatar, discriminator: currentUser.discriminator, bot: currentUser.bot, global_name: currentUser.globalName, primary_guild: currentUser.primaryGuild };
};
export const createBotMessage = function createBotMessage(arg0) {
({ messageId, embeds } = arg0);
({ channelId, content, loggingName } = arg0);
if (messageId == null) {
messageId = createNonce.createNonce();
}
const obj2 = { id: messageId, type: constants2.DEFAULT, flags: constants3.EPHEMERAL, content, channel_id: channelId, author: { id, username: "Clyde", discriminator, avatar: "clyde", bot: true }, attachments: [], embeds: null, pinned: false, mentions: null, mention_channels: null, mention_roles: null, mention_everyone: false, timestamp: null, state: null, tts: false, loggingName: null };
if (embeds == null) {
embeds = [];
}
obj2.embeds = embeds;
obj2.mentions = [];
obj2.mention_channels = [];
obj2.mention_roles = [];
obj2.timestamp = new Date().toISOString();
obj2.state = constants.SENT;
obj2.loggingName = loggingName;
return obj2;
};