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,466 @@
|
|
|
1
|
+
import { Limits } from '../discord/api.js';
|
|
2
|
+
import { cdn } from '../discord/cdn.js';
|
|
3
|
+
import { BulkGuildBan, CreateGuildChannel, CreateGuildEmoji, CreateGuildRole, CreateGuildScheduledEvent, GetGuild, GetGuildAuditLog, GetGuildBan, GetGuildBans, GetGuildChannels, GetGuildInvites, GetGuildMember, GetGuildRoles, GetGuildWebhooks, LeaveGuild, ListActiveGuildThreads, ListAutoModerationRulesForGuild, ListGuildEmojis, ListGuildMembers, ListGuildStickers, ListScheduledEventsForGuild, ModifyGuild, RemoveGuildBan, RemoveGuildMember, SearchGuildMembers, } from '../discord/endpoints.js';
|
|
4
|
+
import { Permissions } from '../discord/permissions.js';
|
|
5
|
+
import { toCamelCase, toSnakeCase } from '../util/case.js';
|
|
6
|
+
import { ctxOf, dataOf, idOf, IdStructure } from './base.js';
|
|
7
|
+
import { knownMember } from './known.js';
|
|
8
|
+
import { banUser } from './member.js';
|
|
9
|
+
/** Only the framework writes to the stores of a server. */
|
|
10
|
+
export let storesOf;
|
|
11
|
+
/**
|
|
12
|
+
* A server ("guild" is the name Discord gives servers in its API).
|
|
13
|
+
* @see https://docs.discord.com/developers/resources/guild#guild-object
|
|
14
|
+
*/
|
|
15
|
+
export class Guild extends IdStructure {
|
|
16
|
+
#stores;
|
|
17
|
+
static {
|
|
18
|
+
storesOf = guild => guild.#stores;
|
|
19
|
+
}
|
|
20
|
+
constructor(ctx, data) {
|
|
21
|
+
super(ctx, data);
|
|
22
|
+
const { createStore, limits } = ctx.cache;
|
|
23
|
+
this.#stores = {
|
|
24
|
+
roles: createStore(),
|
|
25
|
+
members: createStore({ limit: limits.members }),
|
|
26
|
+
channels: createStore(),
|
|
27
|
+
emojis: createStore(),
|
|
28
|
+
voiceStates: createStore(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** The name of the server. */
|
|
32
|
+
get name() {
|
|
33
|
+
return dataOf(this).name;
|
|
34
|
+
}
|
|
35
|
+
/** The description of the server, when it has one. */
|
|
36
|
+
get description() {
|
|
37
|
+
return dataOf(this).description ?? null;
|
|
38
|
+
}
|
|
39
|
+
/** The id of the user who owns the server. */
|
|
40
|
+
get ownerId() {
|
|
41
|
+
return dataOf(this).owner_id;
|
|
42
|
+
}
|
|
43
|
+
/** `false` during an outage of Discord: the data may be out of date. */
|
|
44
|
+
get available() {
|
|
45
|
+
return !dataOf(this).unavailable;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* How many members the server has. Exact when the bot receives member
|
|
49
|
+
* events, approximate otherwise; `null` when Discord never said it.
|
|
50
|
+
*/
|
|
51
|
+
get memberCount() {
|
|
52
|
+
const data = dataOf(this);
|
|
53
|
+
return data.member_count ?? data.approximate_member_count ?? null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* What the server has enabled or unlocked (`COMMUNITY`, `VANITY_URL`...).
|
|
57
|
+
* @see https://docs.discord.com/developers/resources/guild#guild-object-guild-features
|
|
58
|
+
*/
|
|
59
|
+
get features() {
|
|
60
|
+
return dataOf(this).features ?? [];
|
|
61
|
+
}
|
|
62
|
+
/** What Discord asks of new members before they can write. */
|
|
63
|
+
get verificationLevel() {
|
|
64
|
+
return dataOf(this).verification_level;
|
|
65
|
+
}
|
|
66
|
+
/** The boost level of the server. */
|
|
67
|
+
get premiumTier() {
|
|
68
|
+
return dataOf(this).premium_tier;
|
|
69
|
+
}
|
|
70
|
+
/** How many boosts the server has. */
|
|
71
|
+
get boostCount() {
|
|
72
|
+
return dataOf(this).premium_subscription_count ?? 0;
|
|
73
|
+
}
|
|
74
|
+
/** The language of the server, used for what Discord sends to it. */
|
|
75
|
+
get preferredLocale() {
|
|
76
|
+
return dataOf(this).preferred_locale;
|
|
77
|
+
}
|
|
78
|
+
/** The code of the custom invite link of the server, when it has one. */
|
|
79
|
+
get vanityUrlCode() {
|
|
80
|
+
return dataOf(this).vanity_url_code ?? null;
|
|
81
|
+
}
|
|
82
|
+
/** The id of the channel where Discord posts welcome messages. */
|
|
83
|
+
get systemChannelId() {
|
|
84
|
+
return dataOf(this).system_channel_id ?? null;
|
|
85
|
+
}
|
|
86
|
+
/** The id of the channel that shows the rules, in a community server. */
|
|
87
|
+
get rulesChannelId() {
|
|
88
|
+
return dataOf(this).rules_channel_id ?? null;
|
|
89
|
+
}
|
|
90
|
+
/** The id of the voice channel inactive members are moved to. */
|
|
91
|
+
get afkChannelId() {
|
|
92
|
+
return dataOf(this).afk_channel_id ?? null;
|
|
93
|
+
}
|
|
94
|
+
/** When the bot joined the server, when Discord said it. */
|
|
95
|
+
get joinedAt() {
|
|
96
|
+
const joined = dataOf(this).joined_at;
|
|
97
|
+
return joined ? new Date(joined) : null;
|
|
98
|
+
}
|
|
99
|
+
/** The roles of the server, @everyone included. */
|
|
100
|
+
get roles() {
|
|
101
|
+
return this.#stores.roles;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The members of the server the bot knows: the ones seen the most
|
|
105
|
+
* recently, not all of them.
|
|
106
|
+
*/
|
|
107
|
+
get members() {
|
|
108
|
+
return this.#stores.members;
|
|
109
|
+
}
|
|
110
|
+
/** The channels and active threads of the server. */
|
|
111
|
+
get channels() {
|
|
112
|
+
return this.#stores.channels;
|
|
113
|
+
}
|
|
114
|
+
/** The custom emojis of the server. */
|
|
115
|
+
get emojis() {
|
|
116
|
+
return this.#stores.emojis;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The bot in voice in this server, to play or leave; `null` when it is
|
|
120
|
+
* in no voice channel here.
|
|
121
|
+
*/
|
|
122
|
+
get voice() {
|
|
123
|
+
return ctxOf(this).voice?.connectionOf(this.id) ?? null;
|
|
124
|
+
}
|
|
125
|
+
/** The @everyone role, which every member has. */
|
|
126
|
+
get everyoneRole() {
|
|
127
|
+
const role = this.#stores.roles.get(this.id);
|
|
128
|
+
if (!role)
|
|
129
|
+
throw this.#notReceived('roles');
|
|
130
|
+
return role;
|
|
131
|
+
}
|
|
132
|
+
/** The bot as a member of this server. */
|
|
133
|
+
get me() {
|
|
134
|
+
const self = ctxOf(this).self;
|
|
135
|
+
// Kept apart too: a limit on how many members are remembered must
|
|
136
|
+
// never make the bot forget itself.
|
|
137
|
+
const member = (self ? this.#stores.members.get(self.userId) : undefined) ??
|
|
138
|
+
knownMember(this);
|
|
139
|
+
if (!member)
|
|
140
|
+
throw this.#notReceived('members');
|
|
141
|
+
return member;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Discord sends the roles of a server and the bot as one of its members
|
|
145
|
+
* with the server itself: they are only missing while it is unavailable.
|
|
146
|
+
*/
|
|
147
|
+
#notReceived(what) {
|
|
148
|
+
return new Error(`Discord has not sent the ${what} of the server ${this.id}${this.available ? '' : ', which is unavailable (an outage on their side)'}.`);
|
|
149
|
+
}
|
|
150
|
+
/** The URL of the icon of the server, when it has one. */
|
|
151
|
+
iconURL(options) {
|
|
152
|
+
const icon = dataOf(this).icon;
|
|
153
|
+
return icon ? cdn.guildIcon(this.id, icon, options) : null;
|
|
154
|
+
}
|
|
155
|
+
/** The URL of the banner of the server, when it has one. */
|
|
156
|
+
bannerURL(options) {
|
|
157
|
+
const banner = dataOf(this).banner;
|
|
158
|
+
return banner ? cdn.guildBanner(this.id, banner, options) : null;
|
|
159
|
+
}
|
|
160
|
+
/** The URL of the invite background of the server, when it has one. */
|
|
161
|
+
splashURL(options) {
|
|
162
|
+
const splash = dataOf(this).splash;
|
|
163
|
+
return splash ? cdn.guildSplash(this.id, splash, options) : null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Asks Discord for the latest data of the server.
|
|
167
|
+
* @see https://docs.discord.com/developers/resources/guild#get-guild
|
|
168
|
+
*/
|
|
169
|
+
async fetch() {
|
|
170
|
+
const { rest, entities } = ctxOf(this);
|
|
171
|
+
const raw = await rest.request(GetGuild, [this.id], {
|
|
172
|
+
query: { with_counts: true },
|
|
173
|
+
});
|
|
174
|
+
return entities.guild(raw);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Changes the settings of the server.
|
|
178
|
+
* @see https://docs.discord.com/developers/resources/guild#modify-guild
|
|
179
|
+
*/
|
|
180
|
+
async edit(options, reason) {
|
|
181
|
+
const { rest, entities } = ctxOf(this);
|
|
182
|
+
const raw = await rest.request(ModifyGuild, [this.id], {
|
|
183
|
+
body: toSnakeCase(options),
|
|
184
|
+
reason,
|
|
185
|
+
});
|
|
186
|
+
return entities.guild(raw);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Makes the bot leave the server.
|
|
190
|
+
* @see https://docs.discord.com/developers/resources/user#leave-guild
|
|
191
|
+
*/
|
|
192
|
+
async leave() {
|
|
193
|
+
await ctxOf(this).rest.request(LeaveGuild, [this.id]);
|
|
194
|
+
}
|
|
195
|
+
// -- Members ---------------------------------------------------------------
|
|
196
|
+
/**
|
|
197
|
+
* A member of the server: from what the bot remembers, or else from Discord.
|
|
198
|
+
* @see https://docs.discord.com/developers/resources/guild#get-guild-member
|
|
199
|
+
*/
|
|
200
|
+
async fetchMember(user, { force = false } = {}) {
|
|
201
|
+
const { rest, entities } = ctxOf(this);
|
|
202
|
+
const id = idOf(user);
|
|
203
|
+
const cached = force ? undefined : this.#stores.members.get(id);
|
|
204
|
+
if (cached)
|
|
205
|
+
return cached;
|
|
206
|
+
return entities.member(this.id, await rest.request(GetGuildMember, [this.id, id]));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Members of the server, by pages of 1000 at most, ordered by id. Needs
|
|
210
|
+
* the Server Members intent to be enabled for the bot.
|
|
211
|
+
* @see https://docs.discord.com/developers/resources/guild#list-guild-members
|
|
212
|
+
*/
|
|
213
|
+
async fetchMembers(options = {}) {
|
|
214
|
+
const { rest, entities } = ctxOf(this);
|
|
215
|
+
const limit = options.limit ?? Limits.ListGuildMembers;
|
|
216
|
+
if (!Number.isInteger(limit) ||
|
|
217
|
+
limit < 1 ||
|
|
218
|
+
limit > Limits.ListGuildMembers) {
|
|
219
|
+
throw new RangeError(`limit is a whole number between 1 and ${Limits.ListGuildMembers}, got ${limit}.`);
|
|
220
|
+
}
|
|
221
|
+
const raw = await rest.request(ListGuildMembers, [this.id], {
|
|
222
|
+
query: { limit, after: options.after && idOf(options.after) },
|
|
223
|
+
});
|
|
224
|
+
return raw.map(member => entities.member(this.id, member));
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Members whose username or nickname starts with the given text.
|
|
228
|
+
* @see https://docs.discord.com/developers/resources/guild#search-guild-members
|
|
229
|
+
*/
|
|
230
|
+
async searchMembers(query, limit = 1) {
|
|
231
|
+
const { rest, entities } = ctxOf(this);
|
|
232
|
+
const raw = await rest.request(SearchGuildMembers, [this.id], {
|
|
233
|
+
query: { query, limit },
|
|
234
|
+
});
|
|
235
|
+
return raw.map(member => entities.member(this.id, member));
|
|
236
|
+
}
|
|
237
|
+
/** The member who owns the server. */
|
|
238
|
+
async fetchOwner() {
|
|
239
|
+
return this.fetchMember(this.ownerId);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Removes a member from the server; they can come back with an invite.
|
|
243
|
+
* @see https://docs.discord.com/developers/resources/guild#remove-guild-member
|
|
244
|
+
*/
|
|
245
|
+
async kick(user, reason) {
|
|
246
|
+
await ctxOf(this).rest.request(RemoveGuildMember, [this.id, idOf(user)], {
|
|
247
|
+
reason,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
// -- Bans ------------------------------------------------------------------
|
|
251
|
+
/**
|
|
252
|
+
* Bans a user from the server, member or not.
|
|
253
|
+
* @see https://docs.discord.com/developers/resources/guild#create-guild-ban
|
|
254
|
+
*/
|
|
255
|
+
async ban(user, options = {}) {
|
|
256
|
+
await banUser(ctxOf(this), this.id, idOf(user), options);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Bans up to 200 users at once.
|
|
260
|
+
* @returns the ids of the users that were banned, and of those that could not be
|
|
261
|
+
* @see https://docs.discord.com/developers/resources/guild#bulk-guild-ban
|
|
262
|
+
*/
|
|
263
|
+
async bulkBan(users, options = {}) {
|
|
264
|
+
if (users.length === 0 || users.length > Limits.BulkBanUsers) {
|
|
265
|
+
throw new RangeError(`bulkBan() takes between 1 and ${Limits.BulkBanUsers} users, got ${users.length}.`);
|
|
266
|
+
}
|
|
267
|
+
const raw = await ctxOf(this).rest.request(BulkGuildBan, [this.id], {
|
|
268
|
+
body: {
|
|
269
|
+
user_ids: users.map(idOf),
|
|
270
|
+
delete_message_seconds: options.deleteMessageSeconds,
|
|
271
|
+
},
|
|
272
|
+
reason: options.reason,
|
|
273
|
+
});
|
|
274
|
+
return toCamelCase(raw);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Lifts the ban of a user.
|
|
278
|
+
* @see https://docs.discord.com/developers/resources/guild#remove-guild-ban
|
|
279
|
+
*/
|
|
280
|
+
async unban(user, reason) {
|
|
281
|
+
await ctxOf(this).rest.request(RemoveGuildBan, [this.id, idOf(user)], {
|
|
282
|
+
reason,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The ban of a user; `null` when they are not banned.
|
|
287
|
+
* @see https://docs.discord.com/developers/resources/guild#get-guild-ban
|
|
288
|
+
*/
|
|
289
|
+
async fetchBan(user) {
|
|
290
|
+
const { rest, entities } = ctxOf(this);
|
|
291
|
+
try {
|
|
292
|
+
const raw = await rest.request(GetGuildBan, [this.id, idOf(user)]);
|
|
293
|
+
return { user: entities.user(raw.user), reason: raw.reason };
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
// 10026: Unknown ban.
|
|
297
|
+
if (error?.code === 10026)
|
|
298
|
+
return null;
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The bans of the server, by pages of 1000 at most.
|
|
304
|
+
* @see https://docs.discord.com/developers/resources/guild#get-guild-bans
|
|
305
|
+
*/
|
|
306
|
+
async fetchBans(options = {}) {
|
|
307
|
+
const { rest, entities } = ctxOf(this);
|
|
308
|
+
const raw = await rest.request(GetGuildBans, [this.id], { query: options });
|
|
309
|
+
return raw.map(ban => ({
|
|
310
|
+
user: entities.user(ban.user),
|
|
311
|
+
reason: ban.reason,
|
|
312
|
+
}));
|
|
313
|
+
}
|
|
314
|
+
// -- Roles -----------------------------------------------------------------
|
|
315
|
+
/**
|
|
316
|
+
* Asks Discord for the roles of the server.
|
|
317
|
+
* @see https://docs.discord.com/developers/resources/guild#get-guild-roles
|
|
318
|
+
*/
|
|
319
|
+
async fetchRoles() {
|
|
320
|
+
const { rest, entities } = ctxOf(this);
|
|
321
|
+
const raw = await rest.request(GetGuildRoles, [this.id]);
|
|
322
|
+
return raw.map(role => entities.role(this.id, role));
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Creates a role.
|
|
326
|
+
* @see https://docs.discord.com/developers/resources/guild#create-guild-role
|
|
327
|
+
*/
|
|
328
|
+
async createRole(options = {}, reason) {
|
|
329
|
+
const { rest, entities } = ctxOf(this);
|
|
330
|
+
const { permissions, ...others } = options;
|
|
331
|
+
const body = toSnakeCase(others);
|
|
332
|
+
if (permissions !== undefined) {
|
|
333
|
+
body.permissions = new Permissions(permissions).toString();
|
|
334
|
+
}
|
|
335
|
+
const raw = await rest.request(CreateGuildRole, [this.id], {
|
|
336
|
+
body,
|
|
337
|
+
reason,
|
|
338
|
+
});
|
|
339
|
+
return entities.role(this.id, raw);
|
|
340
|
+
}
|
|
341
|
+
// -- Channels --------------------------------------------------------------
|
|
342
|
+
/**
|
|
343
|
+
* The channels of the server (threads are not included).
|
|
344
|
+
* @see https://docs.discord.com/developers/resources/guild#get-guild-channels
|
|
345
|
+
*/
|
|
346
|
+
async fetchChannels() {
|
|
347
|
+
const { rest, entities } = ctxOf(this);
|
|
348
|
+
const raw = await rest.request(GetGuildChannels, [this.id]);
|
|
349
|
+
return raw.map(channel => entities.channel(channel, this.id));
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Creates a channel.
|
|
353
|
+
* @see https://docs.discord.com/developers/resources/guild#create-guild-channel
|
|
354
|
+
*/
|
|
355
|
+
async createChannel(options, reason) {
|
|
356
|
+
const { rest, entities } = ctxOf(this);
|
|
357
|
+
const raw = await rest.request(CreateGuildChannel, [this.id], {
|
|
358
|
+
body: toSnakeCase(options),
|
|
359
|
+
reason,
|
|
360
|
+
});
|
|
361
|
+
return entities.channel(raw, this.id);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The threads of the server that are not archived.
|
|
365
|
+
* @see https://docs.discord.com/developers/resources/guild#list-active-guild-threads
|
|
366
|
+
*/
|
|
367
|
+
async fetchActiveThreads() {
|
|
368
|
+
const { rest, entities } = ctxOf(this);
|
|
369
|
+
const raw = await rest.request(ListActiveGuildThreads, [this.id]);
|
|
370
|
+
return raw.threads.map(thread => entities.channel(thread, this.id));
|
|
371
|
+
}
|
|
372
|
+
// -- Everything else -------------------------------------------------------
|
|
373
|
+
/**
|
|
374
|
+
* Asks Discord for the custom emojis of the server.
|
|
375
|
+
* @see https://docs.discord.com/developers/resources/emoji#list-guild-emojis
|
|
376
|
+
*/
|
|
377
|
+
async fetchEmojis() {
|
|
378
|
+
const { rest, entities } = ctxOf(this);
|
|
379
|
+
const raw = await rest.request(ListGuildEmojis, [this.id]);
|
|
380
|
+
return raw.map(emoji => entities.emoji(this.id, emoji));
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Adds a custom emoji to the server.
|
|
384
|
+
* @param options.image the image as a data URI (`data:image/png;base64,...`)
|
|
385
|
+
* @see https://docs.discord.com/developers/resources/emoji#create-guild-emoji
|
|
386
|
+
*/
|
|
387
|
+
async createEmoji(options, reason) {
|
|
388
|
+
const { rest, entities } = ctxOf(this);
|
|
389
|
+
const raw = await rest.request(CreateGuildEmoji, [this.id], {
|
|
390
|
+
body: {
|
|
391
|
+
name: options.name,
|
|
392
|
+
image: options.image,
|
|
393
|
+
roles: options.roles?.map(idOf) ?? [],
|
|
394
|
+
},
|
|
395
|
+
reason,
|
|
396
|
+
});
|
|
397
|
+
return entities.emoji(this.id, raw);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* The invites of the server, with how many times each was used.
|
|
401
|
+
* @see https://docs.discord.com/developers/resources/guild#get-guild-invites
|
|
402
|
+
*/
|
|
403
|
+
async fetchInvites() {
|
|
404
|
+
const { rest, entities } = ctxOf(this);
|
|
405
|
+
const raw = await rest.request(GetGuildInvites, [this.id]);
|
|
406
|
+
return raw.map(invite => entities.invite(invite));
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* The webhooks of every channel of the server.
|
|
410
|
+
* @see https://docs.discord.com/developers/resources/webhook#get-guild-webhooks
|
|
411
|
+
*/
|
|
412
|
+
async fetchWebhooks() {
|
|
413
|
+
const { rest, entities } = ctxOf(this);
|
|
414
|
+
const raw = await rest.request(GetGuildWebhooks, [this.id]);
|
|
415
|
+
return raw.map(webhook => entities.webhook(webhook));
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* What moderators and bots did in the server.
|
|
419
|
+
* @see https://docs.discord.com/developers/resources/audit-log#get-guild-audit-log
|
|
420
|
+
*/
|
|
421
|
+
async fetchAuditLog(options = {}) {
|
|
422
|
+
const raw = await ctxOf(this).rest.request(GetGuildAuditLog, [this.id], {
|
|
423
|
+
query: toSnakeCase(options),
|
|
424
|
+
});
|
|
425
|
+
return toCamelCase(raw);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* The scheduled events of the server.
|
|
429
|
+
* @see https://docs.discord.com/developers/resources/guild-scheduled-event#list-scheduled-events-for-guild
|
|
430
|
+
*/
|
|
431
|
+
async fetchScheduledEvents() {
|
|
432
|
+
const raw = await ctxOf(this).rest.request(ListScheduledEventsForGuild, [this.id], { query: { with_user_count: true } });
|
|
433
|
+
return toCamelCase(raw);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Schedules an event in the server.
|
|
437
|
+
* @see https://docs.discord.com/developers/resources/guild-scheduled-event#create-guild-scheduled-event
|
|
438
|
+
*/
|
|
439
|
+
async createScheduledEvent(options, reason) {
|
|
440
|
+
const raw = await ctxOf(this).rest.request(CreateGuildScheduledEvent, [this.id], {
|
|
441
|
+
body: toSnakeCase(options),
|
|
442
|
+
reason,
|
|
443
|
+
});
|
|
444
|
+
return toCamelCase(raw);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* The auto moderation rules of the server.
|
|
448
|
+
* @see https://docs.discord.com/developers/resources/auto-moderation#list-auto-moderation-rules-for-guild
|
|
449
|
+
*/
|
|
450
|
+
async fetchAutoModerationRules() {
|
|
451
|
+
const raw = await ctxOf(this).rest.request(ListAutoModerationRulesForGuild, [this.id]);
|
|
452
|
+
return toCamelCase(raw);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* The custom stickers of the server.
|
|
456
|
+
* @see https://docs.discord.com/developers/resources/sticker#list-guild-stickers
|
|
457
|
+
*/
|
|
458
|
+
async fetchStickers() {
|
|
459
|
+
const raw = await ctxOf(this).rest.request(ListGuildStickers, [this.id]);
|
|
460
|
+
return toCamelCase(raw);
|
|
461
|
+
}
|
|
462
|
+
/** The name of the server. */
|
|
463
|
+
toString() {
|
|
464
|
+
return this.name;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { ModalComponent } from '../components/instance.js';
|
|
2
|
+
import type { Locale, Snowflake } from '../discord/types/common.js';
|
|
3
|
+
import { type RawInteraction } from '../discord/types/interaction.js';
|
|
4
|
+
import type { Camelize } from '../util/case.js';
|
|
5
|
+
import { IdStructure } from './base.js';
|
|
6
|
+
import type { DMChannel, GuildTextBasedChannel, TextBasedChannel } from './channel.js';
|
|
7
|
+
import type { Context } from './context.js';
|
|
8
|
+
import type { Guild } from './guild.js';
|
|
9
|
+
import type { GuildMember } from './member.js';
|
|
10
|
+
import type { Message } from './message.js';
|
|
11
|
+
import { type MessageEditOptions, type MessageOptions } from './payload.js';
|
|
12
|
+
import type { User } from './user.js';
|
|
13
|
+
export type InteractionData = Omit<RawInteraction, 'user' | 'member' | 'message'>;
|
|
14
|
+
/** Only the framework reads how far an interaction was answered. */
|
|
15
|
+
export declare let isUpdating: (interaction: Interaction) => boolean;
|
|
16
|
+
/** An answer to an interaction: its text, or its options. */
|
|
17
|
+
export type InteractionReply = string | InteractionReplyOptions;
|
|
18
|
+
/** The options of an answer: everything a message takes, except `replyTo` and `stickers`. */
|
|
19
|
+
export interface InteractionReplyOptions extends Omit<MessageOptions, 'replyTo' | 'stickers'> {
|
|
20
|
+
/**
|
|
21
|
+
* Only show the answer to who used the command. By default: what the
|
|
22
|
+
* command says with its own `ephemeral`, else visible to everyone.
|
|
23
|
+
*/
|
|
24
|
+
ephemeral?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Someone used something of the bot (a command...) and waits for an answer.
|
|
28
|
+
* Discord wants a first answer within 3 seconds, and accepts edits and
|
|
29
|
+
* other messages for 15 minutes.
|
|
30
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding
|
|
31
|
+
*/
|
|
32
|
+
export declare class Interaction extends IdStructure<InteractionData> {
|
|
33
|
+
#private;
|
|
34
|
+
/** Who did it. */
|
|
35
|
+
readonly user: User;
|
|
36
|
+
constructor(ctx: Context, data: InteractionData, user: User, { ephemeral }?: {
|
|
37
|
+
ephemeral?: boolean;
|
|
38
|
+
});
|
|
39
|
+
/** The id of the server; `null` in a private message. */
|
|
40
|
+
get guildId(): Snowflake | null;
|
|
41
|
+
/** The id of the channel it happened in. */
|
|
42
|
+
get channelId(): Snowflake;
|
|
43
|
+
/** The server it happened in; `null` in a private message. */
|
|
44
|
+
get guild(): Guild | null;
|
|
45
|
+
/** The channel it happened in: Discord sends it with the interaction. */
|
|
46
|
+
get channel(): TextBasedChannel;
|
|
47
|
+
/** Who did it, as a member of the server; `null` in a private message. */
|
|
48
|
+
get member(): GuildMember | null;
|
|
49
|
+
/** The language of the person: use it to answer in their language. */
|
|
50
|
+
get locale(): Locale;
|
|
51
|
+
/** Whether an answer was sent, or promised with `defer()`. */
|
|
52
|
+
get answered(): boolean;
|
|
53
|
+
/** Whether `defer()` was called and the answer is still to come. */
|
|
54
|
+
get deferred(): boolean;
|
|
55
|
+
/** The data of the interaction, without its token: a token is a secret. */
|
|
56
|
+
toJSON(): Camelize<InteractionData>;
|
|
57
|
+
/**
|
|
58
|
+
* Answers. If `defer()` was called (by you, or by the framework because
|
|
59
|
+
* the answer was taking long), this completes the pending answer.
|
|
60
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#create-interaction-response
|
|
61
|
+
*/
|
|
62
|
+
reply(message: InteractionReply): Promise<Message>;
|
|
63
|
+
/**
|
|
64
|
+
* Tells Discord the answer is coming: the person sees "thinking…" and
|
|
65
|
+
* `reply()` can then take up to 15 minutes. The framework does it by
|
|
66
|
+
* itself when an answer takes long; call it yourself to choose when.
|
|
67
|
+
*/
|
|
68
|
+
defer({ ephemeral }?: {
|
|
69
|
+
ephemeral?: boolean;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Changes the answer.
|
|
73
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#edit-original-interaction-response
|
|
74
|
+
*/
|
|
75
|
+
edit(message: string | MessageEditOptions): Promise<Message>;
|
|
76
|
+
/**
|
|
77
|
+
* Sends another message, after the answer.
|
|
78
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#create-followup-message
|
|
79
|
+
*/
|
|
80
|
+
followUp(message: InteractionReply): Promise<Message>;
|
|
81
|
+
/**
|
|
82
|
+
* Deletes the answer.
|
|
83
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#delete-original-interaction-response
|
|
84
|
+
*/
|
|
85
|
+
delete(): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
/** Someone used a slash command. */
|
|
88
|
+
export declare class CommandInteraction extends Interaction {
|
|
89
|
+
/** The command as the person typed it: `/mod ban`. */
|
|
90
|
+
readonly commandName: string;
|
|
91
|
+
constructor(ctx: Context, data: InteractionData, user: User, options: {
|
|
92
|
+
ephemeral?: boolean;
|
|
93
|
+
commandName: string;
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Opens a form, as the answer: `showModal(report({ userId }))`, with a
|
|
97
|
+
* form of `src/components/modals/`. It must be the first answer, and the
|
|
98
|
+
* person has as long as they want to fill it in.
|
|
99
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#interaction-response-object-modal
|
|
100
|
+
*/
|
|
101
|
+
showModal(form: ModalComponent): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Someone clicked a button or picked something in a select menu of a
|
|
105
|
+
* message of the bot. It can answer like a command, or change the message
|
|
106
|
+
* the component is on.
|
|
107
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#interaction-object-message-component-data-structure
|
|
108
|
+
*/
|
|
109
|
+
export declare class ComponentInteraction extends Interaction {
|
|
110
|
+
/** The message the component is on. */
|
|
111
|
+
readonly message: Message;
|
|
112
|
+
constructor(ctx: Context, data: InteractionData, user: User, options: {
|
|
113
|
+
ephemeral?: boolean;
|
|
114
|
+
message: Message;
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Changes the message the component is on, as the answer: its text, its
|
|
118
|
+
* embeds, its components, its files. Only what you pass changes;
|
|
119
|
+
* `components: []` removes the buttons and menus.
|
|
120
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type
|
|
121
|
+
*/
|
|
122
|
+
update(message: string | MessageEditOptions): Promise<Message>;
|
|
123
|
+
/**
|
|
124
|
+
* Tells Discord the message will change later: the person sees nothing
|
|
125
|
+
* meanwhile, and `update()` can then take up to 15 minutes. The
|
|
126
|
+
* framework does it by itself when an answer takes long.
|
|
127
|
+
*/
|
|
128
|
+
deferUpdate(): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Opens a form, as the answer: `showModal(report({ userId }))`, with a
|
|
131
|
+
* form of `src/components/modals/`. It must be the first answer.
|
|
132
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#interaction-response-object-modal
|
|
133
|
+
*/
|
|
134
|
+
showModal(form: ModalComponent): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Someone sent a form of the bot. It can answer like a command; when a
|
|
138
|
+
* button or a menu opened the form, it can also change their message.
|
|
139
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure
|
|
140
|
+
*/
|
|
141
|
+
export declare class ModalInteraction extends Interaction {
|
|
142
|
+
/** The message whose button or menu opened the form; `null` when a command did. */
|
|
143
|
+
readonly message: Message | null;
|
|
144
|
+
constructor(ctx: Context, data: InteractionData, user: User, options: {
|
|
145
|
+
ephemeral?: boolean;
|
|
146
|
+
message: Message | null;
|
|
147
|
+
});
|
|
148
|
+
/**
|
|
149
|
+
* Changes the message whose button or menu opened the form, as the
|
|
150
|
+
* answer. Only what you pass changes.
|
|
151
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type
|
|
152
|
+
*/
|
|
153
|
+
update(message: string | MessageEditOptions): Promise<Message>;
|
|
154
|
+
/**
|
|
155
|
+
* Tells Discord the message that opened the form will change later: the
|
|
156
|
+
* person sees nothing meanwhile.
|
|
157
|
+
*/
|
|
158
|
+
deferUpdate(): Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A slash command used in a server: what a command receives by default.
|
|
162
|
+
* Discord sends the server, the member and the channel with it.
|
|
163
|
+
* @see https://docs.discord.com/developers/interactions/receiving-and-responding#interaction-object-interaction-structure
|
|
164
|
+
*/
|
|
165
|
+
export interface GuildCommandInteraction extends CommandInteraction {
|
|
166
|
+
/** The id of the server. */
|
|
167
|
+
readonly guildId: Snowflake;
|
|
168
|
+
/** The server it happened in. */
|
|
169
|
+
readonly guild: Guild;
|
|
170
|
+
/** Who did it, as a member of the server. */
|
|
171
|
+
readonly member: GuildMember;
|
|
172
|
+
/** The channel it happened in. */
|
|
173
|
+
readonly channel: GuildTextBasedChannel;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* A slash command used in a private message with the bot, for a command
|
|
177
|
+
* that works in both places (`where: 'both'`): there is no server, which is
|
|
178
|
+
* how it is told apart from `GuildCommandInteraction`.
|
|
179
|
+
*/
|
|
180
|
+
export interface PrivateCommandInteraction extends CommandInteraction {
|
|
181
|
+
/** No server: it happened in a private message. */
|
|
182
|
+
readonly guildId: null;
|
|
183
|
+
/** No server: it happened in a private message. */
|
|
184
|
+
readonly guild: null;
|
|
185
|
+
/** No member: the person is `user`. */
|
|
186
|
+
readonly member: null;
|
|
187
|
+
/** The private conversation it happened in. */
|
|
188
|
+
readonly channel: DMChannel;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A slash command that is only used in private messages with the bot
|
|
192
|
+
* (`where: 'dm'`): nothing about a server exists on it.
|
|
193
|
+
*/
|
|
194
|
+
export interface DmCommandInteraction extends Omit<CommandInteraction, 'guildId' | 'guild' | 'member' | 'channel'> {
|
|
195
|
+
/** The private conversation it happened in. */
|
|
196
|
+
readonly channel: DMChannel;
|
|
197
|
+
}
|