@confis/discordapiwrapper
Version:
A fast and lightweight discord api wrapper.
162 lines (161 loc) • 5.92 kB
TypeScript
import { Channel, Guild, Collector, Member, User, APIMessage, APIMessageAttachment, APIWebhookMessage, Client, ComponentTypes, ContentOptions, JSONCache, APIMessageSnapshot, Interaction, APIEmbed, APIMessageTypes } from "../index";
import { Base } from "../internal/Base";
/** Forwarded message object */
export declare class MessageSnapshot {
readonly type: number;
readonly content: string;
readonly attachments: APIMessageAttachment[];
readonly timestamp: number;
readonly editedTimestamp: Date | null;
constructor(data: APIMessageSnapshot);
}
/** Message object */
export declare class Message extends Base {
#private;
readonly id: string;
readonly channelID: string;
readonly content: string;
readonly timestamp: Date;
readonly editedTimestamp: Date | null;
readonly mentionEveryone: boolean;
readonly guildID: string;
readonly pinned: boolean;
readonly type: APIMessageTypes;
readonly referencedMessage?: Message;
readonly attachments: APIMessageAttachment[];
readonly embeds: APIEmbed[];
constructor(data: APIMessage, client: Client);
/**
* Get the link of the message
*/
get jumpLink(): string;
/**
* Returns if the message is forwarded
*/
get forwarded(): boolean;
/**
* Returns the forwarded message if it exists
*/
get forwardedMessage(): MessageSnapshot | null;
/**
* Get all the mentioned users in the message
*
* @returns An array of users
*/
get mentions(): User[];
/**
* Get the channel of the message
*
* @returns A channel object
*/
get channel(): Channel | null;
/**
* Get the author of the message
*
* @returns A user object
*/
get author(): User | null;
/**
* Get the member object of the author of the message
*
* @returns A member object
*/
get member(): Member | null;
/**
* Get the guild the message was sent in
*
* @returns A guild object
*/
get guild(): Guild;
/**
* Get the content of the message
*/
toString(): string;
/**
* Create a collector for this message
*
* @param options Collector options
* @returns A collector object
*/
createComponentCollector(options?: {
timeout?: number;
component_type?: ComponentTypes[];
filter?: (i: Interaction) => boolean;
}): Collector;
/**
* Get all the collectors associated with this message
*
* @returns An array of collectors
*/
get componentCollectors(): Collector[];
/**
* Sends a reply message.
*
* @param {string | ContentOptions} content - The content of the message or options for the message.
* @param {number} [deleteAfter] - The number of milliseconds to wait before deleting the message.
* @return {Promise<Message>} A promise that resolves to the sent message.
*/
reply(content: string | ContentOptions, deleteAfter?: number): Promise<Message>;
/**
* Edits the content of a message.
*
* @param {string | ContentOptions} content - The new content of the message. It can be a string or an object with
* the following properties:
* - content: The new content of the message.
* - file: An optional file to attach to the message. It can be a single file or an array of files.
* - embeds: An optional array of embeds to include in the message.
* - components: An optional array of components to include in the message.
* @return {Promise<Message>} A promise that resolves to the edited message.
* @throws {Error} If the message is not owned by the bot.
*/
edit(content: string | ContentOptions): Promise<Message>;
/**
* Deletes this message from the channel.
*
* @param options - Optional configuration for deletion
* @param options.throwError - Whether to throw an error if deletion fails (default: true)
* @return {Promise<void>} A promise that resolves when the message is deleted
* @throws {Error} If throwError is true and the deletion request fails
*/
delete(options?: {
throwError?: boolean;
}): Promise<void>;
/**
* React to a message with an emoji.
*
* @return {Promise<void>} - A Promise that resolves when the reaction has been successfully added.
* @throws {Error} - If the request to react to the message fails, an Error is thrown with the error message.
* @param emoji The emoji to react with.
*/
react(emoji: string): Promise<void>;
/**
* Remove the bot's reaction from the message.
*
* @return {Promise<void>} - A Promise that resolves when the reaction has been successfully removed.
* @throws {Error} - If the request to remove the reaction from the message fails, an Error is thrown with the error message.
* @param emoji The emoji to remove its reaction.
*/
removeReaction(emoji: string): Promise<void>;
/**
* Remove a user's reaction from the message.
*
* @return {Promise<void>} - A Promise that resolves when the reaction has been successfully removed.
* @throws {Error} - If the request to remove the reaction from the message fails, an Error is thrown with the error message.
* @param emoji The emoji to remove its reaction.
* @param userID The user ID
*/
deleteUserReaction(emoji: string, userID: string): Promise<void>;
/**
* Get all of the reactions of an emoji in the message.
*
* @param emoji The emoji to get the reactions of.
* @returns An array of users.
*/
getReactions(emoji: string): Promise<User[]>;
}
/** Webhook message object */
export declare class WebhookMessage extends Message {
readonly webhookID: string;
readonly authorData: JSONCache;
constructor(data: APIWebhookMessage, client: Client);
}