chapterjs 0.1.1 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/asset.d.ts +46 -0
- package/dist/assets/asset.js +86 -0
- package/dist/assets/public.d.ts +19 -0
- package/dist/assets/public.js +120 -0
- package/dist/cache/cache.d.ts +62 -0
- package/dist/cache/cache.js +80 -0
- package/dist/cache/store.d.ts +45 -0
- package/dist/cache/store.js +53 -0
- package/dist/cli/build.d.ts +41 -0
- package/dist/cli/build.js +206 -0
- package/dist/cli/cli.js +108 -25
- package/dist/cli/cluster.d.ts +70 -0
- package/dist/cli/cluster.js +213 -0
- package/dist/cli/dev.d.ts +18 -1
- package/dist/cli/dev.js +252 -198
- package/dist/cli/env.d.ts +31 -0
- package/dist/cli/env.js +93 -0
- package/dist/cli/log.d.ts +13 -0
- package/dist/cli/log.js +17 -0
- package/dist/cli/node-version.d.ts +8 -0
- package/dist/cli/node-version.js +13 -0
- package/dist/cli/preflight.d.ts +36 -0
- package/dist/cli/preflight.js +122 -0
- package/dist/cli/project.d.ts +122 -0
- package/dist/cli/project.js +452 -0
- package/dist/cli/start.d.ts +25 -0
- package/dist/cli/start.js +225 -0
- package/dist/commands/autocomplete.d.ts +13 -0
- package/dist/commands/autocomplete.js +159 -0
- package/dist/commands/command.d.ts +346 -0
- package/dist/commands/command.js +28 -0
- package/dist/commands/convention.d.ts +64 -0
- package/dist/commands/convention.js +464 -0
- package/dist/commands/register.d.ts +18 -0
- package/dist/commands/register.js +42 -0
- package/dist/commands/router.d.ts +20 -0
- package/dist/commands/router.js +228 -0
- package/dist/commands/tree.d.ts +43 -0
- package/dist/commands/tree.js +206 -0
- package/dist/commands/twins.d.ts +15 -0
- package/dist/commands/twins.js +78 -0
- package/dist/components/button.d.ts +79 -0
- package/dist/components/button.js +108 -0
- package/dist/components/component.d.ts +140 -0
- package/dist/components/component.js +39 -0
- package/dist/components/convention.d.ts +35 -0
- package/dist/components/convention.js +339 -0
- package/dist/components/custom-id.d.ts +72 -0
- package/dist/components/custom-id.js +128 -0
- package/dist/components/embed.d.ts +28 -0
- package/dist/components/embed.js +11 -0
- package/dist/components/file.d.ts +30 -0
- package/dist/components/file.js +52 -0
- package/dist/components/instance.d.ts +100 -0
- package/dist/components/instance.js +86 -0
- package/dist/components/layout.d.ts +103 -0
- package/dist/components/layout.js +279 -0
- package/dist/components/modal.d.ts +244 -0
- package/dist/components/modal.js +399 -0
- package/dist/components/options.d.ts +41 -0
- package/dist/components/options.js +101 -0
- package/dist/components/render.d.ts +12 -0
- package/dist/components/render.js +58 -0
- package/dist/components/router.d.ts +18 -0
- package/dist/components/router.js +256 -0
- package/dist/components/select.d.ts +144 -0
- package/dist/components/select.js +179 -0
- package/dist/core/bot.d.ts +99 -0
- package/dist/core/bot.js +174 -0
- package/dist/core/memory.d.ts +66 -0
- package/dist/core/memory.js +115 -0
- package/dist/discord/api.d.ts +112 -0
- package/dist/discord/api.js +115 -0
- package/dist/discord/cdn.d.ts +67 -0
- package/dist/discord/cdn.js +100 -0
- package/dist/discord/codes.d.ts +171 -0
- package/dist/discord/codes.js +421 -0
- package/dist/discord/endpoint.d.ts +56 -0
- package/dist/discord/endpoint.js +53 -0
- package/dist/discord/endpoints.d.ts +1529 -0
- package/dist/discord/endpoints.js +1139 -0
- package/dist/discord/formatting.d.ts +67 -0
- package/dist/discord/formatting.js +87 -0
- package/dist/discord/index.d.ts +10 -0
- package/dist/discord/index.js +13 -0
- package/dist/discord/intents.d.ts +48 -0
- package/dist/discord/intents.js +128 -0
- package/dist/discord/permissions.d.ts +94 -0
- package/dist/discord/permissions.js +185 -0
- package/dist/discord/snowflake.d.ts +21 -0
- package/dist/discord/snowflake.js +36 -0
- package/dist/discord/types/application-command.d.ts +332 -0
- package/dist/discord/types/application-command.js +48 -0
- package/dist/discord/types/application-role-connection-metadata.d.ts +42 -0
- package/dist/discord/types/application-role-connection-metadata.js +22 -0
- package/dist/discord/types/application.d.ts +208 -0
- package/dist/discord/types/application.js +48 -0
- package/dist/discord/types/audit-log.d.ts +255 -0
- package/dist/discord/types/audit-log.js +144 -0
- package/dist/discord/types/auto-moderation.d.ts +167 -0
- package/dist/discord/types/auto-moderation.js +52 -0
- package/dist/discord/types/channel.d.ts +557 -0
- package/dist/discord/types/channel.js +88 -0
- package/dist/discord/types/common.d.ts +54 -0
- package/dist/discord/types/common.js +38 -0
- package/dist/discord/types/component.d.ts +775 -0
- package/dist/discord/types/component.js +76 -0
- package/dist/discord/types/emoji.d.ts +74 -0
- package/dist/discord/types/emoji.js +1 -0
- package/dist/discord/types/entitlement.d.ts +84 -0
- package/dist/discord/types/entitlement.js +22 -0
- package/dist/discord/types/gateway-events.d.ts +1148 -0
- package/dist/discord/types/gateway-events.js +54 -0
- package/dist/discord/types/gateway.d.ts +38 -0
- package/dist/discord/types/gateway.js +1 -0
- package/dist/discord/types/guild-scheduled-event.d.ts +257 -0
- package/dist/discord/types/guild-scheduled-event.js +68 -0
- package/dist/discord/types/guild-template.d.ts +51 -0
- package/dist/discord/types/guild-template.js +1 -0
- package/dist/discord/types/guild.d.ts +910 -0
- package/dist/discord/types/guild.js +153 -0
- package/dist/discord/types/index.d.ts +31 -0
- package/dist/discord/types/index.js +31 -0
- package/dist/discord/types/interaction.d.ts +321 -0
- package/dist/discord/types/interaction.js +47 -0
- package/dist/discord/types/invite.d.ts +158 -0
- package/dist/discord/types/invite.js +39 -0
- package/dist/discord/types/message.d.ts +834 -0
- package/dist/discord/types/message.js +159 -0
- package/dist/discord/types/oauth2.d.ts +22 -0
- package/dist/discord/types/oauth2.js +1 -0
- package/dist/discord/types/permissions.d.ts +183 -0
- package/dist/discord/types/permissions.js +118 -0
- package/dist/discord/types/poll.d.ts +106 -0
- package/dist/discord/types/poll.js +8 -0
- package/dist/discord/types/sku.d.ts +47 -0
- package/dist/discord/types/sku.js +26 -0
- package/dist/discord/types/soundboard.d.ts +71 -0
- package/dist/discord/types/soundboard.js +1 -0
- package/dist/discord/types/stage-instance.d.ts +58 -0
- package/dist/discord/types/stage-instance.js +10 -0
- package/dist/discord/types/sticker.d.ts +115 -0
- package/dist/discord/types/sticker.js +20 -0
- package/dist/discord/types/subscription.d.ts +54 -0
- package/dist/discord/types/subscription.js +12 -0
- package/dist/discord/types/team.d.ts +55 -0
- package/dist/discord/types/team.js +21 -0
- package/dist/discord/types/user.d.ts +273 -0
- package/dist/discord/types/user.js +83 -0
- package/dist/discord/types/voice.d.ts +72 -0
- package/dist/discord/types/voice.js +1 -0
- package/dist/discord/types/webhook.d.ts +184 -0
- package/dist/discord/types/webhook.js +12 -0
- package/dist/events/convention.d.ts +25 -0
- package/dist/events/convention.js +97 -0
- package/dist/events/event.d.ts +8 -0
- package/dist/events/event.js +20 -0
- package/dist/events/registry.d.ts +706 -0
- package/dist/events/registry.js +839 -0
- package/dist/events/router.d.ts +45 -0
- package/dist/events/router.js +133 -0
- package/dist/events/types.d.ts +7 -0
- package/dist/events/types.js +48 -0
- package/dist/gateway/errors.d.ts +18 -0
- package/dist/gateway/errors.js +47 -0
- package/dist/gateway/gateway.d.ts +64 -0
- package/dist/gateway/gateway.js +117 -0
- package/dist/gateway/identify-queue.d.ts +25 -0
- package/dist/gateway/identify-queue.js +29 -0
- package/dist/gateway/shard.d.ts +94 -0
- package/dist/gateway/shard.js +414 -0
- package/dist/gateway/state.d.ts +11 -0
- package/dist/gateway/state.js +184 -0
- package/dist/index.d.ts +55 -18
- package/dist/index.js +38 -12
- package/dist/interactions/cooldown.d.ts +33 -0
- package/dist/interactions/cooldown.js +74 -0
- package/dist/interactions/dispatch.d.ts +91 -0
- package/dist/interactions/dispatch.js +110 -0
- package/dist/loader/generated.d.ts +37 -0
- package/dist/loader/generated.js +114 -0
- package/dist/loader/hot.d.ts +13 -0
- package/dist/loader/hot.js +85 -0
- package/dist/loader/loader.d.ts +72 -0
- package/dist/loader/loader.js +135 -0
- package/dist/loader/locate.d.ts +10 -0
- package/dist/loader/locate.js +36 -0
- package/dist/loader/watch.d.ts +17 -0
- package/dist/loader/watch.js +66 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +6 -0
- package/dist/messages/commands.d.ts +23 -0
- package/dist/messages/commands.js +123 -0
- package/dist/messages/convention.d.ts +89 -0
- package/dist/messages/convention.js +347 -0
- package/dist/messages/messages.d.ts +219 -0
- package/dist/messages/messages.js +30 -0
- package/dist/messages/phrases.d.ts +23 -0
- package/dist/messages/phrases.js +44 -0
- package/dist/messages/translate.d.ts +100 -0
- package/dist/messages/translate.js +249 -0
- package/dist/presence/convention.d.ts +26 -0
- package/dist/presence/convention.js +133 -0
- package/dist/presence/presence.d.ts +57 -0
- package/dist/presence/presence.js +27 -0
- package/dist/rest/errors.d.ts +55 -0
- package/dist/rest/errors.js +92 -0
- package/dist/rest/rate-limiter.d.ts +46 -0
- package/dist/rest/rate-limiter.js +153 -0
- package/dist/rest/rest.d.ts +63 -0
- package/dist/rest/rest.js +194 -0
- package/dist/structures/base.d.ts +48 -0
- package/dist/structures/base.js +84 -0
- package/dist/structures/channel.d.ts +380 -0
- package/dist/structures/channel.js +627 -0
- package/dist/structures/context.d.ts +30 -0
- package/dist/structures/context.js +7 -0
- package/dist/structures/emoji.d.ts +46 -0
- package/dist/structures/emoji.js +65 -0
- package/dist/structures/entities.d.ts +62 -0
- package/dist/structures/entities.js +226 -0
- package/dist/structures/guild.d.ts +348 -0
- package/dist/structures/guild.js +466 -0
- package/dist/structures/interaction.d.ts +197 -0
- package/dist/structures/interaction.js +396 -0
- package/dist/structures/invite.d.ts +38 -0
- package/dist/structures/invite.js +57 -0
- package/dist/structures/known.d.ts +28 -0
- package/dist/structures/known.js +58 -0
- package/dist/structures/member.d.ts +140 -0
- package/dist/structures/member.js +260 -0
- package/dist/structures/message.d.ts +197 -0
- package/dist/structures/message.js +268 -0
- package/dist/structures/payload.d.ts +91 -0
- package/dist/structures/payload.js +184 -0
- package/dist/structures/role.d.ts +69 -0
- package/dist/structures/role.js +112 -0
- package/dist/structures/user.d.ts +59 -0
- package/dist/structures/user.js +94 -0
- package/dist/structures/webhook.d.ts +46 -0
- package/dist/structures/webhook.js +79 -0
- package/dist/tasks/convention.d.ts +26 -0
- package/dist/tasks/convention.js +78 -0
- package/dist/tasks/schedule.d.ts +54 -0
- package/dist/tasks/schedule.js +236 -0
- package/dist/tasks/scheduler.d.ts +33 -0
- package/dist/tasks/scheduler.js +107 -0
- package/dist/tasks/task.d.ts +76 -0
- package/dist/tasks/task.js +28 -0
- package/dist/util/case.d.ts +13 -0
- package/dist/util/case.js +54 -0
- package/dist/util/duration.d.ts +8 -0
- package/dist/util/duration.js +29 -0
- package/dist/util/websocket.d.ts +9 -0
- package/dist/util/websocket.js +31 -0
- package/dist/voice/connection.d.ts +90 -0
- package/dist/voice/connection.js +494 -0
- package/dist/voice/dave.d.ts +109 -0
- package/dist/voice/dave.js +245 -0
- package/dist/voice/opus.d.ts +19 -0
- package/dist/voice/opus.js +273 -0
- package/dist/voice/session.d.ts +55 -0
- package/dist/voice/session.js +405 -0
- package/dist/voice/source.d.ts +22 -0
- package/dist/voice/source.js +195 -0
- package/dist/voice/transport.d.ts +43 -0
- package/dist/voice/transport.js +140 -0
- package/dist/voice/usage.d.ts +4 -0
- package/dist/voice/usage.js +33 -0
- package/package.json +26 -7
- package/vendor/dave/LICENSE +231 -0
- package/vendor/dave/libdave.d.mts +99 -0
- package/vendor/dave/libdave.mjs +2 -0
- package/vendor/dave/libdave.wasm +0 -0
- package/dist/components.d.ts +0 -97
- package/dist/components.js +0 -260
- package/dist/context.d.ts +0 -72
- package/dist/context.js +0 -273
- package/dist/discord/client.d.ts +0 -35
- package/dist/discord/client.js +0 -66
- package/dist/discord/constants.d.ts +0 -49
- package/dist/discord/constants.js +0 -61
- package/dist/discord/events.d.ts +0 -129
- package/dist/discord/events.js +0 -102
- package/dist/discord/gateway.d.ts +0 -61
- package/dist/discord/gateway.js +0 -320
- package/dist/discord/payloads.d.ts +0 -275
- package/dist/discord/payloads.js +0 -3
- package/dist/discord/presence.d.ts +0 -42
- package/dist/discord/presence.js +0 -51
- package/dist/discord/rest.d.ts +0 -49
- package/dist/discord/rest.js +0 -271
- package/dist/discord/types.d.ts +0 -334
- package/dist/discord/types.js +0 -4
- package/dist/events.d.ts +0 -94
- package/dist/events.js +0 -255
- package/dist/presence.d.ts +0 -92
- package/dist/presence.js +0 -250
- package/dist/structures/Channel.d.ts +0 -110
- package/dist/structures/Channel.js +0 -171
- package/dist/structures/Guild.d.ts +0 -70
- package/dist/structures/Guild.js +0 -105
- package/dist/structures/Interaction.d.ts +0 -113
- package/dist/structures/Interaction.js +0 -274
- package/dist/structures/Member.d.ts +0 -70
- package/dist/structures/Member.js +0 -124
- package/dist/structures/Message.d.ts +0 -87
- package/dist/structures/Message.js +0 -182
- package/dist/structures/Reaction.d.ts +0 -38
- package/dist/structures/Reaction.js +0 -64
- package/dist/structures/Role.d.ts +0 -43
- package/dist/structures/Role.js +0 -77
- package/dist/structures/User.d.ts +0 -41
- package/dist/structures/User.js +0 -79
- package/dist/structures/utils.d.ts +0 -72
- package/dist/structures/utils.js +0 -59
- package/dist/utils/errors.d.ts +0 -5
- package/dist/utils/errors.js +0 -28
- package/dist/utils/modules.d.ts +0 -39
- package/dist/utils/modules.js +0 -156
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { type ImageOptions } from '../discord/cdn.js';
|
|
2
|
+
import { Permissions } from '../discord/permissions.js';
|
|
3
|
+
import type { Snowflake } from '../discord/types/common.js';
|
|
4
|
+
import type { RawGuildMember } from '../discord/types/guild.js';
|
|
5
|
+
import { Structure } from './base.js';
|
|
6
|
+
import type { GuildChannel, VoiceChannel } from './channel.js';
|
|
7
|
+
import type { Context } from './context.js';
|
|
8
|
+
import { type Guild } from './guild.js';
|
|
9
|
+
import type { Message } from './message.js';
|
|
10
|
+
import type { MessageInput } from './payload.js';
|
|
11
|
+
import type { Role } from './role.js';
|
|
12
|
+
import type { User } from './user.js';
|
|
13
|
+
/** The data of a member, without the user it belongs to. */
|
|
14
|
+
export type MemberData = Omit<RawGuildMember, 'user'>;
|
|
15
|
+
export interface BanOptions {
|
|
16
|
+
/** Why, shown in the audit log of the server. */
|
|
17
|
+
reason?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Also deletes the messages the user sent in the last seconds given: from
|
|
20
|
+
* 0 (the default, nothing) to 604800 (7 days).
|
|
21
|
+
*/
|
|
22
|
+
deleteMessageSeconds?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface MemberEditOptions {
|
|
25
|
+
/** The nickname; `null` removes it. */
|
|
26
|
+
nick?: string | null;
|
|
27
|
+
/** Replaces every role of the member. */
|
|
28
|
+
roles?: (Snowflake | Role)[];
|
|
29
|
+
/** Mutes the member in voice channels. */
|
|
30
|
+
mute?: boolean;
|
|
31
|
+
/** Deafens the member in voice channels. */
|
|
32
|
+
deaf?: boolean;
|
|
33
|
+
/** Moves the member to another voice channel; `null` disconnects them. */
|
|
34
|
+
voiceChannel?: Snowflake | {
|
|
35
|
+
id: Snowflake;
|
|
36
|
+
} | null;
|
|
37
|
+
/** Until when the member is timed out; `null` ends the timeout. */
|
|
38
|
+
timeoutUntil?: Date | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A user as a member of one server: nickname, roles, permissions.
|
|
42
|
+
* @see https://docs.discord.com/developers/resources/guild#guild-member-object
|
|
43
|
+
*/
|
|
44
|
+
export declare class GuildMember extends Structure<MemberData> {
|
|
45
|
+
/** The id of the server. */
|
|
46
|
+
readonly guildId: Snowflake;
|
|
47
|
+
/** The account of the member. */
|
|
48
|
+
readonly user: User;
|
|
49
|
+
constructor(ctx: Context, data: MemberData, guildId: Snowflake, user: User);
|
|
50
|
+
/** The id of the user. */
|
|
51
|
+
get id(): Snowflake;
|
|
52
|
+
/** The server the member is in. */
|
|
53
|
+
get guild(): Guild;
|
|
54
|
+
/** The nickname of the member in this server, when they have one. */
|
|
55
|
+
get nick(): string | null;
|
|
56
|
+
/** The name to show: nickname, or display name, or username. */
|
|
57
|
+
get displayName(): string;
|
|
58
|
+
/** The ids of the roles of the member (@everyone is not listed). */
|
|
59
|
+
get roleIds(): readonly Snowflake[];
|
|
60
|
+
/** The roles of the member, @everyone included, highest first. */
|
|
61
|
+
get roles(): Role[];
|
|
62
|
+
/** The highest role of the member in the hierarchy; @everyone at least. */
|
|
63
|
+
get highestRole(): Role;
|
|
64
|
+
/**
|
|
65
|
+
* The voice channel the member is in; `null` when they are in none. The
|
|
66
|
+
* bot knows it when Discord sends it voice states: in a project with a
|
|
67
|
+
* file that joins a voice channel or listens to a voice event.
|
|
68
|
+
*/
|
|
69
|
+
get voiceChannel(): VoiceChannel | null;
|
|
70
|
+
/** When the member joined the server. */
|
|
71
|
+
get joinedAt(): Date | null;
|
|
72
|
+
/** Since when the member boosts the server. */
|
|
73
|
+
get boostingSince(): Date | null;
|
|
74
|
+
/** Whether the member has not passed the membership screening yet. */
|
|
75
|
+
get pending(): boolean;
|
|
76
|
+
/** Until when the member is timed out; `null` when they are not. */
|
|
77
|
+
get timeoutUntil(): Date | null;
|
|
78
|
+
/** Whether the member is timed out right now. */
|
|
79
|
+
get isTimedOut(): boolean;
|
|
80
|
+
/** Whether the member owns the server. */
|
|
81
|
+
get isOwner(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* What the member can do in the server (channels may change it: see
|
|
84
|
+
* `permissionsIn`).
|
|
85
|
+
* @see https://docs.discord.com/developers/topics/permissions#permission-overwrites
|
|
86
|
+
*/
|
|
87
|
+
get permissions(): Permissions;
|
|
88
|
+
/** What the member can do in a channel of the server. */
|
|
89
|
+
permissionsIn(channel: GuildChannel): Permissions;
|
|
90
|
+
/** The avatar of the member in this server, or else of their account. */
|
|
91
|
+
avatarURL(options?: ImageOptions): string;
|
|
92
|
+
/**
|
|
93
|
+
* Whether this member is above another one in the role hierarchy, which
|
|
94
|
+
* is what allows to kick, ban or rename them.
|
|
95
|
+
* @see https://docs.discord.com/developers/topics/permissions#permission-hierarchy
|
|
96
|
+
*/
|
|
97
|
+
isHigherThan(other: GuildMember): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Changes the member.
|
|
100
|
+
* @see https://docs.discord.com/developers/resources/guild#modify-guild-member
|
|
101
|
+
*/
|
|
102
|
+
edit(options: MemberEditOptions, reason?: string): Promise<GuildMember>;
|
|
103
|
+
/** Changes the nickname of the member; `null` removes it. */
|
|
104
|
+
setNick(nick: string | null, reason?: string): Promise<GuildMember>;
|
|
105
|
+
/**
|
|
106
|
+
* Gives a role to the member.
|
|
107
|
+
* @see https://docs.discord.com/developers/resources/guild#add-guild-member-role
|
|
108
|
+
*/
|
|
109
|
+
addRole(role: Snowflake | Role, reason?: string): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Takes a role from the member.
|
|
112
|
+
* @see https://docs.discord.com/developers/resources/guild#remove-guild-member-role
|
|
113
|
+
*/
|
|
114
|
+
removeRole(role: Snowflake | Role, reason?: string): Promise<void>;
|
|
115
|
+
/** Whether the member has a role. */
|
|
116
|
+
hasRole(role: Snowflake | Role): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Prevents the member from writing, reacting and speaking for a while.
|
|
119
|
+
* @param duration how long, in milliseconds (28 days at most)
|
|
120
|
+
*/
|
|
121
|
+
timeout(duration: number, reason?: string): Promise<GuildMember>;
|
|
122
|
+
/** Ends the timeout of the member. */
|
|
123
|
+
removeTimeout(reason?: string): Promise<GuildMember>;
|
|
124
|
+
/**
|
|
125
|
+
* Removes the member from the server; they can come back with an invite.
|
|
126
|
+
* @see https://docs.discord.com/developers/resources/guild#remove-guild-member
|
|
127
|
+
*/
|
|
128
|
+
kick(reason?: string): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Bans the member from the server.
|
|
131
|
+
* @see https://docs.discord.com/developers/resources/guild#create-guild-ban
|
|
132
|
+
*/
|
|
133
|
+
ban(options?: BanOptions): Promise<void>;
|
|
134
|
+
/** Sends a private message to the member. */
|
|
135
|
+
send(message: MessageInput): Promise<Message>;
|
|
136
|
+
/** `<@id>`: mentions the member when put in a message. */
|
|
137
|
+
toString(): string;
|
|
138
|
+
}
|
|
139
|
+
/** One mechanism to ban, used by members and servers. */
|
|
140
|
+
export declare function banUser(ctx: Context, guildId: Snowflake, userId: Snowflake, { reason, deleteMessageSeconds }: BanOptions): Promise<void>;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { Limits } from '../discord/api.js';
|
|
2
|
+
import { cdn } from '../discord/cdn.js';
|
|
3
|
+
import { AddGuildMemberRole, CreateGuildBan, ModifyCurrentMember, ModifyGuildMember, RemoveGuildMember, RemoveGuildMemberRole, } from '../discord/endpoints.js';
|
|
4
|
+
import { applyTimeout, computeBasePermissions, Permissions, } from '../discord/permissions.js';
|
|
5
|
+
import { ctxOf, dataOf, idOf, Structure, toDate } from './base.js';
|
|
6
|
+
import { guildOf } from './known.js';
|
|
7
|
+
import { storesOf } from './guild.js';
|
|
8
|
+
/**
|
|
9
|
+
* A user as a member of one server: nickname, roles, permissions.
|
|
10
|
+
* @see https://docs.discord.com/developers/resources/guild#guild-member-object
|
|
11
|
+
*/
|
|
12
|
+
export class GuildMember extends Structure {
|
|
13
|
+
/** The id of the server. */
|
|
14
|
+
guildId;
|
|
15
|
+
/** The account of the member. */
|
|
16
|
+
user;
|
|
17
|
+
constructor(ctx, data, guildId, user) {
|
|
18
|
+
super(ctx, data);
|
|
19
|
+
this.guildId = guildId;
|
|
20
|
+
this.user = user;
|
|
21
|
+
}
|
|
22
|
+
/** The id of the user. */
|
|
23
|
+
get id() {
|
|
24
|
+
return this.user.id;
|
|
25
|
+
}
|
|
26
|
+
/** The server the member is in. */
|
|
27
|
+
get guild() {
|
|
28
|
+
return guildOf(this, this.guildId);
|
|
29
|
+
}
|
|
30
|
+
/** The nickname of the member in this server, when they have one. */
|
|
31
|
+
get nick() {
|
|
32
|
+
return dataOf(this).nick ?? null;
|
|
33
|
+
}
|
|
34
|
+
/** The name to show: nickname, or display name, or username. */
|
|
35
|
+
get displayName() {
|
|
36
|
+
return this.nick ?? this.user.displayName;
|
|
37
|
+
}
|
|
38
|
+
/** The ids of the roles of the member (@everyone is not listed). */
|
|
39
|
+
get roleIds() {
|
|
40
|
+
return dataOf(this).roles;
|
|
41
|
+
}
|
|
42
|
+
/** The roles of the member, @everyone included, highest first. */
|
|
43
|
+
get roles() {
|
|
44
|
+
const guild = this.guild;
|
|
45
|
+
const roles = [];
|
|
46
|
+
for (const id of [...this.roleIds, this.guildId]) {
|
|
47
|
+
const role = guild.roles.get(id);
|
|
48
|
+
if (role)
|
|
49
|
+
roles.push(role);
|
|
50
|
+
}
|
|
51
|
+
return roles.sort((a, b) => (a.isHigherThan(b) ? -1 : 1));
|
|
52
|
+
}
|
|
53
|
+
/** The highest role of the member in the hierarchy; @everyone at least. */
|
|
54
|
+
get highestRole() {
|
|
55
|
+
return this.roles[0] ?? this.guild.everyoneRole;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The voice channel the member is in; `null` when they are in none. The
|
|
59
|
+
* bot knows it when Discord sends it voice states: in a project with a
|
|
60
|
+
* file that joins a voice channel or listens to a voice event.
|
|
61
|
+
*/
|
|
62
|
+
get voiceChannel() {
|
|
63
|
+
return storesOf(this.guild).voiceStates.get(this.id)?.channel ?? null;
|
|
64
|
+
}
|
|
65
|
+
/** When the member joined the server. */
|
|
66
|
+
get joinedAt() {
|
|
67
|
+
return toDate(dataOf(this).joined_at);
|
|
68
|
+
}
|
|
69
|
+
/** Since when the member boosts the server. */
|
|
70
|
+
get boostingSince() {
|
|
71
|
+
return toDate(dataOf(this).premium_since);
|
|
72
|
+
}
|
|
73
|
+
/** Whether the member has not passed the membership screening yet. */
|
|
74
|
+
get pending() {
|
|
75
|
+
return dataOf(this).pending ?? false;
|
|
76
|
+
}
|
|
77
|
+
/** Until when the member is timed out; `null` when they are not. */
|
|
78
|
+
get timeoutUntil() {
|
|
79
|
+
const until = toDate(dataOf(this).communication_disabled_until);
|
|
80
|
+
return until && until.getTime() > Date.now() ? until : null;
|
|
81
|
+
}
|
|
82
|
+
/** Whether the member is timed out right now. */
|
|
83
|
+
get isTimedOut() {
|
|
84
|
+
return this.timeoutUntil !== null;
|
|
85
|
+
}
|
|
86
|
+
/** Whether the member owns the server. */
|
|
87
|
+
get isOwner() {
|
|
88
|
+
return this.guild?.ownerId === this.id;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* What the member can do in the server (channels may change it: see
|
|
92
|
+
* `permissionsIn`).
|
|
93
|
+
* @see https://docs.discord.com/developers/topics/permissions#permission-overwrites
|
|
94
|
+
*/
|
|
95
|
+
get permissions() {
|
|
96
|
+
const guild = this.guild;
|
|
97
|
+
if (!guild) {
|
|
98
|
+
throw new Error('The permissions of this member are unknown: its server is not in the cache.');
|
|
99
|
+
}
|
|
100
|
+
const base = computeBasePermissions({
|
|
101
|
+
guildId: this.guildId,
|
|
102
|
+
ownerId: guild.ownerId,
|
|
103
|
+
userId: this.id,
|
|
104
|
+
memberRoleIds: this.roleIds,
|
|
105
|
+
roles: [...guild.roles.values()].map(role => ({
|
|
106
|
+
id: role.id,
|
|
107
|
+
permissions: role.permissions.bits,
|
|
108
|
+
})),
|
|
109
|
+
});
|
|
110
|
+
return new Permissions(this.isTimedOut ? applyTimeout(base) : base);
|
|
111
|
+
}
|
|
112
|
+
/** What the member can do in a channel of the server. */
|
|
113
|
+
permissionsIn(channel) {
|
|
114
|
+
return channel.permissionsFor(this);
|
|
115
|
+
}
|
|
116
|
+
/** The avatar of the member in this server, or else of their account. */
|
|
117
|
+
avatarURL(options) {
|
|
118
|
+
const avatar = dataOf(this).avatar;
|
|
119
|
+
return avatar
|
|
120
|
+
? cdn.memberAvatar(this.guildId, this.id, avatar, options)
|
|
121
|
+
: this.user.avatarURL(options);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Whether this member is above another one in the role hierarchy, which
|
|
125
|
+
* is what allows to kick, ban or rename them.
|
|
126
|
+
* @see https://docs.discord.com/developers/topics/permissions#permission-hierarchy
|
|
127
|
+
*/
|
|
128
|
+
isHigherThan(other) {
|
|
129
|
+
if (this.isOwner)
|
|
130
|
+
return true;
|
|
131
|
+
if (other.isOwner)
|
|
132
|
+
return false;
|
|
133
|
+
const mine = this.highestRole;
|
|
134
|
+
const theirs = other.highestRole;
|
|
135
|
+
if (!mine || !theirs)
|
|
136
|
+
return false;
|
|
137
|
+
return mine.id !== theirs.id && mine.isHigherThan(theirs);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Changes the member.
|
|
141
|
+
* @see https://docs.discord.com/developers/resources/guild#modify-guild-member
|
|
142
|
+
*/
|
|
143
|
+
async edit(options, reason) {
|
|
144
|
+
const { rest, entities } = ctxOf(this);
|
|
145
|
+
if (typeof options.nick === 'string' &&
|
|
146
|
+
options.nick.length > Limits.Nickname) {
|
|
147
|
+
throw new RangeError(`A nickname is ${Limits.Nickname} characters long at most, got ${options.nick.length}.`);
|
|
148
|
+
}
|
|
149
|
+
if (options.timeoutUntil) {
|
|
150
|
+
const ms = options.timeoutUntil.getTime() - Date.now();
|
|
151
|
+
if (!(ms > 0) || ms > Limits.TimeoutMaxDuration) {
|
|
152
|
+
throw new RangeError('A timeout ends in the future, 28 days from now at most.');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const raw = await rest.request(ModifyGuildMember, [this.guildId, this.id], {
|
|
156
|
+
// `null` is meaningful for these fields; the documented type only
|
|
157
|
+
// lists what they are when set.
|
|
158
|
+
body: {
|
|
159
|
+
nick: options.nick,
|
|
160
|
+
roles: options.roles?.map(idOf),
|
|
161
|
+
mute: options.mute,
|
|
162
|
+
deaf: options.deaf,
|
|
163
|
+
channel_id: options.voiceChannel === null || options.voiceChannel === undefined
|
|
164
|
+
? options.voiceChannel
|
|
165
|
+
: idOf(options.voiceChannel),
|
|
166
|
+
communication_disabled_until: options.timeoutUntil === null || options.timeoutUntil === undefined
|
|
167
|
+
? options.timeoutUntil
|
|
168
|
+
: options.timeoutUntil.toISOString(),
|
|
169
|
+
},
|
|
170
|
+
reason,
|
|
171
|
+
});
|
|
172
|
+
return entities.member(this.guildId, { ...raw, user: raw.user });
|
|
173
|
+
}
|
|
174
|
+
/** Changes the nickname of the member; `null` removes it. */
|
|
175
|
+
async setNick(nick, reason) {
|
|
176
|
+
const { rest, entities, self } = ctxOf(this);
|
|
177
|
+
if (self?.userId === this.id) {
|
|
178
|
+
// A bot renames itself through another endpoint.
|
|
179
|
+
// https://docs.discord.com/developers/resources/guild#modify-current-member
|
|
180
|
+
const raw = await rest.request(ModifyCurrentMember, [this.guildId], {
|
|
181
|
+
body: { nick },
|
|
182
|
+
reason,
|
|
183
|
+
});
|
|
184
|
+
return entities.member(this.guildId, raw);
|
|
185
|
+
}
|
|
186
|
+
return this.edit({ nick }, reason);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Gives a role to the member.
|
|
190
|
+
* @see https://docs.discord.com/developers/resources/guild#add-guild-member-role
|
|
191
|
+
*/
|
|
192
|
+
async addRole(role, reason) {
|
|
193
|
+
await ctxOf(this).rest.request(AddGuildMemberRole, [this.guildId, this.id, idOf(role)], { reason });
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Takes a role from the member.
|
|
197
|
+
* @see https://docs.discord.com/developers/resources/guild#remove-guild-member-role
|
|
198
|
+
*/
|
|
199
|
+
async removeRole(role, reason) {
|
|
200
|
+
await ctxOf(this).rest.request(RemoveGuildMemberRole, [this.guildId, this.id, idOf(role)], { reason });
|
|
201
|
+
}
|
|
202
|
+
/** Whether the member has a role. */
|
|
203
|
+
hasRole(role) {
|
|
204
|
+
const id = idOf(role);
|
|
205
|
+
return id === this.guildId || this.roleIds.includes(id);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Prevents the member from writing, reacting and speaking for a while.
|
|
209
|
+
* @param duration how long, in milliseconds (28 days at most)
|
|
210
|
+
*/
|
|
211
|
+
async timeout(duration, reason) {
|
|
212
|
+
if (!Number.isFinite(duration) || duration <= 0) {
|
|
213
|
+
throw new RangeError(`A timeout lasts a positive number of milliseconds, got ${duration}. Use removeTimeout() to end one.`);
|
|
214
|
+
}
|
|
215
|
+
return this.edit({ timeoutUntil: new Date(Date.now() + duration) }, reason);
|
|
216
|
+
}
|
|
217
|
+
/** Ends the timeout of the member. */
|
|
218
|
+
async removeTimeout(reason) {
|
|
219
|
+
return this.edit({ timeoutUntil: null }, reason);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Removes the member from the server; they can come back with an invite.
|
|
223
|
+
* @see https://docs.discord.com/developers/resources/guild#remove-guild-member
|
|
224
|
+
*/
|
|
225
|
+
async kick(reason) {
|
|
226
|
+
await ctxOf(this).rest.request(RemoveGuildMember, [this.guildId, this.id], {
|
|
227
|
+
reason,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Bans the member from the server.
|
|
232
|
+
* @see https://docs.discord.com/developers/resources/guild#create-guild-ban
|
|
233
|
+
*/
|
|
234
|
+
async ban(options = {}) {
|
|
235
|
+
await banUser(ctxOf(this), this.guildId, this.id, options);
|
|
236
|
+
}
|
|
237
|
+
/** Sends a private message to the member. */
|
|
238
|
+
async send(message) {
|
|
239
|
+
return this.user.send(message);
|
|
240
|
+
}
|
|
241
|
+
/** `<@id>`: mentions the member when put in a message. */
|
|
242
|
+
toString() {
|
|
243
|
+
return this.user.toString();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/** One mechanism to ban, used by members and servers. */
|
|
247
|
+
export async function banUser(ctx, guildId, userId, { reason, deleteMessageSeconds }) {
|
|
248
|
+
if (deleteMessageSeconds !== undefined &&
|
|
249
|
+
(!Number.isInteger(deleteMessageSeconds) ||
|
|
250
|
+
deleteMessageSeconds < 0 ||
|
|
251
|
+
deleteMessageSeconds > Limits.BanDeleteMessageSeconds)) {
|
|
252
|
+
throw new RangeError(`deleteMessageSeconds is a whole number between 0 and ${Limits.BanDeleteMessageSeconds} (7 days), got ${deleteMessageSeconds}.`);
|
|
253
|
+
}
|
|
254
|
+
await ctx.rest.request(CreateGuildBan, [guildId, userId], {
|
|
255
|
+
body: deleteMessageSeconds === undefined
|
|
256
|
+
? {}
|
|
257
|
+
: { delete_message_seconds: deleteMessageSeconds },
|
|
258
|
+
reason,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { StartThreadFromMessageJSONParams } from '../discord/types/channel.js';
|
|
2
|
+
import type { Snowflake } from '../discord/types/common.js';
|
|
3
|
+
import type { RawPartialEmoji } from '../discord/types/emoji.js';
|
|
4
|
+
import { MessageFlags, MessageType, type RawAttachment, type RawMessage, type RawReaction } from '../discord/types/message.js';
|
|
5
|
+
import { type Camelize } from '../util/case.js';
|
|
6
|
+
import { IdStructure } from './base.js';
|
|
7
|
+
import type { DMChannel, GuildTextBasedChannel, TextBasedChannel, ThreadChannel } from './channel.js';
|
|
8
|
+
import type { Context } from './context.js';
|
|
9
|
+
import type { Guild } from './guild.js';
|
|
10
|
+
import type { GuildMember } from './member.js';
|
|
11
|
+
import { type Embed, type MessageEditOptions, type MessageInput } from './payload.js';
|
|
12
|
+
import type { User } from './user.js';
|
|
13
|
+
/** What the message stores: users are kept as structures, not copies. */
|
|
14
|
+
export type MessageData = Omit<RawMessage, 'author' | 'mentions'> & {
|
|
15
|
+
guild_id?: Snowflake;
|
|
16
|
+
};
|
|
17
|
+
/** The name of a flag of a message: a key of `MessageFlags`. */
|
|
18
|
+
export type MessageFlagName = keyof typeof MessageFlags;
|
|
19
|
+
/** A file attached to a message. */
|
|
20
|
+
export type Attachment = Camelize<RawAttachment>;
|
|
21
|
+
/** The reactions of one emoji on a message. */
|
|
22
|
+
export type Reaction = Camelize<RawReaction>;
|
|
23
|
+
/**
|
|
24
|
+
* The emoji of a reaction: a standard one has only a `name` (`"👍"`), a
|
|
25
|
+
* custom one has an `id` too.
|
|
26
|
+
* @see https://docs.discord.com/developers/resources/emoji#emoji-object
|
|
27
|
+
*/
|
|
28
|
+
export type ReactionEmoji = Camelize<RawPartialEmoji>;
|
|
29
|
+
/** An emoji to react with: a standard one (`"👍"`), or a custom one. */
|
|
30
|
+
export type EmojiInput = string | {
|
|
31
|
+
id?: Snowflake | null;
|
|
32
|
+
name?: string | null;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A message sent in a channel.
|
|
36
|
+
* @see https://docs.discord.com/developers/resources/message#message-object
|
|
37
|
+
*/
|
|
38
|
+
export declare class Message extends IdStructure<MessageData> {
|
|
39
|
+
/** Who wrote the message. */
|
|
40
|
+
readonly author: User;
|
|
41
|
+
/** The users mentioned in the message. */
|
|
42
|
+
readonly mentions: readonly User[];
|
|
43
|
+
constructor(ctx: Context, data: MessageData, author: User, mentions: readonly User[]);
|
|
44
|
+
/** The id of the channel of the message. */
|
|
45
|
+
get channelId(): Snowflake;
|
|
46
|
+
/** The id of the server; `null` for a private message. */
|
|
47
|
+
get guildId(): Snowflake | null;
|
|
48
|
+
/** The channel of the message, when it is known. */
|
|
49
|
+
get channel(): TextBasedChannel | null;
|
|
50
|
+
/** The server of the message; `null` for a private message. */
|
|
51
|
+
get guild(): Guild | null;
|
|
52
|
+
/** The author as a member of the server, when it is known. */
|
|
53
|
+
get member(): GuildMember | null;
|
|
54
|
+
/**
|
|
55
|
+
* The text of the message. Empty when the bot is not allowed to read it:
|
|
56
|
+
* reading the messages of others needs the Message Content intent.
|
|
57
|
+
*/
|
|
58
|
+
get content(): string;
|
|
59
|
+
/** The kind of message, as a value of `MessageType` (a regular one, a reply, a join notice...). */
|
|
60
|
+
get type(): MessageType;
|
|
61
|
+
/** When the message was last edited; `null` when it never was. */
|
|
62
|
+
get editedAt(): Date | null;
|
|
63
|
+
/** Whether the message is pinned. */
|
|
64
|
+
get pinned(): boolean;
|
|
65
|
+
/** Whether the message was read aloud. */
|
|
66
|
+
get tts(): boolean;
|
|
67
|
+
/** The embeds of the message. */
|
|
68
|
+
get embeds(): Embed[];
|
|
69
|
+
/** The files attached to the message. */
|
|
70
|
+
get attachments(): Attachment[];
|
|
71
|
+
/** The reactions on the message, one entry per emoji. */
|
|
72
|
+
get reactions(): Reaction[];
|
|
73
|
+
/** Whether the message mentions @everyone or @here. */
|
|
74
|
+
get mentionsEveryone(): boolean;
|
|
75
|
+
/** The ids of the roles mentioned in the message. */
|
|
76
|
+
get mentionedRoleIds(): readonly Snowflake[];
|
|
77
|
+
/** The flags of the message, by name (`Ephemeral`, `SuppressEmbeds`...). */
|
|
78
|
+
get flags(): MessageFlagName[];
|
|
79
|
+
/** The id of the webhook that sent the message, when one did. */
|
|
80
|
+
get webhookId(): Snowflake | null;
|
|
81
|
+
/** The id of the message this one replies to, when it is a reply. */
|
|
82
|
+
get repliedMessageId(): Snowflake | null;
|
|
83
|
+
/** Whether a person wrote it: not a bot, a webhook or Discord itself. */
|
|
84
|
+
get isFromUser(): boolean;
|
|
85
|
+
/** The link that opens the message in Discord. */
|
|
86
|
+
get url(): string;
|
|
87
|
+
/** Asks Discord for the latest version of the message. */
|
|
88
|
+
fetch(): Promise<Message>;
|
|
89
|
+
/**
|
|
90
|
+
* Answers the message, in the same channel.
|
|
91
|
+
* @see https://docs.discord.com/developers/resources/message#create-message
|
|
92
|
+
*/
|
|
93
|
+
reply(message: MessageInput): Promise<Message>;
|
|
94
|
+
/**
|
|
95
|
+
* Changes the message. Only the content, embeds, components and files of
|
|
96
|
+
* a message the bot wrote can change.
|
|
97
|
+
* @see https://docs.discord.com/developers/resources/message#edit-message
|
|
98
|
+
*/
|
|
99
|
+
edit(message: string | MessageEditOptions): Promise<Message>;
|
|
100
|
+
/**
|
|
101
|
+
* Deletes the message.
|
|
102
|
+
* @see https://docs.discord.com/developers/resources/message#delete-message
|
|
103
|
+
*/
|
|
104
|
+
delete(reason?: string): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Adds a reaction of the bot to the message.
|
|
107
|
+
* @see https://docs.discord.com/developers/resources/message#create-reaction
|
|
108
|
+
*/
|
|
109
|
+
react(emoji: EmojiInput): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Removes a reaction: of the bot, or of the given user.
|
|
112
|
+
* @see https://docs.discord.com/developers/resources/message#delete-user-reaction
|
|
113
|
+
*/
|
|
114
|
+
removeReaction(emoji: EmojiInput, user?: Snowflake | {
|
|
115
|
+
id: Snowflake;
|
|
116
|
+
}): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Removes every reaction of the message, or every reaction of one emoji.
|
|
119
|
+
* @see https://docs.discord.com/developers/resources/message#delete-all-reactions
|
|
120
|
+
*/
|
|
121
|
+
clearReactions(emoji?: EmojiInput): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* The users who reacted with an emoji (100 at most per call).
|
|
124
|
+
* @see https://docs.discord.com/developers/resources/message#get-reactions
|
|
125
|
+
*/
|
|
126
|
+
fetchReactionUsers(emoji: EmojiInput, options?: {
|
|
127
|
+
limit?: number;
|
|
128
|
+
after?: Snowflake;
|
|
129
|
+
}): Promise<User[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Pins the message in its channel.
|
|
132
|
+
* @see https://docs.discord.com/developers/resources/message#pin-message
|
|
133
|
+
*/
|
|
134
|
+
pin(reason?: string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Unpins the message.
|
|
137
|
+
* @see https://docs.discord.com/developers/resources/message#unpin-message
|
|
138
|
+
*/
|
|
139
|
+
unpin(reason?: string): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Publishes a message of an announcement channel to the servers that
|
|
142
|
+
* follow it.
|
|
143
|
+
* @see https://docs.discord.com/developers/resources/message#crosspost-message
|
|
144
|
+
*/
|
|
145
|
+
crosspost(): Promise<Message>;
|
|
146
|
+
/**
|
|
147
|
+
* Starts a thread from the message.
|
|
148
|
+
* @see https://docs.discord.com/developers/resources/channel#start-thread-from-message
|
|
149
|
+
*/
|
|
150
|
+
startThread(options: Camelize<StartThreadFromMessageJSONParams>, reason?: string): Promise<ThreadChannel>;
|
|
151
|
+
}
|
|
152
|
+
/** One mechanism to send a message, used by channels, replies and users. */
|
|
153
|
+
export declare function sendMessage(ctx: Context, channelId: Snowflake, message: MessageInput, guildId?: Snowflake): Promise<Message>;
|
|
154
|
+
/**
|
|
155
|
+
* A message of a server: its server is known. It is what the events about
|
|
156
|
+
* messages give for what happens in a server.
|
|
157
|
+
*/
|
|
158
|
+
export interface GuildMessage extends Message {
|
|
159
|
+
/** The id of the server. */
|
|
160
|
+
readonly guildId: Snowflake;
|
|
161
|
+
/** The server of the message. */
|
|
162
|
+
readonly guild: Guild;
|
|
163
|
+
/** The channel of the message. */
|
|
164
|
+
readonly channel: GuildTextBasedChannel;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A message written in a server by one of its members: neither a private
|
|
168
|
+
* message nor the message of a webhook. It is what the events about
|
|
169
|
+
* messages give by default.
|
|
170
|
+
*/
|
|
171
|
+
export interface MemberMessage extends GuildMessage {
|
|
172
|
+
/** The author as a member of the server. */
|
|
173
|
+
readonly member: GuildMember;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* A private message, for a file that receives both kinds
|
|
177
|
+
* (`{ where: 'both' }`): there is no server, which is how it is told apart
|
|
178
|
+
* from a `GuildMessage`.
|
|
179
|
+
*/
|
|
180
|
+
export interface PrivateMessage extends Message {
|
|
181
|
+
/** No server: it is a private message. */
|
|
182
|
+
readonly guildId: null;
|
|
183
|
+
/** No server: it is a private message. */
|
|
184
|
+
readonly guild: null;
|
|
185
|
+
/** No member: the author is `author`. */
|
|
186
|
+
readonly member: null;
|
|
187
|
+
/** The private conversation, when the bot knows it. */
|
|
188
|
+
readonly channel: DMChannel | null;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A private message, for a file that only receives those
|
|
192
|
+
* (`{ where: 'dm' }`): nothing about a server exists on it.
|
|
193
|
+
*/
|
|
194
|
+
export interface DmMessage extends Omit<Message, 'guildId' | 'guild' | 'member' | 'channel'> {
|
|
195
|
+
/** The private conversation, when the bot knows it. */
|
|
196
|
+
readonly channel: DMChannel | null;
|
|
197
|
+
}
|