@impulsedev/chameleon 2.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{builders-CCZQJXF6.js → builders-WHD6LQWX.js} +5 -1
- package/dist/{chunk-F2RRJ7OJ.js → chunk-G4SUOXGV.js} +61 -0
- package/dist/index.d.ts +1019 -563
- package/dist/index.js +1586 -97
- package/package.json +1 -1
- package/diff.txt +0 -3086
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Designed for development of ...
|
|
|
9
9
|
- We store timestamps in milliseconds instead of Discord ISO8601 timestamps
|
|
10
10
|
- We store all structs in POJOs instead of classes
|
|
11
11
|
- All gateway events are strict discriminated unions
|
|
12
|
+
- Where possible, we're attaching X-Audit-Log-Reason header to REST requests
|
|
12
13
|
|
|
13
14
|
### Bugs?
|
|
14
15
|
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
buildGuild,
|
|
14
14
|
buildIntegration,
|
|
15
15
|
buildInteraction,
|
|
16
|
+
buildInvite,
|
|
16
17
|
buildMember,
|
|
17
18
|
buildMessage,
|
|
18
19
|
buildRole,
|
|
@@ -22,12 +23,13 @@ import {
|
|
|
22
23
|
buildStickerItem,
|
|
23
24
|
buildUser,
|
|
24
25
|
buildVoiceState,
|
|
26
|
+
buildWebhook,
|
|
25
27
|
resolveChannel,
|
|
26
28
|
resolveGuild,
|
|
27
29
|
resolveRole,
|
|
28
30
|
resolveUser,
|
|
29
31
|
serializeComponent
|
|
30
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-G4SUOXGV.js";
|
|
31
33
|
export {
|
|
32
34
|
ActionRowBuilder,
|
|
33
35
|
ButtonBuilder,
|
|
@@ -43,6 +45,7 @@ export {
|
|
|
43
45
|
buildGuild,
|
|
44
46
|
buildIntegration,
|
|
45
47
|
buildInteraction,
|
|
48
|
+
buildInvite,
|
|
46
49
|
buildMember,
|
|
47
50
|
buildMessage,
|
|
48
51
|
buildRole,
|
|
@@ -52,6 +55,7 @@ export {
|
|
|
52
55
|
buildStickerItem,
|
|
53
56
|
buildUser,
|
|
54
57
|
buildVoiceState,
|
|
58
|
+
buildWebhook,
|
|
55
59
|
resolveChannel,
|
|
56
60
|
resolveGuild,
|
|
57
61
|
resolveRole,
|
|
@@ -174,6 +174,18 @@ function toSnakeCase(obj) {
|
|
|
174
174
|
}
|
|
175
175
|
return obj;
|
|
176
176
|
}
|
|
177
|
+
function toCamelCase(obj) {
|
|
178
|
+
if (Array.isArray(obj)) {
|
|
179
|
+
return obj.map((v) => toCamelCase(v));
|
|
180
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
181
|
+
return Object.keys(obj).reduce((result, key) => {
|
|
182
|
+
const camelKey = key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
183
|
+
result[camelKey] = toCamelCase(obj[key]);
|
|
184
|
+
return result;
|
|
185
|
+
}, {});
|
|
186
|
+
}
|
|
187
|
+
return obj;
|
|
188
|
+
}
|
|
177
189
|
|
|
178
190
|
// src/builders/components.ts
|
|
179
191
|
function serializeEmoji(emoji) {
|
|
@@ -664,6 +676,52 @@ function buildInteraction(raw, cache) {
|
|
|
664
676
|
...raw.context !== void 0 ? { context: raw.context } : {}
|
|
665
677
|
};
|
|
666
678
|
}
|
|
679
|
+
function buildInvite(raw) {
|
|
680
|
+
let inviter;
|
|
681
|
+
let targetUser;
|
|
682
|
+
if (raw.inviter) {
|
|
683
|
+
inviter = buildUser(raw.inviter);
|
|
684
|
+
}
|
|
685
|
+
if (raw.target_user) {
|
|
686
|
+
targetUser = buildUser(raw.target_user);
|
|
687
|
+
}
|
|
688
|
+
return {
|
|
689
|
+
type: raw.type ?? 0,
|
|
690
|
+
code: raw.code,
|
|
691
|
+
...raw.guild ? { guild: buildGuild(raw.guild) } : {},
|
|
692
|
+
channel: raw.channel ? buildChannel(raw.channel) : null,
|
|
693
|
+
...inviter ? { inviter } : {},
|
|
694
|
+
...raw.target_type !== void 0 ? { targetType: raw.target_type } : {},
|
|
695
|
+
...targetUser ? { targetUser } : {},
|
|
696
|
+
...raw.target_application !== void 0 ? { targetApplication: raw.target_application } : {},
|
|
697
|
+
...raw.approximate_presence_count !== void 0 ? { approximatePresenceCount: raw.approximate_presence_count } : {},
|
|
698
|
+
...raw.approximate_member_count !== void 0 ? { approximateMemberCount: raw.approximate_member_count } : {},
|
|
699
|
+
expiresAt: raw.expires_at ? Date.parse(raw.expires_at) : null,
|
|
700
|
+
...raw.guild_scheduled_event !== void 0 ? { guildScheduledEvent: buildScheduledEvent(raw.guild_scheduled_event) } : {},
|
|
701
|
+
...raw.flags !== void 0 ? { flags: raw.flags } : {},
|
|
702
|
+
...raw.roles !== void 0 ? { roles: raw.roles } : {}
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
function buildWebhook(raw) {
|
|
706
|
+
let user;
|
|
707
|
+
if (raw.user) {
|
|
708
|
+
user = buildUser(raw.user);
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
id: raw.id,
|
|
712
|
+
type: raw.type ?? 1,
|
|
713
|
+
...raw.guild_id !== void 0 ? { guildId: raw.guild_id } : {},
|
|
714
|
+
...raw.channel_id !== void 0 ? { channelId: raw.channel_id } : {},
|
|
715
|
+
...user ? { user } : {},
|
|
716
|
+
name: raw.name ?? null,
|
|
717
|
+
avatar: raw.avatar ?? null,
|
|
718
|
+
...raw.token !== void 0 ? { token: raw.token } : {},
|
|
719
|
+
applicationId: raw.application_id ?? null,
|
|
720
|
+
...raw.source_guild ? { sourceGuild: buildGuild(raw.source_guild) } : {},
|
|
721
|
+
...raw.source_channel ? { sourceChannel: buildChannel(raw.source_channel) } : {},
|
|
722
|
+
...raw.url !== void 0 ? { url: raw.url } : {}
|
|
723
|
+
};
|
|
724
|
+
}
|
|
667
725
|
|
|
668
726
|
// src/builders/index.ts
|
|
669
727
|
function buildUser(raw) {
|
|
@@ -821,6 +879,7 @@ export {
|
|
|
821
879
|
Colors,
|
|
822
880
|
EmbedBuilder,
|
|
823
881
|
toSnakeCase,
|
|
882
|
+
toCamelCase,
|
|
824
883
|
ButtonBuilder,
|
|
825
884
|
SelectMenuBuilder,
|
|
826
885
|
TextInputBuilder,
|
|
@@ -837,6 +896,8 @@ export {
|
|
|
837
896
|
buildVoiceState,
|
|
838
897
|
buildEntitlement,
|
|
839
898
|
buildInteraction,
|
|
899
|
+
buildInvite,
|
|
900
|
+
buildWebhook,
|
|
840
901
|
buildUser,
|
|
841
902
|
buildChannel,
|
|
842
903
|
buildGuild,
|