@buape/carbon 0.4.2 → 0.6.0
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/README.md +15 -3
- package/dist/package.json +22 -5
- package/dist/src/abstracts/BaseChannel.d.ts +22 -21
- package/dist/src/abstracts/BaseChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseChannel.js +37 -27
- package/dist/src/abstracts/BaseChannel.js.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.d.ts +3 -2
- package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.js +3 -4
- package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.d.ts +12 -10
- package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.js +35 -22
- package/dist/src/abstracts/BaseGuildChannel.js.map +1 -1
- package/dist/src/abstracts/BaseGuildTextChannel.d.ts +13 -9
- package/dist/src/abstracts/BaseGuildTextChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseGuildTextChannel.js +25 -9
- package/dist/src/abstracts/BaseGuildTextChannel.js.map +1 -1
- package/dist/src/abstracts/BaseInteraction.d.ts +10 -24
- package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.js +21 -15
- package/dist/src/abstracts/BaseInteraction.js.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +14 -13
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.js +31 -16
- package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -1
- package/dist/src/abstracts/Plugin.d.ts +14 -0
- package/dist/src/abstracts/Plugin.d.ts.map +1 -0
- package/dist/src/abstracts/Plugin.js +4 -0
- package/dist/src/abstracts/Plugin.js.map +1 -0
- package/dist/src/adapters/bun/index.d.ts +16 -0
- package/dist/src/adapters/bun/index.d.ts.map +1 -0
- package/dist/src/adapters/bun/index.js +20 -0
- package/dist/src/adapters/bun/index.js.map +1 -0
- package/dist/src/adapters/cloudflare/index.d.ts +16 -0
- package/dist/src/adapters/cloudflare/index.d.ts.map +1 -0
- package/dist/src/adapters/cloudflare/index.js +17 -0
- package/dist/src/adapters/cloudflare/index.js.map +1 -0
- package/dist/src/adapters/next/index.d.ts +14 -0
- package/dist/src/adapters/next/index.d.ts.map +1 -0
- package/dist/src/adapters/next/index.js +17 -0
- package/dist/src/adapters/next/index.js.map +1 -0
- package/dist/src/adapters/node/index.d.ts +16 -0
- package/dist/src/adapters/node/index.d.ts.map +1 -0
- package/dist/src/adapters/node/index.js +20 -0
- package/dist/src/adapters/node/index.js.map +1 -0
- package/dist/src/adapters/shared.d.ts +10 -0
- package/dist/src/adapters/shared.d.ts.map +1 -0
- package/dist/src/adapters/shared.js +2 -0
- package/dist/src/adapters/shared.js.map +1 -0
- package/dist/src/classes/Button.d.ts +0 -4
- package/dist/src/classes/Button.d.ts.map +1 -1
- package/dist/src/classes/Button.js +6 -0
- package/dist/src/classes/Button.js.map +1 -1
- package/dist/src/classes/Client.d.ts +72 -59
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +125 -111
- package/dist/src/classes/Client.js.map +1 -1
- package/dist/src/classes/Embed.d.ts +2 -1
- package/dist/src/classes/Embed.d.ts.map +1 -1
- package/dist/src/classes/Embed.js +12 -10
- package/dist/src/classes/Embed.js.map +1 -1
- package/dist/src/createHandle.d.ts +20 -0
- package/dist/src/createHandle.d.ts.map +1 -0
- package/dist/src/createHandle.js +57 -0
- package/dist/src/createHandle.js.map +1 -0
- package/dist/src/factories/channelFactory.d.ts +1 -1
- package/dist/src/factories/channelFactory.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.d.ts +2 -3
- package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.js +2 -8
- package/dist/src/internals/AutocompleteInteraction.js.map +1 -1
- package/dist/src/internals/CommandHandler.d.ts.map +1 -1
- package/dist/src/internals/CommandHandler.js +4 -2
- package/dist/src/internals/CommandHandler.js.map +1 -1
- package/dist/src/internals/CommandInteraction.d.ts +3 -4
- package/dist/src/internals/CommandInteraction.d.ts.map +1 -1
- package/dist/src/internals/CommandInteraction.js +6 -12
- package/dist/src/internals/CommandInteraction.js.map +1 -1
- package/dist/src/internals/ModalInteraction.d.ts +3 -2
- package/dist/src/internals/ModalInteraction.d.ts.map +1 -1
- package/dist/src/internals/ModalInteraction.js +3 -3
- package/dist/src/internals/ModalInteraction.js.map +1 -1
- package/dist/src/internals/OptionsHandler.d.ts +8 -12
- package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
- package/dist/src/internals/OptionsHandler.js +27 -9
- package/dist/src/internals/OptionsHandler.js.map +1 -1
- package/dist/src/plugins/linked-roles/LinkedRoles.d.ts +61 -0
- package/dist/src/plugins/linked-roles/LinkedRoles.d.ts.map +1 -0
- package/dist/src/plugins/linked-roles/LinkedRoles.js +196 -0
- package/dist/src/plugins/linked-roles/LinkedRoles.js.map +1 -0
- package/dist/src/plugins/linked-roles/index.d.ts +3 -0
- package/dist/src/plugins/linked-roles/index.d.ts.map +1 -0
- package/dist/src/plugins/linked-roles/index.js +3 -0
- package/dist/src/plugins/linked-roles/index.js.map +1 -0
- package/dist/src/plugins/linked-roles/types.d.ts +94 -0
- package/dist/src/plugins/linked-roles/types.d.ts.map +1 -0
- package/dist/src/plugins/linked-roles/types.js +39 -0
- package/dist/src/plugins/linked-roles/types.js.map +1 -0
- package/dist/src/structures/DmChannel.d.ts +7 -6
- package/dist/src/structures/DmChannel.d.ts.map +1 -1
- package/dist/src/structures/DmChannel.js +7 -6
- package/dist/src/structures/DmChannel.js.map +1 -1
- package/dist/src/structures/GroupDmChannel.d.ts +17 -19
- package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
- package/dist/src/structures/GroupDmChannel.js +48 -41
- package/dist/src/structures/GroupDmChannel.js.map +1 -1
- package/dist/src/structures/Guild.d.ts +29 -28
- package/dist/src/structures/Guild.d.ts.map +1 -1
- package/dist/src/structures/Guild.js +82 -57
- package/dist/src/structures/Guild.js.map +1 -1
- package/dist/src/structures/GuildAnnouncementChannel.d.ts +3 -4
- package/dist/src/structures/GuildAnnouncementChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildAnnouncementChannel.js +1 -3
- package/dist/src/structures/GuildAnnouncementChannel.js.map +1 -1
- package/dist/src/structures/GuildCategoryChannel.d.ts +3 -3
- package/dist/src/structures/GuildCategoryChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildCategoryChannel.js +0 -1
- package/dist/src/structures/GuildCategoryChannel.js.map +1 -1
- package/dist/src/structures/GuildForumChannel.d.ts +4 -3
- package/dist/src/structures/GuildForumChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildForumChannel.js +4 -3
- package/dist/src/structures/GuildForumChannel.js.map +1 -1
- package/dist/src/structures/GuildMediaChannel.d.ts +3 -7
- package/dist/src/structures/GuildMediaChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildMediaChannel.js +1 -6
- package/dist/src/structures/GuildMediaChannel.js.map +1 -1
- package/dist/src/structures/GuildMember.d.ts +28 -26
- package/dist/src/structures/GuildMember.d.ts.map +1 -1
- package/dist/src/structures/GuildMember.js +95 -57
- package/dist/src/structures/GuildMember.js.map +1 -1
- package/dist/src/structures/GuildStageOrVoiceChannel.d.ts +12 -11
- package/dist/src/structures/GuildStageOrVoiceChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildStageOrVoiceChannel.js +22 -13
- package/dist/src/structures/GuildStageOrVoiceChannel.js.map +1 -1
- package/dist/src/structures/GuildTextChannel.d.ts +6 -6
- package/dist/src/structures/GuildTextChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildTextChannel.js +9 -7
- package/dist/src/structures/GuildTextChannel.js.map +1 -1
- package/dist/src/structures/GuildThreadChannel.d.ts +14 -13
- package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildThreadChannel.js +59 -28
- package/dist/src/structures/GuildThreadChannel.js.map +1 -1
- package/dist/src/structures/Message.d.ts +50 -41
- package/dist/src/structures/Message.d.ts.map +1 -1
- package/dist/src/structures/Message.js +163 -93
- package/dist/src/structures/Message.js.map +1 -1
- package/dist/src/structures/Role.d.ts +27 -25
- package/dist/src/structures/Role.d.ts.map +1 -1
- package/dist/src/structures/Role.js +100 -61
- package/dist/src/structures/Role.js.map +1 -1
- package/dist/src/structures/User.d.ts +34 -32
- package/dist/src/structures/User.d.ts.map +1 -1
- package/dist/src/structures/User.js +97 -64
- package/dist/src/structures/User.js.map +1 -1
- package/dist/src/types.d.ts +37 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +17 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +16 -5
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/adapters/shared.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AAG3D,MAAM,WAAW,aAAa;CAAG;AAEjC,MAAM,WAAW,aAAc,SAAQ,aAAa;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/adapters/shared.ts"],"names":[],"mappings":""}
|
|
@@ -25,10 +25,6 @@ declare abstract class BaseButton extends BaseComponent {
|
|
|
25
25
|
disabled: boolean;
|
|
26
26
|
}
|
|
27
27
|
export declare abstract class Button extends BaseButton {
|
|
28
|
-
/**
|
|
29
|
-
* The style of the button
|
|
30
|
-
*/
|
|
31
|
-
abstract style: Exclude<ButtonStyle, ButtonStyle.Link | ButtonStyle.Premium>;
|
|
32
28
|
abstract run(interaction: ButtonInteraction): Promise<void>;
|
|
33
29
|
serialize: () => APIButtonComponent;
|
|
34
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/classes/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,WAAW,EACX,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAE1E,uBAAe,UAAW,SAAQ,aAAa;IAC9C,IAAI,gBAAuB;IAE3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,KAAK,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAA;QACZ,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,QAAQ,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IAED;;OAEG;IACH,KAAK,EAAE,WAAW,CAAsB;IAExC;;OAEG;IACH,QAAQ,UAAQ;CAChB;AAED,8BAAsB,MAAO,SAAQ,UAAU;IAC9C
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/classes/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,WAAW,EACX,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAE1E,uBAAe,UAAW,SAAQ,aAAa;IAC9C,IAAI,gBAAuB;IAE3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,KAAK,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAA;QACZ,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,QAAQ,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IAED;;OAEG;IACH,KAAK,EAAE,WAAW,CAAsB;IAExC;;OAEG;IACH,QAAQ,UAAQ;CAChB;AAED,8BAAsB,MAAO,SAAQ,UAAU;IAC9C,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D,SAAS,QAAO,kBAAkB,CAmBjC;CACD;AAED,8BAAsB,UAAW,SAAQ,UAAU;IAClD,QAAQ,SAAK;IACb;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,WAAW,CAAC,IAAI,CAAmB;IAE1C,SAAS,QAAO,yBAAyB,CASxC;CACD;AAED,8BAAsB,aAAc,SAAQ,UAAU;IACrD,KAAK,EAAE,WAAW,CAAC,OAAO,CAAsB;IAEhD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IAEvB,SAAS,QAAO,2BAA2B,CAO1C;CACD"}
|
|
@@ -17,6 +17,12 @@ class BaseButton extends BaseComponent {
|
|
|
17
17
|
}
|
|
18
18
|
export class Button extends BaseButton {
|
|
19
19
|
serialize = () => {
|
|
20
|
+
if (this.style === ButtonStyle.Link) {
|
|
21
|
+
throw new Error("Link buttons cannot be serialized. Are you using the right class?");
|
|
22
|
+
}
|
|
23
|
+
if (this.style === ButtonStyle.Premium) {
|
|
24
|
+
throw new Error("Premium buttons cannot be serialized. Are you using the right class?");
|
|
25
|
+
}
|
|
20
26
|
return {
|
|
21
27
|
type: ComponentType.Button,
|
|
22
28
|
style: this.style,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/classes/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,WAAW,EACX,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAG7D,MAAe,UAAW,SAAQ,aAAa;IAC9C,IAAI,GAAG,aAAa,CAAC,MAAM,CAAA;IAO3B;;OAEG;IACH,KAAK,CAIJ;IAED;;OAEG;IACH,KAAK,GAAgB,WAAW,CAAC,OAAO,CAAA;IAExC;;OAEG;IACH,QAAQ,GAAG,KAAK,CAAA;CAChB;AAED,MAAM,OAAgB,MAAO,SAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/classes/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,WAAW,EACX,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAG7D,MAAe,UAAW,SAAQ,aAAa;IAC9C,IAAI,GAAG,aAAa,CAAC,MAAM,CAAA;IAO3B;;OAEG;IACH,KAAK,CAIJ;IAED;;OAEG;IACH,KAAK,GAAgB,WAAW,CAAC,OAAO,CAAA;IAExC;;OAEG;IACH,QAAQ,GAAG,KAAK,CAAA;CAChB;AAED,MAAM,OAAgB,MAAO,SAAQ,UAAU;IAG9C,SAAS,GAAG,GAAuB,EAAE;QACpC,IAAI,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CACd,mEAAmE,CACnE,CAAA;QACF,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACd,sEAAsE,CACtE,CAAA;QACF,CAAC;QACD,OAAO;YACN,IAAI,EAAE,aAAa,CAAC,MAAM;YAC1B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,CAAA;IACF,CAAC,CAAA;CACD;AAED,MAAM,OAAgB,UAAW,SAAQ,UAAU;IAClD,QAAQ,GAAG,EAAE,CAAA;IAKb,KAAK,GAAqB,WAAW,CAAC,IAAI,CAAA;IAE1C,SAAS,GAAG,GAA8B,EAAE;QAC3C,OAAO;YACN,IAAI,EAAE,aAAa,CAAC,MAAM;YAC1B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,CAAA;IACF,CAAC,CAAA;CACD;AAED,MAAM,OAAgB,aAAc,SAAQ,UAAU;IACrD,KAAK,GAAwB,WAAW,CAAC,OAAO,CAAA;IAOhD,SAAS,GAAG,GAAgC,EAAE;QAC7C,OAAO;YACN,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,aAAa,CAAC,MAAM;YAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CAAA;IACF,CAAC,CAAA;CACD"}
|
|
@@ -1,82 +1,71 @@
|
|
|
1
1
|
import { RequestClient, type RequestClientOptions } from "@buape/carbon-request";
|
|
2
|
-
import { AutoRouter, type IRequestStrict } from "itty-router";
|
|
3
2
|
import type { BaseCommand } from "../abstracts/BaseCommand.js";
|
|
3
|
+
import { type Context, Plugin } from "../abstracts/Plugin.js";
|
|
4
4
|
import { CommandHandler } from "../internals/CommandHandler.js";
|
|
5
5
|
import { ComponentHandler } from "../internals/ComponentHandler.js";
|
|
6
6
|
import { ModalHandler } from "../internals/ModalHandler.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare enum ClientMode {
|
|
12
|
-
NodeJS = "node",
|
|
13
|
-
CloudflareWorkers = "cloudflare",
|
|
14
|
-
Bun = "bun",
|
|
15
|
-
Vercel = "vercel",
|
|
16
|
-
Web = "web"
|
|
17
|
-
}
|
|
7
|
+
import { Guild } from "../structures/Guild.js";
|
|
8
|
+
import { GuildMember } from "../structures/GuildMember.js";
|
|
9
|
+
import { Role } from "../structures/Role.js";
|
|
10
|
+
import { User } from "../structures/User.js";
|
|
18
11
|
/**
|
|
19
12
|
* The options used for initializing the client
|
|
20
13
|
*/
|
|
21
14
|
export type ClientOptions = {
|
|
22
15
|
/**
|
|
23
|
-
*
|
|
16
|
+
* The base URL of the app
|
|
24
17
|
*/
|
|
25
|
-
|
|
18
|
+
baseUrl: string;
|
|
26
19
|
/**
|
|
27
|
-
* The client ID of the
|
|
20
|
+
* The client ID of the app
|
|
28
21
|
*/
|
|
29
22
|
clientId: string;
|
|
30
23
|
/**
|
|
31
|
-
* The
|
|
24
|
+
* The deploy secret of the app, used for protecting the deploy route
|
|
32
25
|
*/
|
|
33
|
-
|
|
26
|
+
deploySecret: string;
|
|
34
27
|
/**
|
|
35
|
-
* The
|
|
28
|
+
* The client secret of the app
|
|
36
29
|
*/
|
|
37
|
-
|
|
30
|
+
clientSecret: string;
|
|
38
31
|
/**
|
|
39
|
-
* The
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* import { Client, ClientMode } from "@buape/carbon"
|
|
43
|
-
*
|
|
44
|
-
* const client = new Client({
|
|
45
|
-
* clientId: "12345678901234567890",
|
|
46
|
-
* publicKey: "c1a2f941ae8ce6d776f7704d0bb3d46b863e21fda491cdb2bdba6b8bc5fe7269",
|
|
47
|
-
* token: "MTA4NjEwNTYxMDUxMDE1NTg1Nw.GNt-U8.OSHy-g-5FlfESnu3Z9MEEMJLHiRthXajiXNwiE",
|
|
48
|
-
* mode: process.env.NODE_ENV === "development" ? ClientMode.NodeJS : ClientMode.CloudflareWorkers
|
|
49
|
-
* })
|
|
50
|
-
* ```
|
|
32
|
+
* The public key of the app, used for interaction verification
|
|
51
33
|
*/
|
|
52
|
-
|
|
34
|
+
publicKey: string;
|
|
53
35
|
/**
|
|
54
|
-
* The
|
|
55
|
-
* @default "/interaction"
|
|
36
|
+
* The token of the bot
|
|
56
37
|
*/
|
|
57
|
-
|
|
38
|
+
token: string;
|
|
58
39
|
/**
|
|
59
40
|
* The options used to initialize the request client, if you want to customize it.
|
|
60
41
|
*/
|
|
61
42
|
requestOptions?: RequestClientOptions;
|
|
62
|
-
/**
|
|
63
|
-
* The port to run the server on, if you are using {@link ClientMode.Bun} mode.
|
|
64
|
-
*/
|
|
65
|
-
port?: number;
|
|
66
43
|
/**
|
|
67
44
|
* Whether the commands should be deployed to Discord automatically.
|
|
45
|
+
* @default false
|
|
68
46
|
*/
|
|
69
47
|
autoDeploy?: boolean;
|
|
70
48
|
/**
|
|
71
|
-
* Whether components and modals should be registered automatically.
|
|
72
|
-
* If you
|
|
49
|
+
* Whether components and modals should not be registered automatically.
|
|
50
|
+
* If you want you register components yourself (e.g. you are changing them at runtime), you can manually call {@link ComponentHandler#registerComponent} and {@link ModalHandler#registerModal} on the client.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
disableAutoRegister?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the deploy route should be disabled.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
disableDeployRoute?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the interactions route should
|
|
61
|
+
* @default false
|
|
73
62
|
*/
|
|
74
|
-
|
|
63
|
+
disableInteractionsRoute?: boolean;
|
|
75
64
|
};
|
|
76
65
|
/**
|
|
77
66
|
* The main client used to interact with Discord
|
|
78
67
|
*/
|
|
79
|
-
export declare class Client {
|
|
68
|
+
export declare class Client extends Plugin {
|
|
80
69
|
/**
|
|
81
70
|
* The options used to initialize the client
|
|
82
71
|
*/
|
|
@@ -85,10 +74,6 @@ export declare class Client {
|
|
|
85
74
|
* The commands that the client has registered
|
|
86
75
|
*/
|
|
87
76
|
commands: BaseCommand[];
|
|
88
|
-
/**
|
|
89
|
-
* The router used to handle requests
|
|
90
|
-
*/
|
|
91
|
-
router: ReturnType<typeof AutoRouter<IRequestStrict>>;
|
|
92
77
|
/**
|
|
93
78
|
* The rest client used to interact with the Discord API
|
|
94
79
|
*/
|
|
@@ -114,27 +99,55 @@ export declare class Client {
|
|
|
114
99
|
* @param commands The commands that the client has registered
|
|
115
100
|
*/
|
|
116
101
|
constructor(options: ClientOptions, commands: BaseCommand[]);
|
|
102
|
+
private appendRoutes;
|
|
117
103
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*/
|
|
121
|
-
deployCommands(): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* Setup the routes for the client
|
|
104
|
+
* Handle a request to deploy the commands to Discord
|
|
105
|
+
* @returns A response
|
|
124
106
|
*/
|
|
125
|
-
|
|
107
|
+
handleDeployRequest(): Promise<Response>;
|
|
126
108
|
/**
|
|
127
|
-
*
|
|
109
|
+
* Handle an interaction request from Discord
|
|
128
110
|
* @param req The request to handle
|
|
129
|
-
* @param ctx
|
|
130
|
-
* @returns A response
|
|
111
|
+
* @param ctx The context for the request
|
|
112
|
+
* @returns A response
|
|
131
113
|
*/
|
|
132
|
-
|
|
114
|
+
handleInteractionsRequest(req: Request, ctx: Context): Promise<Response>;
|
|
133
115
|
/**
|
|
134
116
|
* Validate the interaction request
|
|
135
117
|
* @param req The request to validate
|
|
136
118
|
*/
|
|
137
|
-
private
|
|
119
|
+
private validateInteractionRequest;
|
|
120
|
+
/**
|
|
121
|
+
* Fetch a user from the Discord API
|
|
122
|
+
* @param id The ID of the user to fetch
|
|
123
|
+
* @returns The user data
|
|
124
|
+
*/
|
|
125
|
+
fetchUser(id: string): Promise<User<false>>;
|
|
126
|
+
/**
|
|
127
|
+
* Fetch a guild from the Discord API
|
|
128
|
+
* @param id The ID of the guild to fetch
|
|
129
|
+
* @returns The guild data
|
|
130
|
+
*/
|
|
131
|
+
fetchGuild(id: string): Promise<Guild<false>>;
|
|
132
|
+
/**
|
|
133
|
+
* Fetch a channel from the Discord API
|
|
134
|
+
* @param id The ID of the channel to fetch
|
|
135
|
+
* @returns The channel data
|
|
136
|
+
*/
|
|
137
|
+
fetchChannel(id: string): Promise<import("../index.js").DmChannel<false> | import("../index.js").GroupDmChannel<false> | import("../index.js").GuildTextChannel<false> | import("../index.js").GuildVoiceChannel<false> | import("../index.js").GuildCategoryChannel<false> | import("../index.js").GuildAnnouncementChannel<false> | import("../index.js").GuildThreadChannel<import("discord-api-types/v10").ThreadChannelType, false> | import("../index.js").GuildStageChannel<false> | import("../index.js").GuildForumChannel<false> | import("../index.js").GuildMediaChannel | null>;
|
|
138
|
+
/**
|
|
139
|
+
* Fetch a role from the Discord API
|
|
140
|
+
* @param id The ID of the role to fetch
|
|
141
|
+
* @returns The role data
|
|
142
|
+
*/
|
|
143
|
+
fetchRole(guildId: string, id: string): Promise<Role<false>>;
|
|
144
|
+
/**
|
|
145
|
+
* Fetch a member from the Discord API
|
|
146
|
+
* @param guildId The ID of the guild the member is in
|
|
147
|
+
* @param id The ID of the member to fetch
|
|
148
|
+
* @returns The member data
|
|
149
|
+
*/
|
|
150
|
+
fetchMember(guildId: string, id: string): Promise<GuildMember<false, true>>;
|
|
138
151
|
}
|
|
139
152
|
/**
|
|
140
153
|
* @hidden
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAYhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAG5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AAED;;GAEG;AACH,qBAAa,MAAO,SAAQ,MAAM;IACjC;;OAEG;IACH,OAAO,EAAE,aAAa,CAAA;IACtB;;OAEG;IACH,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB;;OAEG;IACH,IAAI,EAAE,aAAa,CAAA;IACnB;;;OAGG;IACH,gBAAgB,EAAE,gBAAgB,CAAA;IAClC;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAA;IAC9B;;;OAGG;IACH,YAAY,EAAE,YAAY,CAAA;IAE1B;;;;OAIG;gBACS,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE;IAgC3D,OAAO,CAAC,YAAY;IAgBpB;;;OAGG;IACU,mBAAmB;IAWhC;;;;;OAKG;IACU,yBAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO;IAsCjE;;;OAGG;YACW,0BAA0B;IAmCxC;;;;OAIG;IACG,SAAS,CAAC,EAAE,EAAE,MAAM;IAK1B;;;;OAIG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM;IAK3B;;;;OAIG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM;IAK7B;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAK3C;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAQ7C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAEhC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;CACtC"}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
import { RequestClient } from "@buape/carbon-request";
|
|
2
2
|
import { InteractionResponseType, InteractionType, Routes } from "discord-api-types/v10";
|
|
3
|
-
import {
|
|
3
|
+
import { Plugin } from "../abstracts/Plugin.js";
|
|
4
|
+
import { channelFactory } from "../factories/channelFactory.js";
|
|
4
5
|
import { CommandHandler } from "../internals/CommandHandler.js";
|
|
5
6
|
import { ComponentHandler } from "../internals/ComponentHandler.js";
|
|
6
7
|
import { ModalHandler } from "../internals/ModalHandler.js";
|
|
8
|
+
import { Guild } from "../structures/Guild.js";
|
|
9
|
+
import { GuildMember } from "../structures/GuildMember.js";
|
|
10
|
+
import { Role } from "../structures/Role.js";
|
|
11
|
+
import { User } from "../structures/User.js";
|
|
7
12
|
import { concatUint8Arrays, subtleCrypto, valueToUint8Array } from "../utils.js";
|
|
8
|
-
/**
|
|
9
|
-
* The mode that the client is running in.
|
|
10
|
-
* Different platforms have different requirements for how processes are handled.
|
|
11
|
-
*/
|
|
12
|
-
export var ClientMode;
|
|
13
|
-
(function (ClientMode) {
|
|
14
|
-
ClientMode["NodeJS"] = "node";
|
|
15
|
-
ClientMode["CloudflareWorkers"] = "cloudflare";
|
|
16
|
-
ClientMode["Bun"] = "bun";
|
|
17
|
-
ClientMode["Vercel"] = "vercel";
|
|
18
|
-
ClientMode["Web"] = "web";
|
|
19
|
-
})(ClientMode || (ClientMode = {}));
|
|
20
13
|
/**
|
|
21
14
|
* The main client used to interact with Discord
|
|
22
15
|
*/
|
|
23
|
-
export class Client {
|
|
16
|
+
export class Client extends Plugin {
|
|
24
17
|
/**
|
|
25
18
|
* The options used to initialize the client
|
|
26
19
|
*/
|
|
@@ -29,10 +22,6 @@ export class Client {
|
|
|
29
22
|
* The commands that the client has registered
|
|
30
23
|
*/
|
|
31
24
|
commands;
|
|
32
|
-
/**
|
|
33
|
-
* The router used to handle requests
|
|
34
|
-
*/
|
|
35
|
-
router;
|
|
36
25
|
/**
|
|
37
26
|
* The rest client used to interact with the Discord API
|
|
38
27
|
*/
|
|
@@ -58,6 +47,11 @@ export class Client {
|
|
|
58
47
|
* @param commands The commands that the client has registered
|
|
59
48
|
*/
|
|
60
49
|
constructor(options, commands) {
|
|
50
|
+
super();
|
|
51
|
+
if (!options.baseUrl)
|
|
52
|
+
throw new Error("Missing base URL");
|
|
53
|
+
if (!options.clientSecret)
|
|
54
|
+
throw new Error("Missing client secret");
|
|
61
55
|
if (!options.clientId)
|
|
62
56
|
throw new Error("Missing client ID");
|
|
63
57
|
if (!options.publicKey)
|
|
@@ -66,16 +60,12 @@ export class Client {
|
|
|
66
60
|
throw new Error("Missing token");
|
|
67
61
|
this.options = options;
|
|
68
62
|
this.commands = commands;
|
|
63
|
+
this.appendRoutes();
|
|
69
64
|
this.commandHandler = new CommandHandler(this);
|
|
70
65
|
this.componentHandler = new ComponentHandler(this);
|
|
71
66
|
this.modalHandler = new ModalHandler(this);
|
|
72
|
-
const routerData = this.options.mode === ClientMode.Bun && this.options.port
|
|
73
|
-
? { port: this.options.port }
|
|
74
|
-
: {};
|
|
75
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
76
|
-
this.router = AutoRouter(routerData);
|
|
77
67
|
this.rest = new RequestClient(options.token, options.requestOptions);
|
|
78
|
-
if (this.options.
|
|
68
|
+
if (!this.options.disableAutoRegister) {
|
|
79
69
|
for (const command of commands) {
|
|
80
70
|
for (const component of command.components)
|
|
81
71
|
this.componentHandler.registerComponent(new component());
|
|
@@ -83,114 +73,91 @@ export class Client {
|
|
|
83
73
|
this.modalHandler.registerModal(new modal());
|
|
84
74
|
}
|
|
85
75
|
}
|
|
86
|
-
if (this.options.autoDeploy)
|
|
87
|
-
this.
|
|
88
|
-
this.setupRoutes();
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Deploy the commands registered to Discord.
|
|
92
|
-
* This is automatically called when running in NodeJS mode.
|
|
93
|
-
*/
|
|
94
|
-
async deployCommands() {
|
|
95
|
-
try {
|
|
96
|
-
const commands = this.commands
|
|
97
|
-
.filter((x) => x.name !== "*")
|
|
98
|
-
.map((command) => {
|
|
99
|
-
return command.serialize();
|
|
100
|
-
});
|
|
101
|
-
await this.rest.put(Routes.applicationCommands(this.options.clientId), {
|
|
102
|
-
body: commands
|
|
103
|
-
});
|
|
104
|
-
console.log(`Deployed ${commands.length} commands to Discord`);
|
|
105
|
-
}
|
|
106
|
-
catch (err) {
|
|
107
|
-
console.error("Failed to deploy commands");
|
|
108
|
-
console.error(err);
|
|
76
|
+
if (this.options.autoDeploy) {
|
|
77
|
+
this.handleDeployRequest();
|
|
109
78
|
}
|
|
110
79
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
throw new StatusError(404);
|
|
80
|
+
appendRoutes() {
|
|
81
|
+
this.routes.push({
|
|
82
|
+
method: "GET",
|
|
83
|
+
path: "/deploy",
|
|
84
|
+
handler: this.handleDeployRequest.bind(this),
|
|
85
|
+
protected: true,
|
|
86
|
+
disabled: this.options.disableDeployRoute
|
|
119
87
|
});
|
|
120
|
-
this.
|
|
121
|
-
|
|
88
|
+
this.routes.push({
|
|
89
|
+
method: "POST",
|
|
90
|
+
path: "/interactions",
|
|
91
|
+
handler: this.handleInteractionsRequest.bind(this),
|
|
92
|
+
disabled: this.options.disableInteractionsRoute
|
|
122
93
|
});
|
|
123
94
|
}
|
|
124
95
|
/**
|
|
125
|
-
*
|
|
96
|
+
* Handle a request to deploy the commands to Discord
|
|
97
|
+
* @returns A response
|
|
98
|
+
*/
|
|
99
|
+
async handleDeployRequest() {
|
|
100
|
+
const commands = this.commands
|
|
101
|
+
.filter((c) => c.name !== "*")
|
|
102
|
+
.map((c) => c.serialize());
|
|
103
|
+
await this.rest.put(Routes.applicationCommands(this.options.clientId), //
|
|
104
|
+
{ body: commands });
|
|
105
|
+
return new Response("OK", { status: 202 });
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Handle an interaction request from Discord
|
|
126
109
|
* @param req The request to handle
|
|
127
|
-
* @param ctx
|
|
128
|
-
* @returns A response
|
|
110
|
+
* @param ctx The context for the request
|
|
111
|
+
* @returns A response
|
|
129
112
|
*/
|
|
130
|
-
async
|
|
131
|
-
const isValid = await this.
|
|
132
|
-
if (!isValid)
|
|
133
|
-
return new Response("
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return json({
|
|
138
|
-
type: InteractionResponseType.Pong
|
|
139
|
-
});
|
|
113
|
+
async handleInteractionsRequest(req, ctx) {
|
|
114
|
+
const isValid = await this.validateInteractionRequest(req);
|
|
115
|
+
if (!isValid)
|
|
116
|
+
return new Response("Unauthorized", { status: 401 });
|
|
117
|
+
const interaction = (await req.json());
|
|
118
|
+
if (interaction.type === InteractionType.Ping) {
|
|
119
|
+
return Response.json({ type: InteractionResponseType.Pong });
|
|
140
120
|
}
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
else {
|
|
148
|
-
await this.commandHandler.handleCommandInteraction(rawInteraction);
|
|
149
|
-
}
|
|
121
|
+
if (interaction.type === InteractionType.ApplicationCommand) {
|
|
122
|
+
const promise = this.commandHandler.handleCommandInteraction(interaction);
|
|
123
|
+
if (ctx?.waitUntil)
|
|
124
|
+
ctx.waitUntil(promise);
|
|
125
|
+
else
|
|
126
|
+
await promise;
|
|
150
127
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
else {
|
|
158
|
-
await this.commandHandler.handleAutocompleteInteraction(rawInteraction);
|
|
159
|
-
}
|
|
128
|
+
if (interaction.type === InteractionType.ApplicationCommandAutocomplete) {
|
|
129
|
+
const promise = this.commandHandler.handleAutocompleteInteraction(interaction);
|
|
130
|
+
if (ctx?.waitUntil)
|
|
131
|
+
ctx.waitUntil(promise);
|
|
132
|
+
else
|
|
133
|
+
await promise;
|
|
160
134
|
}
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
else {
|
|
168
|
-
await this.componentHandler.handleInteraction(rawInteraction);
|
|
169
|
-
}
|
|
135
|
+
if (interaction.type === InteractionType.MessageComponent) {
|
|
136
|
+
const promise = this.componentHandler.handleInteraction(interaction);
|
|
137
|
+
if (ctx?.waitUntil)
|
|
138
|
+
ctx.waitUntil(promise);
|
|
139
|
+
else
|
|
140
|
+
await promise;
|
|
170
141
|
}
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
else {
|
|
178
|
-
await this.modalHandler.handleInteraction(rawInteraction);
|
|
179
|
-
}
|
|
142
|
+
if (interaction.type === InteractionType.ModalSubmit) {
|
|
143
|
+
const promise = this.modalHandler.handleInteraction(interaction);
|
|
144
|
+
if (ctx?.waitUntil)
|
|
145
|
+
ctx.waitUntil(promise);
|
|
146
|
+
else
|
|
147
|
+
await promise;
|
|
180
148
|
}
|
|
181
|
-
return new Response(
|
|
149
|
+
return new Response("OK", { status: 202 });
|
|
182
150
|
}
|
|
183
151
|
/**
|
|
184
152
|
* Validate the interaction request
|
|
185
153
|
* @param req The request to validate
|
|
186
154
|
*/
|
|
187
|
-
async
|
|
155
|
+
async validateInteractionRequest(req) {
|
|
188
156
|
const body = await req.clone().text();
|
|
189
157
|
const signature = req.headers.get("X-Signature-Ed25519");
|
|
190
158
|
const timestamp = req.headers.get("X-Signature-Timestamp");
|
|
191
|
-
if (!timestamp || !signature || req.method !== "POST" || !body)
|
|
192
|
-
|
|
193
|
-
}
|
|
159
|
+
if (!timestamp || !signature || req.method !== "POST" || !body)
|
|
160
|
+
return false;
|
|
194
161
|
try {
|
|
195
162
|
const timestampData = valueToUint8Array(timestamp);
|
|
196
163
|
const bodyData = valueToUint8Array(body);
|
|
@@ -207,5 +174,52 @@ export class Client {
|
|
|
207
174
|
return false;
|
|
208
175
|
}
|
|
209
176
|
}
|
|
177
|
+
// ======================== Begin Fetchers ================================================
|
|
178
|
+
/**
|
|
179
|
+
* Fetch a user from the Discord API
|
|
180
|
+
* @param id The ID of the user to fetch
|
|
181
|
+
* @returns The user data
|
|
182
|
+
*/
|
|
183
|
+
async fetchUser(id) {
|
|
184
|
+
const user = (await this.rest.get(Routes.user(id)));
|
|
185
|
+
return new User(this, user);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Fetch a guild from the Discord API
|
|
189
|
+
* @param id The ID of the guild to fetch
|
|
190
|
+
* @returns The guild data
|
|
191
|
+
*/
|
|
192
|
+
async fetchGuild(id) {
|
|
193
|
+
const guild = (await this.rest.get(Routes.guild(id)));
|
|
194
|
+
return new Guild(this, guild);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Fetch a channel from the Discord API
|
|
198
|
+
* @param id The ID of the channel to fetch
|
|
199
|
+
* @returns The channel data
|
|
200
|
+
*/
|
|
201
|
+
async fetchChannel(id) {
|
|
202
|
+
const channel = (await this.rest.get(Routes.channel(id)));
|
|
203
|
+
return channelFactory(this, channel);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Fetch a role from the Discord API
|
|
207
|
+
* @param id The ID of the role to fetch
|
|
208
|
+
* @returns The role data
|
|
209
|
+
*/
|
|
210
|
+
async fetchRole(guildId, id) {
|
|
211
|
+
const role = (await this.rest.get(Routes.guildRole(guildId, id)));
|
|
212
|
+
return new Role(this, role);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Fetch a member from the Discord API
|
|
216
|
+
* @param guildId The ID of the guild the member is in
|
|
217
|
+
* @param id The ID of the member to fetch
|
|
218
|
+
* @returns The member data
|
|
219
|
+
*/
|
|
220
|
+
async fetchMember(guildId, id) {
|
|
221
|
+
const member = (await this.rest.get(Routes.guildMember(guildId, id)));
|
|
222
|
+
return new GuildMember(this, member, new Guild(this, guildId));
|
|
223
|
+
}
|
|
210
224
|
}
|
|
211
225
|
//# sourceMappingURL=Client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,uBAAuB,CAAA;AAChF,OAAO,
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAON,uBAAuB,EACvB,eAAe,EACf,MAAM,EACN,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAgB,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAyDhF;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,MAAM;IACjC;;OAEG;IACH,OAAO,CAAe;IACtB;;OAEG;IACH,QAAQ,CAAe;IACvB;;OAEG;IACH,IAAI,CAAe;IACnB;;;OAGG;IACH,gBAAgB,CAAkB;IAClC;;;OAGG;IACH,cAAc,CAAgB;IAC9B;;;OAGG;IACH,YAAY,CAAc;IAE1B;;;;OAIG;IACH,YAAY,OAAsB,EAAE,QAAuB;QAC1D,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE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KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,EAAU;QAC5C,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAClC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAC/B,CAAmB,CAAA;QACpB,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,CAAO,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IACrE,CAAC;CAGD"}
|
|
@@ -41,6 +41,7 @@ export declare class Embed {
|
|
|
41
41
|
author?: {
|
|
42
42
|
name: string;
|
|
43
43
|
url?: string;
|
|
44
|
+
icon_url?: string;
|
|
44
45
|
};
|
|
45
46
|
fields?: {
|
|
46
47
|
name: string;
|
|
@@ -50,7 +51,7 @@ export declare class Embed {
|
|
|
50
51
|
/**
|
|
51
52
|
* Create an embed from an API embed
|
|
52
53
|
*/
|
|
53
|
-
constructor(embed
|
|
54
|
+
constructor(embed?: APIEmbed);
|
|
54
55
|
/**
|
|
55
56
|
* Serialize the embed to an API embed
|
|
56
57
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.d.ts","sourceRoot":"","sources":["../../../src/classes/Embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;GAEG;AACH,qBAAa,KAAK;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;KACj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