{"size": 3919, "ext": "js", "max_stars_repo_path": "dist/channel/Message.js", "max_stars_repo_name": "HoloShrimp/holocord-structures", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dist/channel/Message.js", "max_issues_repo_name": "HoloShrimp/holocord-structures", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dist/channel/Message.js", "max_forks_repo_name": "HoloShrimp/holocord-structures", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 35.9541284404, "max_line_length": 95, "alphanum_fraction": 0.5667262057}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Message = void 0;
//@ts-nocheck
const dist_1 = require("holocord/dist");
const Member_1 = require("../guild/Member");
const User_1 = require("../user/User");
const Channel_1 = require("./Channel");
class Message {
    constructor(data, client) {
        this.activity = this.CamelCaseData(data.activity);
        this.application = this.CamelCaseData(data.application);
        this.applicationId = data.application_id;
        this.attachments = data.attachments;
        this.author = new User_1.User(data.author, client);
        this.channelId = data.channel_id;
        this.components = data.components;
        this.content = data.content;
        this.created = {
            at: data.timestamp,
            timestamp: new Date(data.timestamp).getTime(),
            toString: () => new Date(data.timestamp).toString(),
        };
        this.edited = {
            at: data.edited_timestamp,
            timestamp: data.edited_timestamp
                ? new Date(data.edited_timestamp).getTime()
                : null,
            toString: () => data.edited_timestamp
                ? new Date(data.edited_timestamp).toString()
                : "null",
        };
        this.embeds = data.embeds;
        this.flags = data.flags || 0;
        this.guildId = data.guild_id || client._channels?.get(this.channelId);
        this.id = data.id;
        this.interaction = data.interaction;
        this.pinned = data.pinned;
        this.reactions = data.reactions;
        if (data.guild_id) {
            this.member = data.member
                ? new Member_1.Member(data.member, client.guilds?.get(data.guild_id), client)
                : undefined;
        }
        else {
            this.member = data.member
                ? new Member_1.Member(data.member, undefined, client)
                : undefined;
        }
        this.mentions = {
            channels: data.mention_channels,
            everyone: data.mention_everyone,
            roles: data.mention_roles,
            users: data.mentions,
        };
        this.messageReference = this.CamelCaseData(data.message_reference);
        this.nonce = data.nonce;
        this.pinned = data.pinned;
        this.reactions = data.reactions;
        this.referencedMessage = data.referenced_message
            ? new Message(data.referenced_message, client)
            : data.referenced_message;
        this.stickerItems = this.CamelCaseData(data.sticker_items);
        if (data.guild_id) {
            this.thread = data.thread
                ? new Channel_1.Channel(data.thread, client.guilds?.get(data.guild_id), client)
                : undefined;
        }
        else {
            this.thread = data.thread
                ? new Channel_1.Channel(data.thread, undefined, client)
                : undefined;
        }
        this.tts = data.tts;
        this.type = dist_1.MessageType[data.type];
        this.webhookId = data.webhook_id;
        this.client = client;
        this.rawData = data;
    }
    CamelCaseData(data) {
        let a = {};
        if (data) {
            for (const key of Object.keys(data)) {
                a[dist_1.Util.ConvertSnakeToCamelCase(key)] = data[key];
            }
        }
        else {
            a = data;
        }
        return a;
    }
    get formattedType() {
        return dist_1.FormattedMessageTypes[this.rawData.type];
    }
    async getGuild() {
        return this.guildId
            ? this.client.guilds?.get(this.guildId) ||
                (await this.client.fetchGuild(this.guildId))
            : undefined;
    }
    async getChannel({ force = false, returnRaw = false, } = {}) {
        return await this.client.getChannel(this.channelId, {
            force,
            returnRaw,
        });
    }
}
exports.Message = Message;
//# sourceMappingURL=Message.js.map