UNPKG

guilded.ts

Version:

A powerful NPM module that allows you to easily interact with the Guilded API.

84 lines 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MessageReaction = void 0; const Base_1 = require("../Base"); /** * Represents a message reaction on Guilded. * @example new MessageReaction(message, rawReaction); */ class MessageReaction extends Base_1.Base { message; raw; /** The ID of the channel the message belongs to. */ channelId; /** The ID of the message. */ messageId; /** The ID of the user that created the reaction. */ createdBy; /** The emote of the reaction. */ emote; /** * @param message The message the reaction belongs to. * @param raw The raw data of the reaction. * @param cache Whether to cache the reaction. */ constructor(message, raw, cache = message.channel.client.options.cacheMessageReactions ?? true) { super(message.client, raw.emote.id); this.message = message; this.raw = raw; this.channelId = raw.channelId; this.messageId = raw.messageId; this.createdBy = raw.createdBy; this.emote = raw.emote; if (cache) message.reactions.cache.set(this.id, this); } /** Whether the reaction is cached. */ get isCached() { return this.message.reactions.cache.has(this.id); } /** The channel the message belongs to. */ get channel() { return this.message.channel; } /** The ID of the server the message belongs to. */ get serverId() { return this.message.serverId; } /** The server the message belongs to. */ get server() { return this.message.server; } /** The server member that created the reaction. */ get author() { return this.server?.members.cache.get(this.createdBy); } /** * Fetch the server the message belongs to. * @param options The options to fetch the server with. * @returns The fetched server. * @example reaction.fetchServer(); */ fetchServer(options) { return this.message.fetchServer(options); } /** * Fetch the server member that created the reaction. * @param options The options to fetch the server member with. * @returns The fetched server member. * @example reaction.fetchAuthor(); */ async fetchAuthor(options) { const server = await this.fetchServer(); return server.members.fetch(this.createdBy, options); } /** * Remove the reaction from the message. * @example reaction.remove(); */ remove() { return this.message.reactions.remove(this.id); } } exports.MessageReaction = MessageReaction; //# sourceMappingURL=MessageReaction.js.map