aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/discord.js/other.ts
blob: aeba01c6ee2fd9afd3711b22071d78e1fd62b47c (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import type {
	BushApplicationCommand,
	BushCategoryChannel,
	BushDMChannel,
	BushGuild,
	BushGuildEmoji,
	BushGuildMember,
	BushMessage,
	BushNewsChannel,
	BushReactionEmoji,
	BushRole,
	BushStageChannel,
	BushTextChannel,
	BushThreadChannel,
	BushThreadMember,
	BushUser,
	BushVoiceChannel,
	PartialBushDMChannel
} from '#lib';
import { APIMessage } from 'discord-api-types/v10';
import type {
	ApplicationCommandResolvable,
	CacheType,
	CacheTypeReducer,
	ChannelResolvable,
	ChannelType,
	Collection,
	EmojiIdentifierResolvable,
	EmojiResolvable,
	FetchedThreads,
	GuildChannelResolvable,
	GuildMemberResolvable,
	GuildTextChannelResolvable,
	MessageResolvable,
	PartialGroupDMChannel,
	RoleResolvable,
	Snowflake,
	ThreadChannelResolvable,
	ThreadMemberResolvable,
	UserResolvable
} from 'discord.js';

/**
 * Data that resolves to give a ThreadMember object.
 */
export type BushThreadMemberResolvable = ThreadMemberResolvable | BushThreadMember | BushUserResolvable;

/**
 * Data that resolves to give a User object.
 */
export type BushUserResolvable = UserResolvable | BushUser | Snowflake | BushMessage | BushGuildMember | BushThreadMember;

/**
 * Data that resolves to give a GuildMember object.
 */
export type BushGuildMemberResolvable = GuildMemberResolvable | BushGuildMember | BushUserResolvable;

/**
 * Data that can be resolved to a Role object.
 */
export type BushRoleResolvable = RoleResolvable | BushRole | Snowflake;

/**
 * Data that can be resolved to a Message object.
 */
export type BushMessageResolvable = MessageResolvable | BushMessage | Snowflake;

/**
 * Data that can be resolved into a GuildEmoji object.
 */
export type BushEmojiResolvable = EmojiResolvable | Snowflake | BushGuildEmoji | BushReactionEmoji;

/**
 * Data that can be resolved to give an emoji identifier. This can be:
 * * The unicode representation of an emoji
 * * The `<a:name:id>`, `<:name:id>`, `a:name:id` or `name:id` emoji identifier string of an emoji
 * * An EmojiResolvable
 */
export type BushEmojiIdentifierResolvable = EmojiIdentifierResolvable | string | BushEmojiResolvable;

/**
 * Data that can be resolved to a Thread Channel object.
 */
export type BushThreadChannelResolvable = ThreadChannelResolvable | BushThreadChannel | Snowflake;

/**
 * Data that resolves to give an ApplicationCommand object.
 */
export type BushApplicationCommandResolvable = ApplicationCommandResolvable | BushApplicationCommand | Snowflake;

/**
 * Data that can be resolved to a GuildTextChannel object.
 */
export type BushGuildTextChannelResolvable = GuildTextChannelResolvable | BushTextChannel | BushNewsChannel | Snowflake;

/**
 * Data that can be resolved to give a Channel object.
 */
export type BushChannelResolvable = ChannelResolvable | BushAnyChannel | Snowflake;

/**
 * Data that can be resolved to give a Guild Channel object.
 */
export type BushGuildChannelResolvable = GuildChannelResolvable | Snowflake | BushGuildBasedChannel;

export type BushAnyChannel =
	| BushCategoryChannel
	| BushDMChannel
	| PartialBushDMChannel
	| PartialGroupDMChannel
	| BushNewsChannel
	| BushStageChannel
	| BushTextChannel
	| BushThreadChannel
	| BushVoiceChannel;

/**
 * The channels that are text-based.
 */
export type BushTextBasedChannel =
	| BushDMChannel
	| PartialBushDMChannel
	| BushNewsChannel
	| BushTextChannel
	| BushThreadChannel
	| BushVoiceChannel;

/**
 * The types of channels that are text-based.
 */
export type BushTextBasedChannelTypes = BushTextBasedChannel['type'];

export type BushVoiceBasedChannel = Extract<BushAnyChannel, { bitrate: number }>;

export type BushGuildBasedChannel = Extract<BushAnyChannel, { guild: BushGuild }>;

export type BushNonCategoryGuildBasedChannel = Exclude<BushGuildBasedChannel, BushCategoryChannel>;

export type BushNonThreadGuildBasedChannel = Exclude<BushGuildBasedChannel, BushThreadChannel>;

export type BushGuildTextBasedChannel = Extract<BushGuildBasedChannel, BushTextBasedChannel>;

/**
 * Data that can be resolved to a Text Channel object.
 */
export type BushTextChannelResolvable = Snowflake | BushTextChannel;

/**
 * Data that can be resolved to a GuildVoiceChannel object.
 */
export type BushGuildVoiceChannelResolvable = BushVoiceBasedChannel | Snowflake;

export interface BushMappedChannelCategoryTypes {
	[ChannelType.GuildNews]: BushNewsChannel;
	[ChannelType.GuildVoice]: BushVoiceChannel;
	[ChannelType.GuildText]: BushTextChannel;
	[ChannelType.GuildStageVoice]: BushStageChannel;
	[ChannelType.GuildForum]: never; // TODO: Fix when guild forums come out
}

export type BushMappedGuildChannelTypes = {
	[ChannelType.GuildCategory]: BushCategoryChannel;
} & BushMappedChannelCategoryTypes;

/**
 * The data returned from a thread fetch that returns multiple threads.
 */
export interface BushFetchedThreads extends FetchedThreads {
	/**
	 * The threads that were fetched, with any members returned
	 */
	threads: Collection<Snowflake, BushThreadChannel>;

	/**
	 * Whether there are potentially additional threads that require a subsequent call
	 */
	hasMore?: boolean;
}

export type BushGuildCacheMessage<Cached extends CacheType> = CacheTypeReducer<
	Cached,
	BushMessage<true>,
	APIMessage,
	BushMessage | APIMessage,
	BushMessage | APIMessage
>;