disgroove 1.3.1 → 1.3.3-dev.1
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 +1 -1
- package/dist/lib/Client.d.ts +234 -0
- package/dist/lib/Client.js +256 -0
- package/dist/lib/Client.js.map +1 -0
- package/dist/lib/constants.d.ts +1084 -0
- package/dist/lib/constants.js +1163 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/gateway/Shard.d.ts +25 -0
- package/dist/lib/gateway/Shard.js +522 -0
- package/dist/lib/gateway/Shard.js.map +1 -0
- package/dist/lib/gateway/ShardsManager.d.ts +5 -0
- package/dist/lib/gateway/ShardsManager.js +13 -0
- package/dist/lib/gateway/ShardsManager.js.map +1 -0
- package/dist/lib/gateway/index.d.ts +2 -0
- package/dist/lib/gateway/index.js +19 -0
- package/dist/lib/gateway/index.js.map +1 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/index.js +24 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/rest/CDN.d.ts +21 -0
- package/dist/lib/rest/CDN.js +46 -0
- package/dist/lib/rest/CDN.js.map +1 -0
- package/dist/lib/rest/Endpoints.d.ts +94 -0
- package/dist/lib/rest/Endpoints.js +211 -0
- package/dist/lib/rest/Endpoints.js.map +1 -0
- package/dist/lib/rest/REST.d.ts +22 -0
- package/dist/lib/rest/REST.js +35 -0
- package/dist/lib/rest/REST.js.map +1 -0
- package/dist/lib/rest/RequestsManager.d.ts +17 -0
- package/dist/lib/rest/RequestsManager.js +124 -0
- package/dist/lib/rest/RequestsManager.js.map +1 -0
- package/dist/lib/rest/index.d.ts +4 -0
- package/dist/lib/rest/index.js +34 -0
- package/dist/lib/rest/index.js.map +1 -0
- package/dist/lib/structures/Application.d.ts +174 -0
- package/dist/lib/structures/Application.js +328 -0
- package/dist/lib/structures/Application.js.map +1 -0
- package/dist/lib/structures/ApplicationCommand.d.ts +45 -0
- package/dist/lib/structures/ApplicationCommand.js +127 -0
- package/dist/lib/structures/ApplicationCommand.js.map +1 -0
- package/dist/lib/structures/AuditLog.d.ts +20 -0
- package/dist/lib/structures/AuditLog.js +76 -0
- package/dist/lib/structures/AuditLog.js.map +1 -0
- package/dist/lib/structures/AutoModerationRule.d.ts +34 -0
- package/dist/lib/structures/AutoModerationRule.js +96 -0
- package/dist/lib/structures/AutoModerationRule.js.map +1 -0
- package/dist/lib/structures/Base.d.ts +17 -0
- package/dist/lib/structures/Base.js +31 -0
- package/dist/lib/structures/Base.js.map +1 -0
- package/dist/lib/structures/Channel.d.ts +253 -0
- package/dist/lib/structures/Channel.js +591 -0
- package/dist/lib/structures/Channel.js.map +1 -0
- package/dist/lib/structures/ClientApplication.d.ts +150 -0
- package/dist/lib/structures/ClientApplication.js +241 -0
- package/dist/lib/structures/ClientApplication.js.map +1 -0
- package/dist/lib/structures/Emoji.d.ts +28 -0
- package/dist/lib/structures/Emoji.js +79 -0
- package/dist/lib/structures/Emoji.js.map +1 -0
- package/dist/lib/structures/Entitlement.d.ts +24 -0
- package/dist/lib/structures/Entitlement.js +68 -0
- package/dist/lib/structures/Entitlement.js.map +1 -0
- package/dist/lib/structures/Guild.d.ts +462 -0
- package/dist/lib/structures/Guild.js +1095 -0
- package/dist/lib/structures/Guild.js.map +1 -0
- package/dist/lib/structures/GuildMember.d.ts +50 -0
- package/dist/lib/structures/GuildMember.js +149 -0
- package/dist/lib/structures/GuildMember.js.map +1 -0
- package/dist/lib/structures/GuildScheduledEvent.d.ts +49 -0
- package/dist/lib/structures/GuildScheduledEvent.js +118 -0
- package/dist/lib/structures/GuildScheduledEvent.js.map +1 -0
- package/dist/lib/structures/GuildTemplate.d.ts +32 -0
- package/dist/lib/structures/GuildTemplate.js +76 -0
- package/dist/lib/structures/GuildTemplate.js.map +1 -0
- package/dist/lib/structures/Integration.d.ts +30 -0
- package/dist/lib/structures/Integration.js +102 -0
- package/dist/lib/structures/Integration.js.map +1 -0
- package/dist/lib/structures/Interaction.d.ts +76 -0
- package/dist/lib/structures/Interaction.js +345 -0
- package/dist/lib/structures/Interaction.js.map +1 -0
- package/dist/lib/structures/Invite.d.ts +28 -0
- package/dist/lib/structures/Invite.js +86 -0
- package/dist/lib/structures/Invite.js.map +1 -0
- package/dist/lib/structures/Message.d.ts +84 -0
- package/dist/lib/structures/Message.js +300 -0
- package/dist/lib/structures/Message.js.map +1 -0
- package/dist/lib/structures/Role.d.ts +37 -0
- package/dist/lib/structures/Role.js +90 -0
- package/dist/lib/structures/Role.js.map +1 -0
- package/dist/lib/structures/SKU.d.ts +23 -0
- package/dist/lib/structures/SKU.js +63 -0
- package/dist/lib/structures/SKU.js.map +1 -0
- package/dist/lib/structures/StageInstance.d.ts +24 -0
- package/dist/lib/structures/StageInstance.js +57 -0
- package/dist/lib/structures/StageInstance.js.map +1 -0
- package/dist/lib/structures/Sticker.d.ts +31 -0
- package/dist/lib/structures/Sticker.js +86 -0
- package/dist/lib/structures/Sticker.js.map +1 -0
- package/dist/lib/structures/Team.d.ts +14 -0
- package/dist/lib/structures/Team.js +39 -0
- package/dist/lib/structures/Team.js.map +1 -0
- package/dist/lib/structures/TestEntitlement.d.ts +23 -0
- package/dist/lib/structures/TestEntitlement.js +61 -0
- package/dist/lib/structures/TestEntitlement.js.map +1 -0
- package/dist/lib/structures/UnavailableGuild.d.ts +11 -0
- package/dist/lib/structures/UnavailableGuild.js +25 -0
- package/dist/lib/structures/UnavailableGuild.js.map +1 -0
- package/dist/lib/structures/User.d.ts +63 -0
- package/dist/lib/structures/User.js +177 -0
- package/dist/lib/structures/User.js.map +1 -0
- package/dist/lib/structures/VoiceState.d.ts +26 -0
- package/dist/lib/structures/VoiceState.js +70 -0
- package/dist/lib/structures/VoiceState.js.map +1 -0
- package/dist/lib/structures/Webhook.d.ts +84 -0
- package/dist/lib/structures/Webhook.js +239 -0
- package/dist/lib/structures/Webhook.js.map +1 -0
- package/dist/lib/structures/index.d.ts +27 -0
- package/dist/lib/structures/index.js +44 -0
- package/dist/lib/structures/index.js.map +1 -0
- package/dist/lib/types/application-command.d.ts +102 -0
- package/dist/lib/types/application-command.js +3 -0
- package/dist/lib/types/application-command.js.map +1 -0
- package/dist/lib/types/application-role-connection-metadata.d.ts +18 -0
- package/dist/lib/types/application-role-connection-metadata.js +3 -0
- package/dist/lib/types/application-role-connection-metadata.js.map +1 -0
- package/dist/lib/types/application.d.ts +66 -0
- package/dist/lib/types/application.js +3 -0
- package/dist/lib/types/application.js.map +1 -0
- package/dist/lib/types/audit-log.d.ts +82 -0
- package/dist/lib/types/audit-log.js +3 -0
- package/dist/lib/types/audit-log.js.map +1 -0
- package/dist/lib/types/auto-moderation.d.ts +65 -0
- package/dist/lib/types/auto-moderation.js +3 -0
- package/dist/lib/types/auto-moderation.js.map +1 -0
- package/dist/lib/types/channel.d.ts +456 -0
- package/dist/lib/types/channel.js +3 -0
- package/dist/lib/types/channel.js.map +1 -0
- package/dist/lib/types/emoji.d.ts +22 -0
- package/dist/lib/types/emoji.js +3 -0
- package/dist/lib/types/emoji.js.map +1 -0
- package/dist/lib/types/entitlements.d.ts +32 -0
- package/dist/lib/types/entitlements.js +3 -0
- package/dist/lib/types/entitlements.js.map +1 -0
- package/dist/lib/types/gateway-events.d.ts +805 -0
- package/dist/lib/types/gateway-events.js +3 -0
- package/dist/lib/types/gateway-events.js.map +1 -0
- package/dist/lib/types/guild-scheduled-event.d.ts +57 -0
- package/dist/lib/types/guild-scheduled-event.js +3 -0
- package/dist/lib/types/guild-scheduled-event.js.map +1 -0
- package/dist/lib/types/guild-template.d.ts +28 -0
- package/dist/lib/types/guild-template.js +3 -0
- package/dist/lib/types/guild-template.js.map +1 -0
- package/dist/lib/types/guild.d.ts +333 -0
- package/dist/lib/types/guild.js +3 -0
- package/dist/lib/types/guild.js.map +1 -0
- package/dist/lib/types/index.d.ts +23 -0
- package/dist/lib/types/index.js +40 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/types/interaction.d.ts +170 -0
- package/dist/lib/types/interaction.js +3 -0
- package/dist/lib/types/interaction.js.map +1 -0
- package/dist/lib/types/invite.d.ts +59 -0
- package/dist/lib/types/invite.js +3 -0
- package/dist/lib/types/invite.js.map +1 -0
- package/dist/lib/types/message-components.d.ts +100 -0
- package/dist/lib/types/message-components.js +3 -0
- package/dist/lib/types/message-components.js.map +1 -0
- package/dist/lib/types/role.d.ts +47 -0
- package/dist/lib/types/role.js +3 -0
- package/dist/lib/types/role.js.map +1 -0
- package/dist/lib/types/sku.d.ts +30 -0
- package/dist/lib/types/sku.js +3 -0
- package/dist/lib/types/sku.js.map +1 -0
- package/dist/lib/types/stage-instance.d.ts +20 -0
- package/dist/lib/types/stage-instance.js +3 -0
- package/dist/lib/types/stage-instance.js.map +1 -0
- package/dist/lib/types/sticker.d.ts +61 -0
- package/dist/lib/types/sticker.js +3 -0
- package/dist/lib/types/sticker.js.map +1 -0
- package/dist/lib/types/team.d.ts +30 -0
- package/dist/lib/types/team.js +3 -0
- package/dist/lib/types/team.js.map +1 -0
- package/dist/lib/types/user.d.ts +77 -0
- package/dist/lib/types/user.js +3 -0
- package/dist/lib/types/user.js.map +1 -0
- package/dist/lib/types/voice.d.ts +47 -0
- package/dist/lib/types/voice.js +3 -0
- package/dist/lib/types/voice.js.map +1 -0
- package/dist/lib/types/webhook.d.ts +31 -0
- package/dist/lib/types/webhook.js +3 -0
- package/dist/lib/types/webhook.js.map +1 -0
- package/dist/lib/utils/Util.d.ts +15 -0
- package/dist/lib/utils/Util.js +543 -0
- package/dist/lib/utils/Util.js.map +1 -0
- package/dist/lib/utils/errors.d.ts +12 -0
- package/dist/lib/utils/errors.js +25 -0
- package/dist/lib/utils/errors.js.map +1 -0
- package/dist/lib/utils/index.d.ts +2 -0
- package/dist/lib/utils/index.js +19 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/package.json +1 -1
- package/lib/Client.ts +616 -0
- package/lib/constants.ts +1173 -0
- package/lib/gateway/Shard.ts +704 -0
- package/lib/gateway/ShardsManager.ts +11 -0
- package/lib/gateway/index.ts +2 -0
- package/lib/index.ts +7 -0
- package/lib/rest/CDN.ts +56 -0
- package/lib/rest/Endpoints.ts +241 -0
- package/lib/rest/REST.ts +45 -0
- package/lib/rest/RequestsManager.ts +134 -0
- package/lib/rest/index.ts +4 -0
- package/lib/structures/Application.ts +599 -0
- package/lib/structures/ApplicationCommand.ts +187 -0
- package/lib/structures/AuditLog.ts +112 -0
- package/lib/structures/AutoModerationRule.ts +127 -0
- package/lib/structures/Base.ts +39 -0
- package/lib/structures/Channel.ts +921 -0
- package/lib/structures/ClientApplication.ts +515 -0
- package/lib/structures/Emoji.ts +95 -0
- package/lib/structures/Entitlement.ts +65 -0
- package/lib/structures/Guild.ts +1842 -0
- package/lib/structures/GuildMember.ts +193 -0
- package/lib/structures/GuildScheduledEvent.ts +164 -0
- package/lib/structures/GuildTemplate.ts +103 -0
- package/lib/structures/Integration.ts +136 -0
- package/lib/structures/Interaction.ts +506 -0
- package/lib/structures/Invite.ts +108 -0
- package/lib/structures/Message.ts +421 -0
- package/lib/structures/Role.ts +116 -0
- package/lib/structures/SKU.ts +63 -0
- package/lib/structures/StageInstance.ts +74 -0
- package/lib/structures/Sticker.ts +100 -0
- package/lib/structures/Team.ts +41 -0
- package/lib/structures/TestEntitlement.ts +78 -0
- package/lib/structures/UnavailableGuild.ts +27 -0
- package/lib/structures/User.ts +233 -0
- package/lib/structures/VoiceState.ts +72 -0
- package/lib/structures/Webhook.ts +341 -0
- package/lib/structures/index.ts +27 -0
- package/lib/types/application-command.ts +118 -0
- package/lib/types/application-role-connection-metadata.ts +23 -0
- package/lib/types/application.ts +77 -0
- package/lib/types/audit-log.ts +105 -0
- package/lib/types/auto-moderation.ts +78 -0
- package/lib/types/channel.ts +534 -0
- package/lib/types/emoji.ts +24 -0
- package/lib/types/entitlements.ts +34 -0
- package/lib/types/gateway-events.ts +970 -0
- package/lib/types/guild-scheduled-event.ts +67 -0
- package/lib/types/guild-template.ts +30 -0
- package/lib/types/guild.ts +388 -0
- package/lib/types/index.ts +23 -0
- package/lib/types/interaction.ts +224 -0
- package/lib/types/invite.ts +78 -0
- package/lib/types/message-components.ts +127 -0
- package/lib/types/role.ts +51 -0
- package/lib/types/sku.ts +32 -0
- package/lib/types/stage-instance.ts +22 -0
- package/lib/types/sticker.ts +67 -0
- package/lib/types/team.ts +34 -0
- package/lib/types/user.ts +93 -0
- package/lib/types/voice.ts +51 -0
- package/lib/types/webhook.ts +40 -0
- package/lib/utils/Util.ts +600 -0
- package/lib/utils/errors.ts +23 -0
- package/lib/utils/index.ts +2 -0
- package/package.json +1 -1
@@ -0,0 +1,599 @@
|
|
1
|
+
import {
|
2
|
+
Base,
|
3
|
+
User,
|
4
|
+
ApplicationCommand,
|
5
|
+
Team,
|
6
|
+
Guild,
|
7
|
+
TestEntitlement,
|
8
|
+
Entitlement,
|
9
|
+
SKU,
|
10
|
+
} from ".";
|
11
|
+
import type {
|
12
|
+
JSONInstallParams,
|
13
|
+
JSONGuildApplicationCommandPermissions,
|
14
|
+
RawApplication,
|
15
|
+
RawGuildApplicationCommandPermissions,
|
16
|
+
RawApplicationCommand,
|
17
|
+
JSONApplication,
|
18
|
+
JSONApplicationRoleConnectionMetadata,
|
19
|
+
RawApplicationRoleConnectionMetadata,
|
20
|
+
RawSKU,
|
21
|
+
RawEntitlement,
|
22
|
+
JSONApplicationCommandOption,
|
23
|
+
} from "../types";
|
24
|
+
import type { Client } from "../Client";
|
25
|
+
import { Endpoints } from "../rest";
|
26
|
+
import type {
|
27
|
+
ApplicationCommandTypes,
|
28
|
+
ApplicationFlags,
|
29
|
+
Locale,
|
30
|
+
} from "../constants";
|
31
|
+
|
32
|
+
/** https://discord.com/developers/docs/resources/application */
|
33
|
+
export class Application extends Base {
|
34
|
+
protected override raw: RawApplication;
|
35
|
+
name: string;
|
36
|
+
icon: string | null;
|
37
|
+
description: string;
|
38
|
+
rpcOrigins?: Array<string>;
|
39
|
+
botPublic: boolean;
|
40
|
+
botRequireCodeGrant: boolean;
|
41
|
+
termsOfServiceURL?: string;
|
42
|
+
privacyPolicyURL?: string;
|
43
|
+
owner?: User;
|
44
|
+
verifyKey: string;
|
45
|
+
team: Team | null;
|
46
|
+
guildId?: string;
|
47
|
+
guild?: Guild;
|
48
|
+
primarySKUId?: string;
|
49
|
+
slug?: string;
|
50
|
+
coverImage?: string;
|
51
|
+
flags?: ApplicationFlags;
|
52
|
+
approximateGuildCount?: number;
|
53
|
+
redirectURIs?: Array<string>;
|
54
|
+
interactionsEndpointURL?: string;
|
55
|
+
roleConnectionsVerificationURL?: string;
|
56
|
+
tags?: Array<string>;
|
57
|
+
installParams?: JSONInstallParams;
|
58
|
+
customInstallURL?: string;
|
59
|
+
|
60
|
+
constructor(data: RawApplication, client: Client) {
|
61
|
+
super(data.id, client);
|
62
|
+
|
63
|
+
this.raw = data;
|
64
|
+
this.name = data.name;
|
65
|
+
this.icon = data.icon;
|
66
|
+
this.description = data.description;
|
67
|
+
this.botPublic = data.bot_public;
|
68
|
+
this.botRequireCodeGrant = data.bot_require_code_grant;
|
69
|
+
this.verifyKey = data.verify_key;
|
70
|
+
this.team = null;
|
71
|
+
|
72
|
+
this.patch(data);
|
73
|
+
}
|
74
|
+
|
75
|
+
protected override patch(data: RawApplication) {
|
76
|
+
if (data.rpc_origins !== undefined) this.rpcOrigins = data.rpc_origins;
|
77
|
+
if (data.terms_of_service_url !== undefined)
|
78
|
+
this.termsOfServiceURL = data.terms_of_service_url;
|
79
|
+
if (data.owner !== undefined)
|
80
|
+
this.owner = new User(data.owner, this.client);
|
81
|
+
if (data.team !== undefined)
|
82
|
+
this.team = data.team !== null ? new Team(data.team, this.client) : null;
|
83
|
+
if (data.guild_id !== undefined) this.guildId = data.guild_id;
|
84
|
+
if (data.guild !== undefined)
|
85
|
+
this.guild = new Guild(data.guild, this.client);
|
86
|
+
if (data.primary_sku_id !== undefined)
|
87
|
+
this.primarySKUId = data.primary_sku_id;
|
88
|
+
if (data.slug !== undefined) this.slug = data.slug;
|
89
|
+
if (data.cover_image !== undefined) this.coverImage = data.cover_image;
|
90
|
+
if (data.flags !== undefined) this.flags = data.flags;
|
91
|
+
if (data.approximate_guild_count !== undefined)
|
92
|
+
this.approximateGuildCount = data.approximate_guild_count;
|
93
|
+
if (data.redirect_uris !== undefined)
|
94
|
+
this.redirectURIs = data.redirect_uris;
|
95
|
+
if (data.interactions_endpoint_url !== undefined)
|
96
|
+
this.interactionsEndpointURL = data.interactions_endpoint_url;
|
97
|
+
if (data.role_connections_verification_url !== undefined)
|
98
|
+
this.roleConnectionsVerificationURL =
|
99
|
+
data.role_connections_verification_url;
|
100
|
+
if (data.tags !== undefined) this.tags = data.tags;
|
101
|
+
if (data.install_params !== undefined)
|
102
|
+
this.installParams = data.install_params;
|
103
|
+
if (data.custom_install_url !== undefined)
|
104
|
+
this.customInstallURL = data.custom_install_url;
|
105
|
+
}
|
106
|
+
|
107
|
+
/** https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */
|
108
|
+
async createGlobalApplicationCommand(options: {
|
109
|
+
name: string;
|
110
|
+
nameLocalizations?: Partial<Record<Locale, string>> | null;
|
111
|
+
description?: string;
|
112
|
+
descriptionLocalizations?: Partial<Record<Locale, string>> | null;
|
113
|
+
options?: Array<JSONApplicationCommandOption>;
|
114
|
+
defaultMemberPermissions?: string | null;
|
115
|
+
dmPermission?: boolean;
|
116
|
+
defaultPermission?: boolean | null;
|
117
|
+
type?: ApplicationCommandTypes;
|
118
|
+
nsfw?: boolean;
|
119
|
+
}): Promise<ApplicationCommand> {
|
120
|
+
return new ApplicationCommand(
|
121
|
+
await this.client.rest.post<RawApplicationCommand>(
|
122
|
+
Endpoints.applicationCommands(this.id),
|
123
|
+
{
|
124
|
+
json: this.client.util.applicationCommandToRaw(options),
|
125
|
+
}
|
126
|
+
),
|
127
|
+
this.client
|
128
|
+
);
|
129
|
+
}
|
130
|
+
|
131
|
+
/** https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */
|
132
|
+
async createGuildApplicationCommand(
|
133
|
+
guildId: string,
|
134
|
+
options: {
|
135
|
+
name: string;
|
136
|
+
nameLocalizations?: Partial<Record<Locale, string>> | null;
|
137
|
+
description?: string;
|
138
|
+
descriptionLocalizations?: Partial<Record<Locale, string>> | null;
|
139
|
+
options?: Array<JSONApplicationCommandOption>;
|
140
|
+
defaultMemberPermissions?: string | null;
|
141
|
+
dmPermission?: boolean;
|
142
|
+
defaultPermission?: boolean | null;
|
143
|
+
type?: ApplicationCommandTypes;
|
144
|
+
nsfw?: boolean;
|
145
|
+
}
|
146
|
+
): Promise<ApplicationCommand> {
|
147
|
+
return new ApplicationCommand(
|
148
|
+
await this.client.rest.post<RawApplicationCommand>(
|
149
|
+
Endpoints.applicationGuildCommands(this.id, guildId),
|
150
|
+
{
|
151
|
+
json: this.client.util.applicationCommandToRaw(options),
|
152
|
+
}
|
153
|
+
),
|
154
|
+
this.client
|
155
|
+
);
|
156
|
+
}
|
157
|
+
|
158
|
+
/** https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement */
|
159
|
+
async createTestEntitlement(options: {
|
160
|
+
skuId: string;
|
161
|
+
ownerId: string;
|
162
|
+
ownerType: number;
|
163
|
+
}): Promise<TestEntitlement> {
|
164
|
+
return new TestEntitlement(
|
165
|
+
await this.client.rest.post<
|
166
|
+
Omit<RawEntitlement, "starts_at" | "ends_at" | "subscription_id">
|
167
|
+
>(Endpoints.applicationEntitlements(this.id), {
|
168
|
+
json: {
|
169
|
+
sku_id: options.skuId,
|
170
|
+
owner_id: options.ownerId,
|
171
|
+
owner_type: options.ownerType,
|
172
|
+
},
|
173
|
+
}),
|
174
|
+
this.client
|
175
|
+
);
|
176
|
+
}
|
177
|
+
|
178
|
+
/** https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command */
|
179
|
+
deleteGlobalApplicationCommand(commandId: string): void {
|
180
|
+
this.client.rest.delete(Endpoints.applicationCommand(this.id, commandId));
|
181
|
+
}
|
182
|
+
|
183
|
+
/** https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command */
|
184
|
+
deleteGuildApplicationCommand(guildId: string, commandId: string): void {
|
185
|
+
this.client.rest.delete(
|
186
|
+
Endpoints.applicationGuildCommand(this.id, guildId, commandId)
|
187
|
+
);
|
188
|
+
}
|
189
|
+
|
190
|
+
/** https://discord.com/developers/docs/monetization/entitlements#delete-test-entitlement */
|
191
|
+
deleteTestEntitlement(entitlementId: string): void {
|
192
|
+
this.client.rest.delete(
|
193
|
+
Endpoints.applicationEntitlement(this.id, entitlementId)
|
194
|
+
);
|
195
|
+
}
|
196
|
+
|
197
|
+
/** https://discord.com/developers/docs/resources/application#edit-current-application */
|
198
|
+
async edit(options: {
|
199
|
+
customInstallURL?: string;
|
200
|
+
description?: string;
|
201
|
+
roleConnectionsVerificationURL?: string;
|
202
|
+
installParams?: JSONInstallParams;
|
203
|
+
flags?: ApplicationFlags;
|
204
|
+
icon?: string;
|
205
|
+
coverImage?: string;
|
206
|
+
interactionsEndpointURL?: string;
|
207
|
+
tags?: Array<string>;
|
208
|
+
}): Promise<Application> {
|
209
|
+
return new Application(
|
210
|
+
await this.client.rest.patch<RawApplication>(
|
211
|
+
Endpoints.applicationCurrentUser(),
|
212
|
+
{
|
213
|
+
json: {
|
214
|
+
custom_install_url: options.customInstallURL,
|
215
|
+
description: options.description,
|
216
|
+
role_connections_verification_url:
|
217
|
+
options.roleConnectionsVerificationURL,
|
218
|
+
install_params: options.installParams,
|
219
|
+
flags: options.flags,
|
220
|
+
icon: options.icon,
|
221
|
+
cover_image: options.coverImage,
|
222
|
+
interactions_endpoint_url: options.interactionsEndpointURL,
|
223
|
+
tags: options.tags,
|
224
|
+
},
|
225
|
+
}
|
226
|
+
),
|
227
|
+
this.client
|
228
|
+
);
|
229
|
+
}
|
230
|
+
|
231
|
+
/** https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */
|
232
|
+
async editApplicationCommandPermissions(
|
233
|
+
guildId: string,
|
234
|
+
commandId: string,
|
235
|
+
options: {
|
236
|
+
permissions: Array<JSONGuildApplicationCommandPermissions>;
|
237
|
+
}
|
238
|
+
): Promise<JSONGuildApplicationCommandPermissions> {
|
239
|
+
return this.client.rest
|
240
|
+
.put<RawGuildApplicationCommandPermissions>(
|
241
|
+
Endpoints.applicationCommandPermissions(this.id, guildId, commandId),
|
242
|
+
{
|
243
|
+
json: {
|
244
|
+
permissions: options.permissions.map((option) => ({
|
245
|
+
id: option.id,
|
246
|
+
application_id: option.applicationId,
|
247
|
+
guild_id: option.guildId,
|
248
|
+
permissions: option.permissions.map((permission) => ({
|
249
|
+
id: permission.id,
|
250
|
+
type: permission.type,
|
251
|
+
permission: permission.permission,
|
252
|
+
})),
|
253
|
+
})),
|
254
|
+
},
|
255
|
+
}
|
256
|
+
)
|
257
|
+
.then((response) => ({
|
258
|
+
id: response.id,
|
259
|
+
applicationId: response.application_id,
|
260
|
+
guildId: response.guild_id,
|
261
|
+
permissions: response.permissions.map((permission) => ({
|
262
|
+
id: permission.id,
|
263
|
+
type: permission.type,
|
264
|
+
permission: permission.permission,
|
265
|
+
})),
|
266
|
+
}));
|
267
|
+
}
|
268
|
+
|
269
|
+
/** https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */
|
270
|
+
async editGlobalApplicationCommand(
|
271
|
+
commandId: string,
|
272
|
+
options: {
|
273
|
+
name?: string;
|
274
|
+
nameLocalizations?: Partial<Record<Locale, string>> | null;
|
275
|
+
description?: string;
|
276
|
+
descriptionLocalizations?: Partial<Record<Locale, string>> | null;
|
277
|
+
options?: Array<JSONApplicationCommandOption>;
|
278
|
+
defaultMemberPermissions?: string | null;
|
279
|
+
defaultPermission?: boolean | null;
|
280
|
+
dmPermission?: boolean;
|
281
|
+
nsfw?: boolean;
|
282
|
+
}
|
283
|
+
): Promise<ApplicationCommand> {
|
284
|
+
return new ApplicationCommand(
|
285
|
+
await this.client.rest.patch<RawApplicationCommand>(
|
286
|
+
Endpoints.applicationCommand(this.id, commandId),
|
287
|
+
{
|
288
|
+
json: this.client.util.applicationCommandToRaw(options),
|
289
|
+
}
|
290
|
+
),
|
291
|
+
this.client
|
292
|
+
);
|
293
|
+
}
|
294
|
+
|
295
|
+
/** https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */
|
296
|
+
async editGuildApplicationCommand(
|
297
|
+
guildId: string,
|
298
|
+
commandId: string,
|
299
|
+
options: {
|
300
|
+
name?: string;
|
301
|
+
nameLocalizations?: Partial<Record<Locale, string>> | null;
|
302
|
+
description?: string;
|
303
|
+
descriptionLocalizations?: Partial<Record<Locale, string>> | null;
|
304
|
+
options?: Array<JSONApplicationCommandOption>;
|
305
|
+
defaultMemberPermissions?: string | null;
|
306
|
+
defaultPermission?: boolean | null;
|
307
|
+
dmPermission?: boolean;
|
308
|
+
nsfw?: boolean;
|
309
|
+
}
|
310
|
+
): Promise<ApplicationCommand> {
|
311
|
+
return new ApplicationCommand(
|
312
|
+
await this.client.rest.patch<RawApplicationCommand>(
|
313
|
+
Endpoints.applicationGuildCommand(this.id, guildId, commandId),
|
314
|
+
{
|
315
|
+
json: this.client.util.applicationCommandToRaw(options),
|
316
|
+
}
|
317
|
+
),
|
318
|
+
this.client
|
319
|
+
);
|
320
|
+
}
|
321
|
+
|
322
|
+
/** https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */
|
323
|
+
async getApplicationCommandPermissions(
|
324
|
+
guildId: string,
|
325
|
+
commandId: string
|
326
|
+
): Promise<Array<JSONGuildApplicationCommandPermissions>> {
|
327
|
+
return this.client.rest
|
328
|
+
.get<Array<RawGuildApplicationCommandPermissions>>(
|
329
|
+
Endpoints.applicationCommandPermissions(this.id, guildId, commandId)
|
330
|
+
)
|
331
|
+
.then((response) =>
|
332
|
+
response.map((permissions: RawGuildApplicationCommandPermissions) => ({
|
333
|
+
id: permissions.id,
|
334
|
+
applicationId: permissions.application_id,
|
335
|
+
guildId: permissions.guild_id,
|
336
|
+
permissions: permissions.permissions.map((permission) => ({
|
337
|
+
id: permission.id,
|
338
|
+
type: permission.type,
|
339
|
+
permission: permission.permission,
|
340
|
+
})),
|
341
|
+
}))
|
342
|
+
);
|
343
|
+
}
|
344
|
+
|
345
|
+
/** https://discord.com/developers/docs/monetization/entitlements#list-entitlements */
|
346
|
+
async getEntitlements(options?: {
|
347
|
+
userId?: string;
|
348
|
+
skuIds?: Array<string>;
|
349
|
+
before?: string;
|
350
|
+
after?: string;
|
351
|
+
limit?: number;
|
352
|
+
guildId?: string;
|
353
|
+
excludeEnded?: boolean;
|
354
|
+
}): Promise<Array<Entitlement>> {
|
355
|
+
return this.client.rest
|
356
|
+
.get<Array<RawEntitlement>>(Endpoints.applicationEntitlements(this.id), {
|
357
|
+
query: {
|
358
|
+
user_id: options?.userId,
|
359
|
+
sku_ids: options?.skuIds,
|
360
|
+
before: options?.before,
|
361
|
+
after: options?.after,
|
362
|
+
limit: options?.limit,
|
363
|
+
guild_id: options?.guildId,
|
364
|
+
exclude_ended: options?.excludeEnded,
|
365
|
+
},
|
366
|
+
})
|
367
|
+
.then((response) =>
|
368
|
+
response.map((data) => new Entitlement(data, this.client))
|
369
|
+
);
|
370
|
+
}
|
371
|
+
|
372
|
+
/** https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */
|
373
|
+
async getGlobalApplicationCommand(
|
374
|
+
commandId: string
|
375
|
+
): Promise<ApplicationCommand> {
|
376
|
+
return new ApplicationCommand(
|
377
|
+
await this.client.rest.get<RawApplicationCommand>(
|
378
|
+
Endpoints.applicationCommand(this.id, commandId)
|
379
|
+
),
|
380
|
+
this.client
|
381
|
+
);
|
382
|
+
}
|
383
|
+
|
384
|
+
/** https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */
|
385
|
+
async getGlobalApplicationCommands(options: {
|
386
|
+
withLocalizations?: boolean;
|
387
|
+
}): Promise<Array<ApplicationCommand>> {
|
388
|
+
return this.client.rest
|
389
|
+
.get<Array<RawApplicationCommand>>(
|
390
|
+
Endpoints.applicationCommands(this.id),
|
391
|
+
{
|
392
|
+
query: {
|
393
|
+
with_localizations: options.withLocalizations,
|
394
|
+
},
|
395
|
+
}
|
396
|
+
)
|
397
|
+
.then((response) =>
|
398
|
+
response.map((data) => new ApplicationCommand(data, this.client))
|
399
|
+
);
|
400
|
+
}
|
401
|
+
|
402
|
+
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command */
|
403
|
+
async getGuildApplicationCommand(
|
404
|
+
guildId: string,
|
405
|
+
commandId: string
|
406
|
+
): Promise<ApplicationCommand> {
|
407
|
+
return new ApplicationCommand(
|
408
|
+
await this.client.rest.get<RawApplicationCommand>(
|
409
|
+
Endpoints.applicationGuildCommand(this.id, guildId, commandId)
|
410
|
+
),
|
411
|
+
this.client
|
412
|
+
);
|
413
|
+
}
|
414
|
+
|
415
|
+
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */
|
416
|
+
async getGuildApplicationCommands(
|
417
|
+
guildId: string,
|
418
|
+
options?: {
|
419
|
+
withLocalizations?: boolean;
|
420
|
+
}
|
421
|
+
): Promise<Array<ApplicationCommand>> {
|
422
|
+
return this.client.rest
|
423
|
+
.get<Array<RawApplicationCommand>>(
|
424
|
+
Endpoints.applicationGuildCommands(this.id, guildId),
|
425
|
+
{
|
426
|
+
query: {
|
427
|
+
with_localizations: options?.withLocalizations,
|
428
|
+
},
|
429
|
+
}
|
430
|
+
)
|
431
|
+
.then((response) =>
|
432
|
+
response.map((data) => new ApplicationCommand(data, this.client))
|
433
|
+
);
|
434
|
+
}
|
435
|
+
|
436
|
+
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
|
437
|
+
async getGuildApplicationCommandPermissions(
|
438
|
+
guildId: string
|
439
|
+
): Promise<Array<JSONGuildApplicationCommandPermissions>> {
|
440
|
+
return this.client.rest
|
441
|
+
.get<Array<RawGuildApplicationCommandPermissions>>(
|
442
|
+
Endpoints.guildApplicationCommandsPermissions(this.id, guildId)
|
443
|
+
)
|
444
|
+
.then((response) =>
|
445
|
+
response.map((permissions: RawGuildApplicationCommandPermissions) => ({
|
446
|
+
id: permissions.id,
|
447
|
+
applicationId: permissions.application_id,
|
448
|
+
guildId: permissions.guild_id,
|
449
|
+
permissions: permissions.permissions.map((permission) => ({
|
450
|
+
id: permission.id,
|
451
|
+
type: permission.type,
|
452
|
+
permission: permission.permission,
|
453
|
+
})),
|
454
|
+
}))
|
455
|
+
);
|
456
|
+
}
|
457
|
+
|
458
|
+
/** https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records */
|
459
|
+
async getApplicationRoleConnectionMetadataRecords(): Promise<
|
460
|
+
Array<JSONApplicationRoleConnectionMetadata>
|
461
|
+
> {
|
462
|
+
return this.client.rest
|
463
|
+
.get<Array<RawApplicationRoleConnectionMetadata>>(
|
464
|
+
Endpoints.applicationRoleConnectionMetadata(this.id)
|
465
|
+
)
|
466
|
+
.then((response) =>
|
467
|
+
response.map((data) => ({
|
468
|
+
type: data.type,
|
469
|
+
key: data.key,
|
470
|
+
name: data.name,
|
471
|
+
nameLocalizations: data.name_localizations,
|
472
|
+
description: data.description,
|
473
|
+
descriptionLocalizations: data.description_localizations,
|
474
|
+
}))
|
475
|
+
);
|
476
|
+
}
|
477
|
+
|
478
|
+
/** https://discord.com/developers/docs/monetization/skus#list-skus */
|
479
|
+
async getSKUs(): Promise<Array<SKU>> {
|
480
|
+
return this.client.rest
|
481
|
+
.get<Array<RawSKU>>(Endpoints.applicationSKUs(this.id))
|
482
|
+
.then((response) => response.map((data) => new SKU(data, this.client)));
|
483
|
+
}
|
484
|
+
|
485
|
+
/** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */
|
486
|
+
async setGlobalApplicationCommands(
|
487
|
+
commands: Array<{
|
488
|
+
id?: string;
|
489
|
+
name: string;
|
490
|
+
nameLocalizations?: Partial<Record<Locale, string>> | null;
|
491
|
+
description?: string;
|
492
|
+
descriptionLocalizations?: Partial<Record<Locale, string>> | null;
|
493
|
+
options?: Array<JSONApplicationCommandOption>;
|
494
|
+
defaultMemberPermissions?: string | null;
|
495
|
+
dmPermission?: boolean;
|
496
|
+
defaultPermission?: boolean | null;
|
497
|
+
type?: ApplicationCommandTypes;
|
498
|
+
nsfw?: boolean;
|
499
|
+
}>
|
500
|
+
): Promise<Array<ApplicationCommand>> {
|
501
|
+
return this.client.rest
|
502
|
+
.put<Array<RawApplicationCommand>>(
|
503
|
+
Endpoints.applicationCommands(this.id),
|
504
|
+
{
|
505
|
+
json: commands.map((command) =>
|
506
|
+
this.client.util.applicationCommandToRaw(command)
|
507
|
+
),
|
508
|
+
}
|
509
|
+
)
|
510
|
+
.then((response) =>
|
511
|
+
response.map((data) => new ApplicationCommand(data, this.client))
|
512
|
+
);
|
513
|
+
}
|
514
|
+
|
515
|
+
/** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */
|
516
|
+
async setGuildApplicationCommands(
|
517
|
+
guildId: string,
|
518
|
+
commands: Array<{
|
519
|
+
id?: string;
|
520
|
+
name: string;
|
521
|
+
nameLocalizations?: Partial<Record<Locale, string>> | null;
|
522
|
+
description?: string;
|
523
|
+
descriptionLocalizations?: Partial<Record<Locale, string>> | null;
|
524
|
+
options?: Array<JSONApplicationCommandOption>;
|
525
|
+
defaultMemberPermissions?: string | null;
|
526
|
+
dmPermission?: boolean;
|
527
|
+
defaultPermission?: boolean | null;
|
528
|
+
type: ApplicationCommandTypes;
|
529
|
+
nsfw?: boolean;
|
530
|
+
}>
|
531
|
+
): Promise<Array<ApplicationCommand>> {
|
532
|
+
return this.client.rest
|
533
|
+
.put<Array<RawApplicationCommand>>(
|
534
|
+
Endpoints.applicationGuildCommands(this.id, guildId),
|
535
|
+
{
|
536
|
+
json: commands.map((command) =>
|
537
|
+
this.client.util.applicationCommandToRaw(command)
|
538
|
+
),
|
539
|
+
}
|
540
|
+
)
|
541
|
+
.then((response) =>
|
542
|
+
response.map((data) => new ApplicationCommand(data, this.client))
|
543
|
+
);
|
544
|
+
}
|
545
|
+
|
546
|
+
/** https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records */
|
547
|
+
async updateApplicationRoleConnectionMetadataRecords(): Promise<
|
548
|
+
Array<JSONApplicationRoleConnectionMetadata>
|
549
|
+
> {
|
550
|
+
return this.client.rest
|
551
|
+
.put<Array<RawApplicationRoleConnectionMetadata>>(
|
552
|
+
Endpoints.applicationRoleConnectionMetadata(this.id)
|
553
|
+
)
|
554
|
+
.then((response) =>
|
555
|
+
response.map((data) => ({
|
556
|
+
type: data.type,
|
557
|
+
key: data.key,
|
558
|
+
name: data.name,
|
559
|
+
nameLocalizations: data.name_localizations,
|
560
|
+
description: data.description,
|
561
|
+
descriptionLocalizations: data.description_localizations,
|
562
|
+
}))
|
563
|
+
);
|
564
|
+
}
|
565
|
+
|
566
|
+
override toRaw(): RawApplication {
|
567
|
+
return this.raw;
|
568
|
+
}
|
569
|
+
|
570
|
+
override toJSON(): JSONApplication {
|
571
|
+
return {
|
572
|
+
...super.toJSON(),
|
573
|
+
name: this.name,
|
574
|
+
icon: this.icon,
|
575
|
+
description: this.description,
|
576
|
+
rpcOrigins: this.rpcOrigins,
|
577
|
+
botPublic: this.botPublic,
|
578
|
+
botRequireCodeGrant: this.botRequireCodeGrant,
|
579
|
+
termsOfServiceURL: this.termsOfServiceURL,
|
580
|
+
privacyPolicyURL: this.privacyPolicyURL,
|
581
|
+
owner: this.owner?.toJSON(),
|
582
|
+
verifyKey: this.verifyKey,
|
583
|
+
team: this.team?.toJSON() ?? null,
|
584
|
+
guildId: this.guildId,
|
585
|
+
guild: this.guild?.toJSON(),
|
586
|
+
primarySKUId: this.primarySKUId,
|
587
|
+
slug: this.slug,
|
588
|
+
coverImage: this.coverImage,
|
589
|
+
flags: this.flags,
|
590
|
+
approximateGuildCount: this.approximateGuildCount,
|
591
|
+
redirectURIs: this.redirectURIs,
|
592
|
+
interactionsEndpointURL: this.interactionsEndpointURL,
|
593
|
+
roleConnectionsVerificationURL: this.roleConnectionsVerificationURL,
|
594
|
+
tags: this.tags,
|
595
|
+
installParams: this.installParams,
|
596
|
+
customInstallURL: this.customInstallURL,
|
597
|
+
};
|
598
|
+
}
|
599
|
+
}
|