aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/discord.js/BushMessage.ts
blob: 420f8f5f2642d6a22be5091f6ec3cfdbf010ffc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type {
	BushClient,
	BushCommandUtil,
	BushGuild,
	BushGuildMember,
	BushGuildTextBasedChannel,
	BushMessageReaction,
	BushTextBasedChannel,
	BushThreadChannel,
	BushUser
} from '#lib';
import {
	ActionRowComponent,
	Message,
	type EmojiIdentifierResolvable,
	type If,
	type MessageEditOptions,
	type MessagePayload,
	type Partialize,
	type ReplyMessageOptions,
	type StartThreadOptions
} from 'discord.js';
import type { RawMessageData } from 'discord.js/typings/rawDataTypes';

export type PartialBushMessage = Partialize<
	BushMessage,
	'type' | 'system' | 'pinned' | 'tts',
	'content' | 'cleanContent' | 'author'
>;

/**
 * Represents a message on Discord.
 */
export class BushMessage<Cached extends boolean = boolean> extends Message<Cached> {
	public declare readonly client: BushClient;
	public declare util: BushCommandUtil<BushMessage<true>>;
	public declare readonly guild: If<Cached, BushGuild>;
	public declare readonly member: BushGuildMember | null;
	public declare author: BushUser;
	public declare readonly channel: If<Cached, BushGuildTextBasedChannel, BushTextBasedChannel>;

	public constructor(client: BushClient, data: RawMessageData) {
		super(client, data);
	}
}

export interface BushMessage<Cached extends boolean = boolean> extends Message<Cached> {
	delete(): Promise<BushMessage>;
	edit(content: string | MessageEditOptions | MessagePayload): Promise<BushMessage>;
	equals(message: BushMessage, rawData: unknown): boolean;
	fetchReference(): Promise<BushMessage>;
	crosspost(): Promise<BushMessage>;
	fetch(force?: boolean): Promise<BushMessage>;
	pin(): Promise<BushMessage>;
	react(emoji: EmojiIdentifierResolvable): Promise<BushMessageReaction>;
	removeAttachments(): Promise<BushMessage>;
	reply(options: string | MessagePayload | ReplyMessageOptions): Promise<BushMessage>;
	resolveComponent(customId: string): ActionRowComponent | null;
	startThread(options: StartThreadOptions): Promise<BushThreadChannel>;
	suppressEmbeds(suppress?: boolean): Promise<BushMessage>;
	unpin(): Promise<BushMessage>;
	inGuild(): this is BushMessage<true> & this;
}