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,421 @@
|
|
1
|
+
import {
|
2
|
+
Application,
|
3
|
+
Base,
|
4
|
+
Channel,
|
5
|
+
Emoji,
|
6
|
+
GuildMember,
|
7
|
+
Role,
|
8
|
+
Sticker,
|
9
|
+
User,
|
10
|
+
} from ".";
|
11
|
+
import type { Client } from "../Client";
|
12
|
+
import { Endpoints, type File } from "../rest";
|
13
|
+
import type {
|
14
|
+
JSONActionRow,
|
15
|
+
JSONAllowedMentions,
|
16
|
+
JSONAttachment,
|
17
|
+
JSONChannelMention,
|
18
|
+
JSONEmbed,
|
19
|
+
JSONMessage,
|
20
|
+
JSONMessageActivity,
|
21
|
+
JSONMessageCreateEventExtraFields,
|
22
|
+
JSONMessageInteraction,
|
23
|
+
JSONMessageReference,
|
24
|
+
JSONReaction,
|
25
|
+
JSONResolvedData,
|
26
|
+
JSONRoleSubscriptionData,
|
27
|
+
JSONStickerItem,
|
28
|
+
RawChannel,
|
29
|
+
RawMessage,
|
30
|
+
RawMessageCreateEventExtraFields,
|
31
|
+
RawUser,
|
32
|
+
} from "../types";
|
33
|
+
import { MessageFlags, MessageTypes } from "../constants";
|
34
|
+
|
35
|
+
/** https://discord.com/developers/docs/resources/channel */
|
36
|
+
export class Message extends Base {
|
37
|
+
protected override raw: RawMessage &
|
38
|
+
Partial<RawMessageCreateEventExtraFields>;
|
39
|
+
channelId: string;
|
40
|
+
author: User;
|
41
|
+
content: string;
|
42
|
+
timestamp: string;
|
43
|
+
editedTimestamp: string | null;
|
44
|
+
tts: boolean;
|
45
|
+
mentionEveryone: boolean;
|
46
|
+
mentions: Array<User>;
|
47
|
+
mentionRoles: Array<string>;
|
48
|
+
mentionChannels?: Array<JSONChannelMention>;
|
49
|
+
attachments: Array<JSONAttachment>;
|
50
|
+
embeds: Array<JSONEmbed>;
|
51
|
+
reactions?: Array<JSONReaction>;
|
52
|
+
nonce?: number | string;
|
53
|
+
pinned: boolean;
|
54
|
+
webhookId?: string;
|
55
|
+
type: MessageTypes;
|
56
|
+
activity?: JSONMessageActivity;
|
57
|
+
application?: Application;
|
58
|
+
applicationId?: string;
|
59
|
+
messageReference?: JSONMessageReference;
|
60
|
+
flags?: MessageFlags;
|
61
|
+
referencedMessage?: Message | null;
|
62
|
+
interaction?: JSONMessageInteraction;
|
63
|
+
thread?: Channel;
|
64
|
+
components?: Array<JSONActionRow>;
|
65
|
+
stickerItems?: Array<JSONStickerItem>;
|
66
|
+
stickers?: Array<Sticker>;
|
67
|
+
position?: number;
|
68
|
+
roleSubscriptionData?: JSONRoleSubscriptionData;
|
69
|
+
resolved?: JSONResolvedData;
|
70
|
+
guildId?: string;
|
71
|
+
member?: GuildMember;
|
72
|
+
|
73
|
+
constructor(
|
74
|
+
data: RawMessage & Partial<RawMessageCreateEventExtraFields>,
|
75
|
+
client: Client
|
76
|
+
) {
|
77
|
+
super(data.id, client);
|
78
|
+
|
79
|
+
this.raw = data;
|
80
|
+
this.channelId = data.channel_id;
|
81
|
+
this.author = new User(data.author, this.client);
|
82
|
+
this.content = data.content;
|
83
|
+
this.timestamp = data.timestamp;
|
84
|
+
this.editedTimestamp =
|
85
|
+
data.edited_timestamp !== null ? data.edited_timestamp : null;
|
86
|
+
this.mentions = data.mentions.map((user) => new User(user, this.client));
|
87
|
+
this.mentionRoles = data.mention_roles;
|
88
|
+
this.attachments = data.attachments.map((attachment) =>
|
89
|
+
this.client.util.attachmentToJSON(attachment)
|
90
|
+
);
|
91
|
+
this.embeds = this.client.util.embedsToJSON(data.embeds);
|
92
|
+
this.tts = data.tts;
|
93
|
+
this.mentionEveryone = data.mention_everyone;
|
94
|
+
this.pinned = data.pinned;
|
95
|
+
this.type = data.type;
|
96
|
+
|
97
|
+
this.patch(data);
|
98
|
+
}
|
99
|
+
|
100
|
+
protected override patch(
|
101
|
+
data: RawMessage & Partial<RawMessageCreateEventExtraFields>
|
102
|
+
): void {
|
103
|
+
if (data.mention_channels !== undefined)
|
104
|
+
this.mentionChannels = data.mention_channels.map((mentionChannel) => ({
|
105
|
+
id: mentionChannel.id,
|
106
|
+
guildId: mentionChannel.guild_id,
|
107
|
+
type: mentionChannel.type,
|
108
|
+
name: mentionChannel.name,
|
109
|
+
}));
|
110
|
+
if (data.reactions !== undefined)
|
111
|
+
this.reactions = data.reactions.map((reaction) => ({
|
112
|
+
count: reaction.count,
|
113
|
+
countDetails: reaction.count_details,
|
114
|
+
me: reaction.me,
|
115
|
+
meBurst: reaction.me_burst,
|
116
|
+
emoji: new Emoji(reaction.emoji, this.client).toJSON(),
|
117
|
+
burstColors: reaction.burst_colors,
|
118
|
+
}));
|
119
|
+
if (data.nonce !== undefined) this.nonce = data.nonce;
|
120
|
+
if (data.webhook_id !== undefined) this.webhookId = data.webhook_id;
|
121
|
+
if (data.activity !== undefined) this.activity = data.activity;
|
122
|
+
if (data.application !== undefined)
|
123
|
+
this.application = new Application(data.application, this.client);
|
124
|
+
if (data.application_id !== undefined)
|
125
|
+
this.applicationId = data.application_id;
|
126
|
+
if (data.message_reference !== undefined)
|
127
|
+
this.messageReference = {
|
128
|
+
messageId: data.message_reference.message_id,
|
129
|
+
channelId: data.message_reference.channel_id,
|
130
|
+
guildId: data.message_reference.guild_id,
|
131
|
+
failIfNotExists: data.message_reference.fail_if_not_exists,
|
132
|
+
};
|
133
|
+
if (data.flags !== undefined) this.flags = data.flags;
|
134
|
+
if (data.referenced_message !== undefined)
|
135
|
+
this.referencedMessage =
|
136
|
+
data.referenced_message !== null
|
137
|
+
? new Message(data.referenced_message, this.client)
|
138
|
+
: null;
|
139
|
+
if (data.interaction !== undefined)
|
140
|
+
this.interaction = {
|
141
|
+
id: data.interaction.id,
|
142
|
+
type: data.interaction.type,
|
143
|
+
name: data.interaction.name,
|
144
|
+
user: new User(data.interaction.user, this.client),
|
145
|
+
member:
|
146
|
+
data.interaction.member !== undefined
|
147
|
+
? new GuildMember(data.interaction.member, this.client)
|
148
|
+
: undefined,
|
149
|
+
};
|
150
|
+
if (data.thread !== undefined)
|
151
|
+
this.thread = new Channel(data.thread, this.client);
|
152
|
+
if (data.components !== undefined)
|
153
|
+
this.components = this.client.util.messageComponentsToJSON(
|
154
|
+
data.components
|
155
|
+
);
|
156
|
+
if (data.sticker_items !== undefined)
|
157
|
+
this.stickerItems = data.sticker_items.map((stickerItem) => ({
|
158
|
+
id: stickerItem.id,
|
159
|
+
name: stickerItem.name,
|
160
|
+
formatType: stickerItem.format_type,
|
161
|
+
}));
|
162
|
+
if (data.stickers !== undefined)
|
163
|
+
this.stickers = data.stickers.map(
|
164
|
+
(sticker) => new Sticker(sticker, this.client)
|
165
|
+
);
|
166
|
+
if (data.position !== undefined) this.position = data.position;
|
167
|
+
if (data.role_subscription_data !== undefined)
|
168
|
+
this.roleSubscriptionData = {
|
169
|
+
roleSubscriptionListingId:
|
170
|
+
data.role_subscription_data.role_subscription_listing_id,
|
171
|
+
tierName: data.role_subscription_data.tier_name,
|
172
|
+
totalMonthsSubscribed:
|
173
|
+
data.role_subscription_data.total_months_subscribed,
|
174
|
+
isRenewal: data.role_subscription_data.is_renewal,
|
175
|
+
};
|
176
|
+
if (data.resolved !== undefined)
|
177
|
+
this.resolved = {
|
178
|
+
users:
|
179
|
+
data.resolved?.users !== undefined
|
180
|
+
? new Map(
|
181
|
+
Object.entries(data.resolved.users).map(([id, user]) => [
|
182
|
+
id,
|
183
|
+
new User(user, this.client).toJSON(),
|
184
|
+
])
|
185
|
+
)
|
186
|
+
: undefined,
|
187
|
+
members:
|
188
|
+
data.resolved?.members !== undefined
|
189
|
+
? new Map(
|
190
|
+
Object.entries(data.resolved.members).map(([id, member]) => [
|
191
|
+
id,
|
192
|
+
new GuildMember(member, this.client).toJSON(),
|
193
|
+
])
|
194
|
+
)
|
195
|
+
: undefined,
|
196
|
+
roles:
|
197
|
+
data.resolved?.roles !== undefined
|
198
|
+
? new Map(
|
199
|
+
Object.entries(data.resolved.roles).map(([id, role]) => [
|
200
|
+
id,
|
201
|
+
new Role(role, this.client).toJSON(),
|
202
|
+
])
|
203
|
+
)
|
204
|
+
: undefined,
|
205
|
+
channels:
|
206
|
+
data.resolved?.channels !== undefined
|
207
|
+
? new Map(
|
208
|
+
Object.entries(data.resolved.channels).map(([id, channel]) => [
|
209
|
+
id,
|
210
|
+
new Channel(channel, this.client).toJSON(),
|
211
|
+
])
|
212
|
+
)
|
213
|
+
: undefined,
|
214
|
+
messages:
|
215
|
+
data.resolved?.messages !== undefined
|
216
|
+
? new Map(
|
217
|
+
Object.entries(data.resolved.messages).map(([id, message]) => [
|
218
|
+
id,
|
219
|
+
new Message(message, this.client).toJSON(),
|
220
|
+
])
|
221
|
+
)
|
222
|
+
: undefined,
|
223
|
+
attachments:
|
224
|
+
data.resolved?.attachments !== undefined
|
225
|
+
? new Map(
|
226
|
+
Object.entries(data.resolved.attachments).map(
|
227
|
+
([id, attachment]) => [
|
228
|
+
id,
|
229
|
+
this.client.util.attachmentToJSON(attachment),
|
230
|
+
]
|
231
|
+
)
|
232
|
+
)
|
233
|
+
: undefined,
|
234
|
+
};
|
235
|
+
if (data.guild_id !== undefined) this.guildId = data.guild_id;
|
236
|
+
if (data.member !== undefined)
|
237
|
+
this.member = new GuildMember(data.member, this.client);
|
238
|
+
}
|
239
|
+
|
240
|
+
/** https://discord.com/developers/docs/resources/channel#create-reaction */
|
241
|
+
createReaction(emoji: string): void {
|
242
|
+
this.client.rest.put(
|
243
|
+
Endpoints.channelMessageReaction(this.channelId, this.id, emoji)
|
244
|
+
);
|
245
|
+
}
|
246
|
+
|
247
|
+
/** https://discord.com/developers/docs/resources/channel#start-thread-from-message */
|
248
|
+
async createThread(
|
249
|
+
options: {
|
250
|
+
name: string;
|
251
|
+
autoArchiveDuration?: number;
|
252
|
+
rateLimitPerUser?: number | null;
|
253
|
+
},
|
254
|
+
reason?: string
|
255
|
+
): Promise<Channel> {
|
256
|
+
return new Channel(
|
257
|
+
await this.client.rest.post<RawChannel>(
|
258
|
+
Endpoints.threads(this.channelId, this.id),
|
259
|
+
{
|
260
|
+
json: {
|
261
|
+
name: options.name,
|
262
|
+
auto_archive_duration: options.autoArchiveDuration,
|
263
|
+
rate_limit_per_user: options.rateLimitPerUser,
|
264
|
+
},
|
265
|
+
reason,
|
266
|
+
}
|
267
|
+
),
|
268
|
+
this.client
|
269
|
+
);
|
270
|
+
}
|
271
|
+
|
272
|
+
/** https://discord.com/developers/docs/resources/channel#crosspost-message */
|
273
|
+
async crosspost(): Promise<Message> {
|
274
|
+
return new Message(
|
275
|
+
await this.client.rest.post<RawMessage>(
|
276
|
+
Endpoints.channelMessageCrosspost(this.channelId, this.id)
|
277
|
+
),
|
278
|
+
this.client
|
279
|
+
);
|
280
|
+
}
|
281
|
+
|
282
|
+
/** https://discord.com/developers/docs/resources/channel#delete-message */
|
283
|
+
delete(reason?: string): void {
|
284
|
+
this.client.rest.delete(Endpoints.channelMessage(this.channelId, this.id), {
|
285
|
+
reason,
|
286
|
+
});
|
287
|
+
}
|
288
|
+
|
289
|
+
/** https://discord.com/developers/docs/resources/channel#delete-all-reactions */
|
290
|
+
deleteAllReactions(emoji?: string): void {
|
291
|
+
this.client.rest.delete(
|
292
|
+
Endpoints.channelMessageAllReactions(this.channelId, this.id, emoji)
|
293
|
+
);
|
294
|
+
}
|
295
|
+
|
296
|
+
/**
|
297
|
+
* https://discord.com/developers/docs/resources/channel#delete-own-reaction
|
298
|
+
* https://discord.com/developers/docs/resources/channel#delete-user-reaction
|
299
|
+
*/
|
300
|
+
deleteReaction(emoji: string, userId?: string): void {
|
301
|
+
this.client.rest.delete(
|
302
|
+
Endpoints.channelMessageReaction(this.channelId, this.id, emoji, userId)
|
303
|
+
);
|
304
|
+
}
|
305
|
+
|
306
|
+
/** https://discord.com/developers/docs/resources/channel#edit-message */
|
307
|
+
async edit(options: {
|
308
|
+
content?: string | null;
|
309
|
+
embeds?: Array<JSONEmbed> | null;
|
310
|
+
flags?: MessageFlags | null;
|
311
|
+
allowedMentions?: JSONAllowedMentions | null;
|
312
|
+
components?: Array<JSONActionRow> | null;
|
313
|
+
files?: Array<File> | null;
|
314
|
+
attachments?: Array<JSONAttachment> | null;
|
315
|
+
}): Promise<Message> {
|
316
|
+
return new Message(
|
317
|
+
await this.client.rest.patch<RawMessage>(
|
318
|
+
Endpoints.channelMessage(this.channelId, this.id),
|
319
|
+
{
|
320
|
+
json: {
|
321
|
+
content: options.content,
|
322
|
+
embeds:
|
323
|
+
options.embeds !== undefined
|
324
|
+
? options.embeds !== null
|
325
|
+
? this.client.util.embedsToRaw(options.embeds)
|
326
|
+
: null
|
327
|
+
: undefined,
|
328
|
+
allowed_mentions: options.allowedMentions,
|
329
|
+
components:
|
330
|
+
options.components !== undefined
|
331
|
+
? options.components !== null
|
332
|
+
? this.client.util.messageComponentsToRaw(options.components)
|
333
|
+
: null
|
334
|
+
: undefined,
|
335
|
+
attachments: options.attachments,
|
336
|
+
flags: options.flags,
|
337
|
+
},
|
338
|
+
files: options.files,
|
339
|
+
}
|
340
|
+
),
|
341
|
+
this.client
|
342
|
+
);
|
343
|
+
}
|
344
|
+
|
345
|
+
/** https://discord.com/developers/docs/resources/channel#get-reactions */
|
346
|
+
async getReactions(
|
347
|
+
emoji: string,
|
348
|
+
options?: {
|
349
|
+
after?: string;
|
350
|
+
limit?: number;
|
351
|
+
}
|
352
|
+
): Promise<Array<User>> {
|
353
|
+
return this.client.rest
|
354
|
+
.get<Array<RawUser>>(
|
355
|
+
Endpoints.channelMessageAllReactions(this.channelId, this.id, emoji),
|
356
|
+
{
|
357
|
+
query: {
|
358
|
+
after: options?.after,
|
359
|
+
limit: options?.limit,
|
360
|
+
},
|
361
|
+
}
|
362
|
+
)
|
363
|
+
.then((response) => response.map((data) => new User(data, this.client)));
|
364
|
+
}
|
365
|
+
|
366
|
+
/** https://discord.com/developers/docs/resources/channel#pin-message */
|
367
|
+
pin(reason?: string): void {
|
368
|
+
this.client.rest.put(Endpoints.channelPin(this.channelId, this.id), {
|
369
|
+
reason,
|
370
|
+
});
|
371
|
+
}
|
372
|
+
|
373
|
+
/** https://discord.com/developers/docs/resources/channel#unpin-message */
|
374
|
+
unpin(reason?: string): void {
|
375
|
+
this.client.rest.delete(Endpoints.channelPin(this.channelId, this.id), {
|
376
|
+
reason,
|
377
|
+
});
|
378
|
+
}
|
379
|
+
|
380
|
+
override toRaw(): RawMessage & Partial<RawMessageCreateEventExtraFields> {
|
381
|
+
return this.raw;
|
382
|
+
}
|
383
|
+
|
384
|
+
override toJSON(): JSONMessage & Partial<JSONMessageCreateEventExtraFields> {
|
385
|
+
return {
|
386
|
+
...super.toJSON(),
|
387
|
+
channelId: this.channelId,
|
388
|
+
author: this.author.toJSON(),
|
389
|
+
content: this.content,
|
390
|
+
timestamp: this.timestamp,
|
391
|
+
editedTimestamp: this.editedTimestamp,
|
392
|
+
tts: this.tts,
|
393
|
+
mentionEveryone: this.mentionEveryone,
|
394
|
+
mentions: this.mentions,
|
395
|
+
mentionRoles: this.mentionRoles,
|
396
|
+
mentionChannels: this.mentionChannels,
|
397
|
+
attachments: this.attachments,
|
398
|
+
embeds: this.embeds,
|
399
|
+
reactions: this.reactions,
|
400
|
+
nonce: this.nonce,
|
401
|
+
pinned: this.pinned,
|
402
|
+
webhookId: this.webhookId,
|
403
|
+
type: this.type,
|
404
|
+
activity: this.activity,
|
405
|
+
application: this.application?.toJSON(),
|
406
|
+
applicationId: this.applicationId,
|
407
|
+
messageReference: this.messageReference,
|
408
|
+
flags: this.flags,
|
409
|
+
referencedMessage: this.referencedMessage?.toJSON(),
|
410
|
+
interaction: this.interaction,
|
411
|
+
thread: this.thread,
|
412
|
+
components: this.components,
|
413
|
+
stickerItems: this.stickerItems,
|
414
|
+
stickers: this.stickers,
|
415
|
+
position: this.position,
|
416
|
+
roleSubscriptionData: this.roleSubscriptionData,
|
417
|
+
guildId: this.guildId,
|
418
|
+
member: this.member?.toJSON(),
|
419
|
+
};
|
420
|
+
}
|
421
|
+
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import type { Client } from "../Client";
|
2
|
+
import { Endpoints } from "../rest";
|
3
|
+
import type { JSONRole, JSONRoleTags, RawRole } from "../types";
|
4
|
+
import { Base } from ".";
|
5
|
+
import { RoleFlags } from "../constants";
|
6
|
+
|
7
|
+
/** https://discord.com/developers/docs/topics/permissions */
|
8
|
+
export class Role extends Base {
|
9
|
+
protected override raw: RawRole;
|
10
|
+
name: string;
|
11
|
+
color: number;
|
12
|
+
hoist: boolean;
|
13
|
+
icon?: string | null;
|
14
|
+
unicodeEmoji?: string | null;
|
15
|
+
position: number;
|
16
|
+
permissions: string;
|
17
|
+
managed: boolean;
|
18
|
+
mentionable: boolean;
|
19
|
+
tags?: JSONRoleTags;
|
20
|
+
flags: RoleFlags;
|
21
|
+
|
22
|
+
constructor(data: RawRole, client: Client) {
|
23
|
+
super(data.id, client);
|
24
|
+
|
25
|
+
this.raw = data;
|
26
|
+
this.name = data.name;
|
27
|
+
this.color = data.color;
|
28
|
+
this.hoist = data.hoist;
|
29
|
+
this.position = data.position;
|
30
|
+
this.permissions = data.permissions;
|
31
|
+
this.managed = data.managed;
|
32
|
+
this.mentionable = data.mentionable;
|
33
|
+
this.flags = data.flags;
|
34
|
+
|
35
|
+
this.patch(data);
|
36
|
+
}
|
37
|
+
|
38
|
+
protected override patch(data: RawRole): void {
|
39
|
+
if (data.icon !== undefined) this.icon = data.icon;
|
40
|
+
if (data.unicode_emoji !== undefined)
|
41
|
+
this.unicodeEmoji = data.unicode_emoji;
|
42
|
+
if (data.tags !== undefined)
|
43
|
+
this.tags = {
|
44
|
+
botId: data.tags.bot_id,
|
45
|
+
integrationId: data.tags.integration_id,
|
46
|
+
premiumSubscriber: data.tags.premium_subscriber,
|
47
|
+
subscriptionListingId: data.tags.subscription_listing_id,
|
48
|
+
availableForPurchase: data.tags.available_for_purchase,
|
49
|
+
guildConnections: data.tags.guild_connections,
|
50
|
+
};
|
51
|
+
}
|
52
|
+
|
53
|
+
/** https://discord.com/developers/docs/resources/guild#delete-guild-role */
|
54
|
+
delete(guildId: string, reason?: string): void {
|
55
|
+
this.client.rest.delete(Endpoints.guildRole(guildId, this.id), {
|
56
|
+
reason,
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
/** https://discord.com/developers/docs/resources/guild#modify-guild-role */
|
61
|
+
async edit(
|
62
|
+
guildId: string,
|
63
|
+
options?: {
|
64
|
+
name?: string | null;
|
65
|
+
permissions?: string | null;
|
66
|
+
color?: number | null;
|
67
|
+
hoist?: boolean | null;
|
68
|
+
icon?: string | null;
|
69
|
+
unicodeEmoji?: string | null;
|
70
|
+
mentionable?: boolean | null;
|
71
|
+
},
|
72
|
+
reason?: string
|
73
|
+
): Promise<Role> {
|
74
|
+
return new Role(
|
75
|
+
await this.client.rest.patch<RawRole>(
|
76
|
+
Endpoints.guildRole(guildId, this.id),
|
77
|
+
{
|
78
|
+
json: {
|
79
|
+
name: options?.name,
|
80
|
+
permissions: options?.permissions,
|
81
|
+
color: options?.color,
|
82
|
+
hoist: options?.hoist,
|
83
|
+
icon: options?.icon,
|
84
|
+
unicode_emoji: options?.unicodeEmoji,
|
85
|
+
mentionable: options?.mentionable,
|
86
|
+
},
|
87
|
+
reason,
|
88
|
+
}
|
89
|
+
),
|
90
|
+
this.client
|
91
|
+
);
|
92
|
+
}
|
93
|
+
|
94
|
+
override toRaw(): RawRole & {
|
95
|
+
guild_id?: string;
|
96
|
+
} {
|
97
|
+
return this.raw;
|
98
|
+
}
|
99
|
+
|
100
|
+
override toJSON(): JSONRole {
|
101
|
+
return {
|
102
|
+
...super.toJSON(),
|
103
|
+
name: this.name,
|
104
|
+
color: this.color,
|
105
|
+
hoist: this.hoist,
|
106
|
+
icon: this.icon,
|
107
|
+
unicodeEmoji: this.unicodeEmoji,
|
108
|
+
position: this.position,
|
109
|
+
permissions: this.permissions,
|
110
|
+
managed: this.managed,
|
111
|
+
mentionable: this.mentionable,
|
112
|
+
tags: this.tags,
|
113
|
+
flags: this.flags,
|
114
|
+
};
|
115
|
+
}
|
116
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import type { Client } from "../Client";
|
2
|
+
import type { JSONSKU, RawSKU } from "../types";
|
3
|
+
import { Base } from ".";
|
4
|
+
import type { SKUFlags, SKUTypes } from "../constants";
|
5
|
+
|
6
|
+
/** https://discord.com/developers/docs/monetization/skus */
|
7
|
+
export class SKU extends Base {
|
8
|
+
protected override raw: RawSKU;
|
9
|
+
type: SKUTypes;
|
10
|
+
dependentSKUId?: string | null; // Undocumented
|
11
|
+
applicationId: string;
|
12
|
+
manifestLabels?: null; // Undocumented
|
13
|
+
accessType?: number; // Undocumented
|
14
|
+
name: string;
|
15
|
+
features?: []; // Undocumented
|
16
|
+
releaseDate?: null; // Undocumented
|
17
|
+
slug: string;
|
18
|
+
flags: SKUFlags;
|
19
|
+
showAgeGate?: boolean; // Undocumented
|
20
|
+
|
21
|
+
constructor(data: RawSKU, client: Client) {
|
22
|
+
super(data.id, client);
|
23
|
+
|
24
|
+
this.raw = data;
|
25
|
+
this.type = data.type;
|
26
|
+
this.applicationId = data.application_id;
|
27
|
+
this.name = data.name;
|
28
|
+
this.slug = data.slug;
|
29
|
+
this.flags = data.flags;
|
30
|
+
}
|
31
|
+
|
32
|
+
protected override patch(data: RawSKU): void {
|
33
|
+
if (data.dependent_sku_id !== undefined)
|
34
|
+
this.dependentSKUId = data.dependent_sku_id;
|
35
|
+
if (data.manifest_labels !== undefined)
|
36
|
+
this.manifestLabels = data.manifest_labels;
|
37
|
+
if (data.access_type !== undefined) this.accessType = data.access_type;
|
38
|
+
if (data.features !== undefined) this.features = data.features;
|
39
|
+
if (data.release_date !== undefined) this.releaseDate = data.release_date;
|
40
|
+
if (data.show_age_gate !== undefined) this.showAgeGate = data.show_age_gate;
|
41
|
+
}
|
42
|
+
|
43
|
+
override toRaw(): RawSKU {
|
44
|
+
return this.raw;
|
45
|
+
}
|
46
|
+
|
47
|
+
override toJSON(): JSONSKU {
|
48
|
+
return {
|
49
|
+
id: this.id,
|
50
|
+
type: this.type,
|
51
|
+
dependentSKUId: this.dependentSKUId,
|
52
|
+
applicationId: this.applicationId,
|
53
|
+
manifestLabels: this.manifestLabels,
|
54
|
+
accessType: this.accessType,
|
55
|
+
name: this.name,
|
56
|
+
features: this.features,
|
57
|
+
releaseDate: this.releaseDate,
|
58
|
+
slug: this.slug,
|
59
|
+
flags: this.flags,
|
60
|
+
showAgeGate: this.showAgeGate,
|
61
|
+
};
|
62
|
+
}
|
63
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import type { Client } from "../Client";
|
2
|
+
import { Endpoints } from "../rest";
|
3
|
+
import type { JSONStageInstance, RawStageInstance } from "../types";
|
4
|
+
import type { PrivacyLevel } from "../constants";
|
5
|
+
import { Base } from ".";
|
6
|
+
|
7
|
+
/** https://discord.com/developers/docs/resources/stage-instance */
|
8
|
+
export class StageInstance extends Base {
|
9
|
+
protected override raw: RawStageInstance;
|
10
|
+
guildId: string;
|
11
|
+
channelId: string;
|
12
|
+
topic: string;
|
13
|
+
privacyLevel: PrivacyLevel;
|
14
|
+
discoverableDisabled: boolean;
|
15
|
+
guildScheduledEventId: string | null;
|
16
|
+
|
17
|
+
constructor(data: RawStageInstance, client: Client) {
|
18
|
+
super(data.id, client);
|
19
|
+
|
20
|
+
this.raw = data;
|
21
|
+
this.guildId = data.guild_id;
|
22
|
+
this.channelId = data.channel_id;
|
23
|
+
this.topic = data.topic;
|
24
|
+
this.privacyLevel = data.privacy_level;
|
25
|
+
this.discoverableDisabled = data.discoverable_disabled;
|
26
|
+
this.guildScheduledEventId = data.guild_scheduled_event_id;
|
27
|
+
}
|
28
|
+
|
29
|
+
/** https://discord.com/developers/docs/resources/stage-instance#delete-stage-instance */
|
30
|
+
delete(reason?: string): void {
|
31
|
+
this.client.rest.delete(Endpoints.stageInstance(this.channelId), {
|
32
|
+
reason,
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
/** https://discord.com/developers/docs/resources/stage-instance#modify-stage-instance */
|
37
|
+
async edit(
|
38
|
+
options: {
|
39
|
+
topic?: string;
|
40
|
+
privacyLevel?: PrivacyLevel;
|
41
|
+
},
|
42
|
+
reason?: string
|
43
|
+
): Promise<StageInstance> {
|
44
|
+
return new StageInstance(
|
45
|
+
await this.client.rest.patch<RawStageInstance>(
|
46
|
+
Endpoints.stageInstance(this.channelId),
|
47
|
+
{
|
48
|
+
json: {
|
49
|
+
topic: options.topic,
|
50
|
+
privacy_level: options.privacyLevel,
|
51
|
+
},
|
52
|
+
reason,
|
53
|
+
}
|
54
|
+
),
|
55
|
+
this.client
|
56
|
+
);
|
57
|
+
}
|
58
|
+
|
59
|
+
override toRaw(): RawStageInstance {
|
60
|
+
return this.raw;
|
61
|
+
}
|
62
|
+
|
63
|
+
override toJSON(): JSONStageInstance {
|
64
|
+
return {
|
65
|
+
...super.toJSON(),
|
66
|
+
guildId: this.guildId,
|
67
|
+
channelId: this.channelId,
|
68
|
+
topic: this.topic,
|
69
|
+
privacyLevel: this.privacyLevel,
|
70
|
+
discoverableDisabled: this.discoverableDisabled,
|
71
|
+
guildScheduledEventId: this.guildScheduledEventId,
|
72
|
+
};
|
73
|
+
}
|
74
|
+
}
|