disgroove 1.3.3-dev.2 → 1.3.3-dev.3
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/package.json +1 -1
- package/package.json +1 -1
- package/dist/lib/Client.d.ts +0 -234
- package/dist/lib/Client.js +0 -256
- package/dist/lib/Client.js.map +0 -1
- package/dist/lib/constants.d.ts +0 -1084
- package/dist/lib/constants.js +0 -1163
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/gateway/Shard.d.ts +0 -25
- package/dist/lib/gateway/Shard.js +0 -522
- package/dist/lib/gateway/Shard.js.map +0 -1
- package/dist/lib/gateway/ShardsManager.d.ts +0 -5
- package/dist/lib/gateway/ShardsManager.js +0 -13
- package/dist/lib/gateway/ShardsManager.js.map +0 -1
- package/dist/lib/gateway/index.d.ts +0 -2
- package/dist/lib/gateway/index.js +0 -19
- package/dist/lib/gateway/index.js.map +0 -1
- package/dist/lib/index.d.ts +0 -7
- package/dist/lib/index.js +0 -24
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/rest/CDN.d.ts +0 -21
- package/dist/lib/rest/CDN.js +0 -46
- package/dist/lib/rest/CDN.js.map +0 -1
- package/dist/lib/rest/Endpoints.d.ts +0 -94
- package/dist/lib/rest/Endpoints.js +0 -211
- package/dist/lib/rest/Endpoints.js.map +0 -1
- package/dist/lib/rest/REST.d.ts +0 -22
- package/dist/lib/rest/REST.js +0 -35
- package/dist/lib/rest/REST.js.map +0 -1
- package/dist/lib/rest/RequestsManager.d.ts +0 -17
- package/dist/lib/rest/RequestsManager.js +0 -124
- package/dist/lib/rest/RequestsManager.js.map +0 -1
- package/dist/lib/rest/index.d.ts +0 -4
- package/dist/lib/rest/index.js +0 -34
- package/dist/lib/rest/index.js.map +0 -1
- package/dist/lib/structures/Application.d.ts +0 -174
- package/dist/lib/structures/Application.js +0 -328
- package/dist/lib/structures/Application.js.map +0 -1
- package/dist/lib/structures/ApplicationCommand.d.ts +0 -45
- package/dist/lib/structures/ApplicationCommand.js +0 -127
- package/dist/lib/structures/ApplicationCommand.js.map +0 -1
- package/dist/lib/structures/AuditLog.d.ts +0 -20
- package/dist/lib/structures/AuditLog.js +0 -76
- package/dist/lib/structures/AuditLog.js.map +0 -1
- package/dist/lib/structures/AutoModerationRule.d.ts +0 -34
- package/dist/lib/structures/AutoModerationRule.js +0 -96
- package/dist/lib/structures/AutoModerationRule.js.map +0 -1
- package/dist/lib/structures/Base.d.ts +0 -17
- package/dist/lib/structures/Base.js +0 -31
- package/dist/lib/structures/Base.js.map +0 -1
- package/dist/lib/structures/Channel.d.ts +0 -253
- package/dist/lib/structures/Channel.js +0 -591
- package/dist/lib/structures/Channel.js.map +0 -1
- package/dist/lib/structures/ClientApplication.d.ts +0 -150
- package/dist/lib/structures/ClientApplication.js +0 -241
- package/dist/lib/structures/ClientApplication.js.map +0 -1
- package/dist/lib/structures/Emoji.d.ts +0 -28
- package/dist/lib/structures/Emoji.js +0 -79
- package/dist/lib/structures/Emoji.js.map +0 -1
- package/dist/lib/structures/Entitlement.d.ts +0 -24
- package/dist/lib/structures/Entitlement.js +0 -68
- package/dist/lib/structures/Entitlement.js.map +0 -1
- package/dist/lib/structures/Guild.d.ts +0 -462
- package/dist/lib/structures/Guild.js +0 -1095
- package/dist/lib/structures/Guild.js.map +0 -1
- package/dist/lib/structures/GuildMember.d.ts +0 -50
- package/dist/lib/structures/GuildMember.js +0 -149
- package/dist/lib/structures/GuildMember.js.map +0 -1
- package/dist/lib/structures/GuildScheduledEvent.d.ts +0 -49
- package/dist/lib/structures/GuildScheduledEvent.js +0 -118
- package/dist/lib/structures/GuildScheduledEvent.js.map +0 -1
- package/dist/lib/structures/GuildTemplate.d.ts +0 -32
- package/dist/lib/structures/GuildTemplate.js +0 -76
- package/dist/lib/structures/GuildTemplate.js.map +0 -1
- package/dist/lib/structures/Integration.d.ts +0 -30
- package/dist/lib/structures/Integration.js +0 -102
- package/dist/lib/structures/Integration.js.map +0 -1
- package/dist/lib/structures/Interaction.d.ts +0 -76
- package/dist/lib/structures/Interaction.js +0 -345
- package/dist/lib/structures/Interaction.js.map +0 -1
- package/dist/lib/structures/Invite.d.ts +0 -28
- package/dist/lib/structures/Invite.js +0 -86
- package/dist/lib/structures/Invite.js.map +0 -1
- package/dist/lib/structures/Message.d.ts +0 -84
- package/dist/lib/structures/Message.js +0 -300
- package/dist/lib/structures/Message.js.map +0 -1
- package/dist/lib/structures/Role.d.ts +0 -37
- package/dist/lib/structures/Role.js +0 -90
- package/dist/lib/structures/Role.js.map +0 -1
- package/dist/lib/structures/SKU.d.ts +0 -23
- package/dist/lib/structures/SKU.js +0 -63
- package/dist/lib/structures/SKU.js.map +0 -1
- package/dist/lib/structures/StageInstance.d.ts +0 -24
- package/dist/lib/structures/StageInstance.js +0 -57
- package/dist/lib/structures/StageInstance.js.map +0 -1
- package/dist/lib/structures/Sticker.d.ts +0 -31
- package/dist/lib/structures/Sticker.js +0 -86
- package/dist/lib/structures/Sticker.js.map +0 -1
- package/dist/lib/structures/Team.d.ts +0 -14
- package/dist/lib/structures/Team.js +0 -39
- package/dist/lib/structures/Team.js.map +0 -1
- package/dist/lib/structures/TestEntitlement.d.ts +0 -23
- package/dist/lib/structures/TestEntitlement.js +0 -61
- package/dist/lib/structures/TestEntitlement.js.map +0 -1
- package/dist/lib/structures/UnavailableGuild.d.ts +0 -11
- package/dist/lib/structures/UnavailableGuild.js +0 -25
- package/dist/lib/structures/UnavailableGuild.js.map +0 -1
- package/dist/lib/structures/User.d.ts +0 -63
- package/dist/lib/structures/User.js +0 -177
- package/dist/lib/structures/User.js.map +0 -1
- package/dist/lib/structures/VoiceState.d.ts +0 -26
- package/dist/lib/structures/VoiceState.js +0 -70
- package/dist/lib/structures/VoiceState.js.map +0 -1
- package/dist/lib/structures/Webhook.d.ts +0 -84
- package/dist/lib/structures/Webhook.js +0 -239
- package/dist/lib/structures/Webhook.js.map +0 -1
- package/dist/lib/structures/index.d.ts +0 -27
- package/dist/lib/structures/index.js +0 -44
- package/dist/lib/structures/index.js.map +0 -1
- package/dist/lib/types/application-command.d.ts +0 -102
- package/dist/lib/types/application-command.js +0 -3
- package/dist/lib/types/application-command.js.map +0 -1
- package/dist/lib/types/application-role-connection-metadata.d.ts +0 -18
- package/dist/lib/types/application-role-connection-metadata.js +0 -3
- package/dist/lib/types/application-role-connection-metadata.js.map +0 -1
- package/dist/lib/types/application.d.ts +0 -66
- package/dist/lib/types/application.js +0 -3
- package/dist/lib/types/application.js.map +0 -1
- package/dist/lib/types/audit-log.d.ts +0 -82
- package/dist/lib/types/audit-log.js +0 -3
- package/dist/lib/types/audit-log.js.map +0 -1
- package/dist/lib/types/auto-moderation.d.ts +0 -65
- package/dist/lib/types/auto-moderation.js +0 -3
- package/dist/lib/types/auto-moderation.js.map +0 -1
- package/dist/lib/types/channel.d.ts +0 -456
- package/dist/lib/types/channel.js +0 -3
- package/dist/lib/types/channel.js.map +0 -1
- package/dist/lib/types/emoji.d.ts +0 -22
- package/dist/lib/types/emoji.js +0 -3
- package/dist/lib/types/emoji.js.map +0 -1
- package/dist/lib/types/entitlements.d.ts +0 -32
- package/dist/lib/types/entitlements.js +0 -3
- package/dist/lib/types/entitlements.js.map +0 -1
- package/dist/lib/types/gateway-events.d.ts +0 -805
- package/dist/lib/types/gateway-events.js +0 -3
- package/dist/lib/types/gateway-events.js.map +0 -1
- package/dist/lib/types/guild-scheduled-event.d.ts +0 -57
- package/dist/lib/types/guild-scheduled-event.js +0 -3
- package/dist/lib/types/guild-scheduled-event.js.map +0 -1
- package/dist/lib/types/guild-template.d.ts +0 -28
- package/dist/lib/types/guild-template.js +0 -3
- package/dist/lib/types/guild-template.js.map +0 -1
- package/dist/lib/types/guild.d.ts +0 -333
- package/dist/lib/types/guild.js +0 -3
- package/dist/lib/types/guild.js.map +0 -1
- package/dist/lib/types/index.d.ts +0 -23
- package/dist/lib/types/index.js +0 -40
- package/dist/lib/types/index.js.map +0 -1
- package/dist/lib/types/interaction.d.ts +0 -170
- package/dist/lib/types/interaction.js +0 -3
- package/dist/lib/types/interaction.js.map +0 -1
- package/dist/lib/types/invite.d.ts +0 -59
- package/dist/lib/types/invite.js +0 -3
- package/dist/lib/types/invite.js.map +0 -1
- package/dist/lib/types/message-components.d.ts +0 -100
- package/dist/lib/types/message-components.js +0 -3
- package/dist/lib/types/message-components.js.map +0 -1
- package/dist/lib/types/role.d.ts +0 -47
- package/dist/lib/types/role.js +0 -3
- package/dist/lib/types/role.js.map +0 -1
- package/dist/lib/types/sku.d.ts +0 -30
- package/dist/lib/types/sku.js +0 -3
- package/dist/lib/types/sku.js.map +0 -1
- package/dist/lib/types/stage-instance.d.ts +0 -20
- package/dist/lib/types/stage-instance.js +0 -3
- package/dist/lib/types/stage-instance.js.map +0 -1
- package/dist/lib/types/sticker.d.ts +0 -61
- package/dist/lib/types/sticker.js +0 -3
- package/dist/lib/types/sticker.js.map +0 -1
- package/dist/lib/types/team.d.ts +0 -30
- package/dist/lib/types/team.js +0 -3
- package/dist/lib/types/team.js.map +0 -1
- package/dist/lib/types/user.d.ts +0 -77
- package/dist/lib/types/user.js +0 -3
- package/dist/lib/types/user.js.map +0 -1
- package/dist/lib/types/voice.d.ts +0 -47
- package/dist/lib/types/voice.js +0 -3
- package/dist/lib/types/voice.js.map +0 -1
- package/dist/lib/types/webhook.d.ts +0 -31
- package/dist/lib/types/webhook.js +0 -3
- package/dist/lib/types/webhook.js.map +0 -1
- package/dist/lib/utils/Util.d.ts +0 -15
- package/dist/lib/utils/Util.js +0 -543
- package/dist/lib/utils/Util.js.map +0 -1
- package/dist/lib/utils/errors.d.ts +0 -12
- package/dist/lib/utils/errors.js +0 -25
- package/dist/lib/utils/errors.js.map +0 -1
- package/dist/lib/utils/index.d.ts +0 -2
- package/dist/lib/utils/index.js +0 -19
- package/dist/lib/utils/index.js.map +0 -1
- package/examples/applicationCommands.js +0 -43
- package/examples/buttons.js +0 -70
- package/examples/embeds.js +0 -36
- package/examples/ephemeralMessages.js +0 -32
- package/examples/files.js +0 -36
- package/examples/modalSubmit.js +0 -62
- package/examples/permissions.js +0 -41
- package/examples/selectMenus.js +0 -160
- package/examples/text.txt +0 -1
- package/lib/Client.ts +0 -616
- package/lib/constants.ts +0 -1173
- package/lib/gateway/Shard.ts +0 -704
- package/lib/gateway/ShardsManager.ts +0 -11
- package/lib/gateway/index.ts +0 -2
- package/lib/index.ts +0 -7
- package/lib/rest/CDN.ts +0 -56
- package/lib/rest/Endpoints.ts +0 -241
- package/lib/rest/REST.ts +0 -45
- package/lib/rest/RequestsManager.ts +0 -134
- package/lib/rest/index.ts +0 -4
- package/lib/structures/Application.ts +0 -599
- package/lib/structures/ApplicationCommand.ts +0 -187
- package/lib/structures/AuditLog.ts +0 -112
- package/lib/structures/AutoModerationRule.ts +0 -127
- package/lib/structures/Base.ts +0 -39
- package/lib/structures/Channel.ts +0 -921
- package/lib/structures/ClientApplication.ts +0 -515
- package/lib/structures/Emoji.ts +0 -95
- package/lib/structures/Entitlement.ts +0 -65
- package/lib/structures/Guild.ts +0 -1842
- package/lib/structures/GuildMember.ts +0 -193
- package/lib/structures/GuildScheduledEvent.ts +0 -164
- package/lib/structures/GuildTemplate.ts +0 -103
- package/lib/structures/Integration.ts +0 -136
- package/lib/structures/Interaction.ts +0 -506
- package/lib/structures/Invite.ts +0 -108
- package/lib/structures/Message.ts +0 -421
- package/lib/structures/Role.ts +0 -116
- package/lib/structures/SKU.ts +0 -63
- package/lib/structures/StageInstance.ts +0 -74
- package/lib/structures/Sticker.ts +0 -100
- package/lib/structures/Team.ts +0 -41
- package/lib/structures/TestEntitlement.ts +0 -78
- package/lib/structures/UnavailableGuild.ts +0 -27
- package/lib/structures/User.ts +0 -233
- package/lib/structures/VoiceState.ts +0 -72
- package/lib/structures/Webhook.ts +0 -341
- package/lib/structures/index.ts +0 -27
- package/lib/types/application-command.ts +0 -118
- package/lib/types/application-role-connection-metadata.ts +0 -23
- package/lib/types/application.ts +0 -77
- package/lib/types/audit-log.ts +0 -105
- package/lib/types/auto-moderation.ts +0 -78
- package/lib/types/channel.ts +0 -534
- package/lib/types/emoji.ts +0 -24
- package/lib/types/entitlements.ts +0 -34
- package/lib/types/gateway-events.ts +0 -970
- package/lib/types/guild-scheduled-event.ts +0 -67
- package/lib/types/guild-template.ts +0 -30
- package/lib/types/guild.ts +0 -388
- package/lib/types/index.ts +0 -23
- package/lib/types/interaction.ts +0 -224
- package/lib/types/invite.ts +0 -78
- package/lib/types/message-components.ts +0 -127
- package/lib/types/role.ts +0 -51
- package/lib/types/sku.ts +0 -32
- package/lib/types/stage-instance.ts +0 -22
- package/lib/types/sticker.ts +0 -67
- package/lib/types/team.ts +0 -34
- package/lib/types/user.ts +0 -93
- package/lib/types/voice.ts +0 -51
- package/lib/types/webhook.ts +0 -40
- package/lib/utils/Util.ts +0 -600
- package/lib/utils/errors.ts +0 -23
- package/lib/utils/index.ts +0 -2
- package/test/basic.js +0 -8
- package/tsconfig.json +0 -107
@@ -1,187 +0,0 @@
|
|
1
|
-
import type { Client } from "../Client";
|
2
|
-
import { Endpoints } from "../rest";
|
3
|
-
import type {
|
4
|
-
JSONApplicationCommand,
|
5
|
-
JSONApplicationCommandOption,
|
6
|
-
JSONApplicationCommandPermission,
|
7
|
-
JSONGuildApplicationCommandPermissions,
|
8
|
-
RawApplicationCommand,
|
9
|
-
RawGuildApplicationCommandPermissions,
|
10
|
-
} from "../types";
|
11
|
-
import type { ApplicationCommandTypes, Locale } from "../constants";
|
12
|
-
import { Base } from ".";
|
13
|
-
|
14
|
-
/** https://discord.com/developers/docs/interactions/application-commands */
|
15
|
-
export class ApplicationCommand extends Base {
|
16
|
-
protected override raw: RawApplicationCommand;
|
17
|
-
type?: ApplicationCommandTypes;
|
18
|
-
applicationId: string;
|
19
|
-
guildId?: string;
|
20
|
-
name: string;
|
21
|
-
nameLocalizations?: Partial<Record<Locale, string>> | null;
|
22
|
-
description: string;
|
23
|
-
descriptionLocalizations?: Partial<Record<Locale, string>> | null;
|
24
|
-
options?: Array<JSONApplicationCommandOption>;
|
25
|
-
defaultMemberPermissions: string | null;
|
26
|
-
dmPermission?: boolean;
|
27
|
-
defaultPermission?: boolean | null;
|
28
|
-
nsfw?: boolean;
|
29
|
-
version: string;
|
30
|
-
|
31
|
-
constructor(data: RawApplicationCommand, client: Client) {
|
32
|
-
super(data.id, client);
|
33
|
-
|
34
|
-
this.raw = data;
|
35
|
-
this.applicationId = data.application_id;
|
36
|
-
this.name = data.name;
|
37
|
-
this.description = data.description;
|
38
|
-
this.defaultMemberPermissions = data.default_member_permissions;
|
39
|
-
this.version = data.version;
|
40
|
-
|
41
|
-
this.patch(data);
|
42
|
-
}
|
43
|
-
|
44
|
-
protected override patch(data: RawApplicationCommand): void {
|
45
|
-
if (data.type !== undefined) this.type = data.type;
|
46
|
-
if (data.guild_id !== undefined) this.guildId = data.guild_id;
|
47
|
-
if (data.name_localizations !== undefined)
|
48
|
-
this.nameLocalizations = data.name_localizations;
|
49
|
-
if (data.description_localizations !== undefined)
|
50
|
-
this.descriptionLocalizations = data.description_localizations;
|
51
|
-
if (data.options !== undefined) this.options = data.options;
|
52
|
-
if (data.dm_permission !== undefined)
|
53
|
-
this.dmPermission = data.dm_permission;
|
54
|
-
if (data.default_permission !== undefined)
|
55
|
-
this.defaultPermission = data.default_permission;
|
56
|
-
if (data.nsfw !== undefined) this.nsfw = data.nsfw;
|
57
|
-
}
|
58
|
-
|
59
|
-
/** https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command */
|
60
|
-
delete(): void {
|
61
|
-
this.guildId !== undefined
|
62
|
-
? this.client.rest.delete(
|
63
|
-
Endpoints.applicationGuildCommand(
|
64
|
-
this.applicationId,
|
65
|
-
this.guildId,
|
66
|
-
this.id
|
67
|
-
)
|
68
|
-
)
|
69
|
-
: this.client.rest.delete(
|
70
|
-
Endpoints.applicationCommand(this.applicationId, this.id)
|
71
|
-
);
|
72
|
-
}
|
73
|
-
|
74
|
-
/** https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */
|
75
|
-
async edit(options: {
|
76
|
-
name?: string;
|
77
|
-
nameLocalizations?: Partial<Record<Locale, string>> | null;
|
78
|
-
description?: string;
|
79
|
-
descriptionLocalizations?: Partial<Record<Locale, string>> | null;
|
80
|
-
options?: Array<JSONApplicationCommandOption>;
|
81
|
-
defaultMemberPermissions?: string | null;
|
82
|
-
defaultPermission?: boolean | null;
|
83
|
-
dmPermission?: boolean;
|
84
|
-
nsfw?: boolean;
|
85
|
-
}): Promise<ApplicationCommand> {
|
86
|
-
return new ApplicationCommand(
|
87
|
-
this.guildId !== undefined
|
88
|
-
? await this.client.rest.patch<RawApplicationCommand>(
|
89
|
-
Endpoints.applicationGuildCommand(this.id, this.guildId, this.id),
|
90
|
-
{
|
91
|
-
json: this.client.util.applicationCommandToRaw(options),
|
92
|
-
}
|
93
|
-
)
|
94
|
-
: await this.client.rest.patch<RawApplicationCommand>(
|
95
|
-
Endpoints.applicationCommand(this.applicationId, this.id),
|
96
|
-
{
|
97
|
-
json: this.client.util.applicationCommandToRaw(options),
|
98
|
-
}
|
99
|
-
),
|
100
|
-
this.client
|
101
|
-
);
|
102
|
-
}
|
103
|
-
|
104
|
-
/** https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */
|
105
|
-
async editPermissions(options: {
|
106
|
-
permissions: Array<JSONApplicationCommandPermission>;
|
107
|
-
}): Promise<JSONGuildApplicationCommandPermissions> {
|
108
|
-
if (!this.guildId)
|
109
|
-
throw new Error(
|
110
|
-
"[disgroove] Cannot edit the permissions of a global application command"
|
111
|
-
);
|
112
|
-
|
113
|
-
return this.client.rest
|
114
|
-
.put<RawGuildApplicationCommandPermissions>(
|
115
|
-
Endpoints.applicationCommandPermissions(
|
116
|
-
this.applicationId,
|
117
|
-
this.guildId,
|
118
|
-
this.id
|
119
|
-
),
|
120
|
-
{
|
121
|
-
json: {
|
122
|
-
permissions: options.permissions,
|
123
|
-
},
|
124
|
-
}
|
125
|
-
)
|
126
|
-
.then((response) => ({
|
127
|
-
id: response.id,
|
128
|
-
applicationId: response.application_id,
|
129
|
-
guildId: response.guild_id,
|
130
|
-
permissions: response.permissions.map((permission) => ({
|
131
|
-
id: permission.id,
|
132
|
-
type: permission.type,
|
133
|
-
permission: permission.permission,
|
134
|
-
})),
|
135
|
-
}));
|
136
|
-
}
|
137
|
-
|
138
|
-
/** https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */
|
139
|
-
async getPermissions(): Promise<JSONGuildApplicationCommandPermissions> {
|
140
|
-
if (!this.guildId)
|
141
|
-
throw new Error(
|
142
|
-
"[disgroove] Cannot get the permissions of a global application command"
|
143
|
-
);
|
144
|
-
|
145
|
-
return this.client.rest
|
146
|
-
.get<RawGuildApplicationCommandPermissions>(
|
147
|
-
Endpoints.applicationCommandPermissions(
|
148
|
-
this.applicationId,
|
149
|
-
this.guildId,
|
150
|
-
this.id
|
151
|
-
)
|
152
|
-
)
|
153
|
-
.then((response) => ({
|
154
|
-
id: response.id,
|
155
|
-
applicationId: response.application_id,
|
156
|
-
guildId: response.guild_id,
|
157
|
-
permissions: response.permissions.map((permission) => ({
|
158
|
-
id: permission.id,
|
159
|
-
type: permission.type,
|
160
|
-
permission: permission.permission,
|
161
|
-
})),
|
162
|
-
}));
|
163
|
-
}
|
164
|
-
|
165
|
-
override toRaw(): RawApplicationCommand {
|
166
|
-
return this.raw;
|
167
|
-
}
|
168
|
-
|
169
|
-
override toJSON(): JSONApplicationCommand {
|
170
|
-
return {
|
171
|
-
...super.toJSON(),
|
172
|
-
type: this.type,
|
173
|
-
applicationId: this.applicationId,
|
174
|
-
guildId: this.guildId,
|
175
|
-
name: this.name,
|
176
|
-
nameLocalizations: this.nameLocalizations,
|
177
|
-
description: this.description,
|
178
|
-
descriptionLocalizations: this.descriptionLocalizations,
|
179
|
-
options: this.options,
|
180
|
-
defaultMemberPermissions: this.defaultMemberPermissions,
|
181
|
-
dmPermission: this.dmPermission,
|
182
|
-
defaultPermission: this.defaultPermission,
|
183
|
-
nsfw: this.nsfw,
|
184
|
-
version: this.version,
|
185
|
-
};
|
186
|
-
}
|
187
|
-
}
|
@@ -1,112 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
ApplicationCommand,
|
3
|
-
AutoModerationRule,
|
4
|
-
Channel,
|
5
|
-
GuildScheduledEvent,
|
6
|
-
Integration,
|
7
|
-
User,
|
8
|
-
Webhook,
|
9
|
-
} from ".";
|
10
|
-
import type { Client } from "../Client";
|
11
|
-
import type { JSONAuditLog, JSONAuditLogEntry, RawAuditLog } from "../types";
|
12
|
-
|
13
|
-
/** https://discord.com/developers/docs/resources/audit-log */
|
14
|
-
export class AuditLog {
|
15
|
-
private client: Client;
|
16
|
-
private raw: RawAuditLog;
|
17
|
-
applicationCommands: Array<ApplicationCommand>;
|
18
|
-
auditLogEntries: Array<JSONAuditLogEntry>;
|
19
|
-
autoModerationRules: Array<AutoModerationRule>;
|
20
|
-
guildScheduledEvents: Array<GuildScheduledEvent>;
|
21
|
-
integrations: Array<Integration>;
|
22
|
-
threads: Array<Channel>;
|
23
|
-
users: Array<User>;
|
24
|
-
webhooks: Array<Webhook>;
|
25
|
-
|
26
|
-
constructor(data: RawAuditLog, client: Client) {
|
27
|
-
this.client = client;
|
28
|
-
this.raw = data;
|
29
|
-
this.applicationCommands = data.application_commands.map(
|
30
|
-
(applicationCommand) =>
|
31
|
-
new ApplicationCommand(applicationCommand, this.client)
|
32
|
-
);
|
33
|
-
this.auditLogEntries = data.audit_log_entries.map((auditLogEntry) => ({
|
34
|
-
targetId: auditLogEntry.target_id,
|
35
|
-
changes: auditLogEntry.changes?.map((change) => ({
|
36
|
-
newValue: change.new_value,
|
37
|
-
oldValue: change.old_value,
|
38
|
-
key: change.key,
|
39
|
-
})),
|
40
|
-
userId: auditLogEntry.user_id,
|
41
|
-
id: auditLogEntry.id,
|
42
|
-
actionType: auditLogEntry.action_type,
|
43
|
-
options:
|
44
|
-
auditLogEntry.options !== undefined
|
45
|
-
? {
|
46
|
-
applicationId: auditLogEntry.options.application_id,
|
47
|
-
autoModerationRuleName:
|
48
|
-
auditLogEntry.options.auto_moderation_rule_name,
|
49
|
-
autoModerationRuleTriggerType:
|
50
|
-
auditLogEntry.options.auto_moderation_rule_trigger_type,
|
51
|
-
channelId: auditLogEntry.options.channel_id,
|
52
|
-
count: auditLogEntry.options.count,
|
53
|
-
deleteMemberDays: auditLogEntry.options.delete_member_days,
|
54
|
-
id: auditLogEntry.options.id,
|
55
|
-
membersRemoved: auditLogEntry.options.members_removed,
|
56
|
-
messageId: auditLogEntry.options.message_id,
|
57
|
-
roleName: auditLogEntry.options.role_name,
|
58
|
-
type: auditLogEntry.options.type,
|
59
|
-
integrationType: auditLogEntry.options.integration_type,
|
60
|
-
}
|
61
|
-
: undefined,
|
62
|
-
reason: auditLogEntry.reason,
|
63
|
-
}));
|
64
|
-
this.autoModerationRules = data.auto_moderation_rules.map(
|
65
|
-
(autoModerationRule) =>
|
66
|
-
new AutoModerationRule(autoModerationRule, this.client)
|
67
|
-
);
|
68
|
-
this.guildScheduledEvents = data.guild_scheduled_events.map(
|
69
|
-
(guildScheduledEvent) =>
|
70
|
-
new GuildScheduledEvent(guildScheduledEvent, this.client)
|
71
|
-
);
|
72
|
-
this.integrations = data.integrations.map(
|
73
|
-
(integration) => new Integration(integration, this.client)
|
74
|
-
);
|
75
|
-
this.threads = data.threads.map(
|
76
|
-
(thread) => new Channel(thread, this.client)
|
77
|
-
);
|
78
|
-
this.users = data.users.map((user) => new User(user, this.client));
|
79
|
-
this.webhooks = data.webhooks.map(
|
80
|
-
(webhook) => new Webhook(webhook, this.client)
|
81
|
-
);
|
82
|
-
}
|
83
|
-
|
84
|
-
toString(): string {
|
85
|
-
return `[${this.constructor.name}]`;
|
86
|
-
}
|
87
|
-
|
88
|
-
toRaw(): RawAuditLog {
|
89
|
-
return this.raw;
|
90
|
-
}
|
91
|
-
|
92
|
-
toJSON(): JSONAuditLog {
|
93
|
-
return {
|
94
|
-
applicationCommands: this.applicationCommands.map((applicationCommand) =>
|
95
|
-
applicationCommand.toJSON()
|
96
|
-
),
|
97
|
-
auditLogEntries: this.auditLogEntries,
|
98
|
-
autoModerationRules: this.autoModerationRules.map((autoModerationRule) =>
|
99
|
-
autoModerationRule.toJSON()
|
100
|
-
),
|
101
|
-
guildScheduledEvents: this.guildScheduledEvents.map(
|
102
|
-
(guildScheduledEvent) => guildScheduledEvent.toJSON()
|
103
|
-
),
|
104
|
-
integrations: this.integrations.map((integration) =>
|
105
|
-
integration.toJSON()
|
106
|
-
),
|
107
|
-
threads: this.threads.map((thread) => thread.toJSON()),
|
108
|
-
users: this.users.map((user) => user.toJSON()),
|
109
|
-
webhooks: this.webhooks.map((webhook) => webhook.toJSON()),
|
110
|
-
};
|
111
|
-
}
|
112
|
-
}
|
@@ -1,127 +0,0 @@
|
|
1
|
-
import type { Client } from "../Client";
|
2
|
-
import { Endpoints } from "../rest";
|
3
|
-
import type {
|
4
|
-
JSONAutoModerationAction,
|
5
|
-
JSONAutoModerationRule,
|
6
|
-
JSONTriggerMetadata,
|
7
|
-
RawAutoModerationRule,
|
8
|
-
} from "../types";
|
9
|
-
import { Base } from ".";
|
10
|
-
import type { EventTypes, TriggerTypes } from "../constants";
|
11
|
-
|
12
|
-
/** https://discord.com/developers/docs/resources/auto-moderation */
|
13
|
-
export class AutoModerationRule extends Base {
|
14
|
-
protected override raw: RawAutoModerationRule;
|
15
|
-
guildId: string;
|
16
|
-
name: string;
|
17
|
-
creatorId: string;
|
18
|
-
eventType: EventTypes;
|
19
|
-
triggerType: TriggerTypes;
|
20
|
-
triggerMetadata: JSONTriggerMetadata;
|
21
|
-
actions: Array<JSONAutoModerationAction>;
|
22
|
-
enabled: boolean;
|
23
|
-
exemptRoles: Array<string>;
|
24
|
-
exemptChannels: Array<string>;
|
25
|
-
|
26
|
-
constructor(data: RawAutoModerationRule, client: Client) {
|
27
|
-
super(data.id, client);
|
28
|
-
|
29
|
-
this.raw = data;
|
30
|
-
this.guildId = data.guild_id;
|
31
|
-
this.name = data.name;
|
32
|
-
this.creatorId = data.creator_id;
|
33
|
-
this.eventType = data.event_type;
|
34
|
-
this.triggerType = data.trigger_type;
|
35
|
-
this.triggerMetadata = {
|
36
|
-
keywordFilter: data.trigger_metadata.keyword_filter,
|
37
|
-
regexPatterns: data.trigger_metadata.regex_patterns,
|
38
|
-
presets: data.trigger_metadata.presets,
|
39
|
-
allowList: data.trigger_metadata.allow_list,
|
40
|
-
mentionTotalLimit: data.trigger_metadata.mention_total_limit,
|
41
|
-
mentionRaidProtection: data.trigger_metadata.mention_raid_protection,
|
42
|
-
};
|
43
|
-
this.actions = data.actions.map((action) => ({
|
44
|
-
type: action.type,
|
45
|
-
metadata: {
|
46
|
-
channelId: action.metadata.channel_id,
|
47
|
-
durationSeconds: action.metadata.duration_seconds,
|
48
|
-
customMessage: action.metadata.custom_message,
|
49
|
-
},
|
50
|
-
}));
|
51
|
-
this.enabled = data.enabled;
|
52
|
-
this.exemptRoles = data.exempt_roles;
|
53
|
-
this.exemptChannels = data.exempt_channels;
|
54
|
-
}
|
55
|
-
|
56
|
-
/** https://discord.com/developers/docs/resources/auto-moderation#delete-auto-moderation-rule */
|
57
|
-
delete(reason?: string): void {
|
58
|
-
this.client.rest.delete(
|
59
|
-
Endpoints.guildAutoModerationRule(this.guildId, this.id),
|
60
|
-
{
|
61
|
-
reason,
|
62
|
-
}
|
63
|
-
);
|
64
|
-
}
|
65
|
-
|
66
|
-
/** https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule */
|
67
|
-
async edit(
|
68
|
-
options: {
|
69
|
-
name?: string;
|
70
|
-
eventType?: EventTypes;
|
71
|
-
triggerType?: TriggerTypes;
|
72
|
-
triggerMetadata?: JSONTriggerMetadata;
|
73
|
-
actions?: Array<JSONAutoModerationAction>;
|
74
|
-
enabled?: boolean;
|
75
|
-
exemptRoles?: Array<string>;
|
76
|
-
exemptChannels?: Array<string>;
|
77
|
-
},
|
78
|
-
reason?: string
|
79
|
-
): Promise<AutoModerationRule> {
|
80
|
-
return new AutoModerationRule(
|
81
|
-
await this.client.rest.patch<RawAutoModerationRule>(
|
82
|
-
Endpoints.guildAutoModerationRule(this.guildId, this.id),
|
83
|
-
{
|
84
|
-
json: {
|
85
|
-
name: options.name,
|
86
|
-
event_type: options.eventType,
|
87
|
-
trigger_type: options.triggerType,
|
88
|
-
trigger_metadata: options.triggerMetadata,
|
89
|
-
actions: options.actions?.map((action) => ({
|
90
|
-
type: action.type,
|
91
|
-
metadata: {
|
92
|
-
channelId: action.metadata.channelId,
|
93
|
-
durationSeconds: action.metadata.durationSeconds,
|
94
|
-
customMessage: action.metadata.customMessage,
|
95
|
-
},
|
96
|
-
})),
|
97
|
-
enabled: options.enabled,
|
98
|
-
exempt_roles: options.exemptRoles,
|
99
|
-
exempt_channels: options.exemptChannels,
|
100
|
-
},
|
101
|
-
reason,
|
102
|
-
}
|
103
|
-
),
|
104
|
-
this.client
|
105
|
-
);
|
106
|
-
}
|
107
|
-
|
108
|
-
override toRaw(): RawAutoModerationRule {
|
109
|
-
return this.raw;
|
110
|
-
}
|
111
|
-
|
112
|
-
override toJSON(): JSONAutoModerationRule {
|
113
|
-
return {
|
114
|
-
...super.toJSON(),
|
115
|
-
guildId: this.guildId,
|
116
|
-
name: this.name,
|
117
|
-
creatorId: this.creatorId,
|
118
|
-
eventType: this.eventType,
|
119
|
-
triggerType: this.triggerType,
|
120
|
-
triggerMetadata: this.triggerMetadata,
|
121
|
-
actions: this.actions,
|
122
|
-
enabled: this.enabled,
|
123
|
-
exemptRoles: this.exemptRoles,
|
124
|
-
exemptChannels: this.exemptChannels,
|
125
|
-
};
|
126
|
-
}
|
127
|
-
}
|
package/lib/structures/Base.ts
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
import type { Client } from "../Client";
|
2
|
-
|
3
|
-
export abstract class Base {
|
4
|
-
protected client: Client;
|
5
|
-
protected raw: {
|
6
|
-
id: string;
|
7
|
-
};
|
8
|
-
id: string;
|
9
|
-
|
10
|
-
constructor(id: string, client: Client) {
|
11
|
-
this.client = client;
|
12
|
-
this.raw = {
|
13
|
-
id,
|
14
|
-
};
|
15
|
-
this.id = id;
|
16
|
-
}
|
17
|
-
|
18
|
-
protected patch(data: unknown): void {}
|
19
|
-
|
20
|
-
toString(): string {
|
21
|
-
return `[${this.constructor.name}]`;
|
22
|
-
}
|
23
|
-
|
24
|
-
toRaw(): {
|
25
|
-
id: string;
|
26
|
-
} {
|
27
|
-
return {
|
28
|
-
id: this.id,
|
29
|
-
};
|
30
|
-
}
|
31
|
-
|
32
|
-
toJSON(): {
|
33
|
-
id: string;
|
34
|
-
} {
|
35
|
-
return {
|
36
|
-
id: this.id,
|
37
|
-
};
|
38
|
-
}
|
39
|
-
}
|