@impulsedev/chameleon 3.5.0 → 3.7.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.
@@ -29,7 +29,7 @@ import {
29
29
  resolveRole,
30
30
  resolveUser,
31
31
  serializeComponent
32
- } from "./chunk-G4SUOXGV.js";
32
+ } from "./chunk-CGH3AKKX.js";
33
33
  export {
34
34
  ActionRowBuilder,
35
35
  ButtonBuilder,
@@ -1,3 +1,85 @@
1
+ // src/types/message/index.ts
2
+ var MessageType = {
3
+ DEFAULT: 0,
4
+ RECIPIENT_ADD: 1,
5
+ RECIPIENT_REMOVE: 2,
6
+ CALL: 3,
7
+ CHANNEL_NAME_CHANGE: 4,
8
+ CHANNEL_ICON_CHANGE: 5,
9
+ CHANNEL_PINNED_MESSAGE: 6,
10
+ USER_JOIN: 7,
11
+ GUILD_BOOST: 8,
12
+ GUILD_BOOST_TIER_1: 9,
13
+ GUILD_BOOST_TIER_2: 10,
14
+ GUILD_BOOST_TIER_3: 11,
15
+ CHANNEL_FOLLOW_ADD: 12,
16
+ GUILD_DISCOVERY_DISQUALIFIED: 14,
17
+ GUILD_DISCOVERY_REQUALIFIED: 15,
18
+ GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING: 16,
19
+ GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING: 17,
20
+ THREAD_CREATED: 18,
21
+ REPLY: 19,
22
+ CHAT_INPUT_COMMAND: 20,
23
+ THREAD_STARTER_MESSAGE: 21,
24
+ GUILD_INVITE_REMINDER: 22,
25
+ CONTEXT_MENU_COMMAND: 23,
26
+ AUTO_MODERATION_ACTION: 24,
27
+ ROLE_SUBSCRIPTION_PURCHASE: 25,
28
+ INTERACTION_PREMIUM_UPSELL: 26,
29
+ STAGE_START: 27,
30
+ STAGE_END: 28,
31
+ STAGE_SPEAKER: 29,
32
+ STAGE_TOPIC: 31,
33
+ GUILD_APPLICATION_PREMIUM_SUBSCRIPTION: 32,
34
+ GUILD_INCIDENT_ALERT_MODE_ENABLED: 36,
35
+ GUILD_INCIDENT_ALERT_MODE_DISABLED: 37,
36
+ GUILD_INCIDENT_REPORT_RAID: 38,
37
+ GUILD_INCIDENT_REPORT_FALSE_ALARM: 39,
38
+ PURCHASE_NOTIFICATION: 44,
39
+ POLL_RESULT: 46
40
+ };
41
+ var MessageActivityType = {
42
+ JOIN: 1,
43
+ SPECTATE: 2,
44
+ LISTEN: 3,
45
+ JOIN_REQUEST: 5
46
+ };
47
+ var MessageFlag = {
48
+ CROSSPOSTED: 1 << 0,
49
+ IS_CROSSPOST: 1 << 1,
50
+ SUPPRESS_EMBEDS: 1 << 2,
51
+ SOURCE_MESSAGE_DELETED: 1 << 3,
52
+ URGENT: 1 << 4,
53
+ HAS_THREAD: 1 << 5,
54
+ EPHEMERAL: 1 << 6,
55
+ LOADING: 1 << 7,
56
+ FAILED_TO_MENTION_SOME_ROLES_IN_THREAD: 1 << 8,
57
+ SUPPRESS_NOTIFICATIONS: 1 << 12,
58
+ IS_VOICE_MESSAGE: 1 << 13,
59
+ HAS_SNAPSHOT: 1 << 14,
60
+ IS_COMPONENTS_V2: 1 << 15
61
+ };
62
+ var MessageReferenceType = {
63
+ DEFAULT: 0,
64
+ FORWARD: 1
65
+ };
66
+ var EmbedType = {
67
+ RICH: "rich",
68
+ IMAGE: "image",
69
+ VIDEO: "video",
70
+ GIFV: "gifv",
71
+ ARTICLE: "article",
72
+ LINK: "link",
73
+ POLL_RESULT: "poll_result"
74
+ };
75
+ var AttachmentFlag = {
76
+ IS_CLIP: 1 << 0,
77
+ IS_THUMBNAIL: 1 << 1,
78
+ IS_REMIX: 1 << 2,
79
+ IS_SPOILER: 1 << 3,
80
+ IS_ANIMATED: 1 << 5
81
+ };
82
+
1
83
  // src/builders/embed.ts
2
84
  var Colors = {
3
85
  Blue: 2003199,
@@ -147,7 +229,19 @@ var ComponentType = {
147
229
  USER_SELECT: 5,
148
230
  ROLE_SELECT: 6,
149
231
  MENTIONABLE_SELECT: 7,
150
- CHANNEL_SELECT: 8
232
+ CHANNEL_SELECT: 8,
233
+ SECTION: 9,
234
+ TEXT_DISPLAY: 10,
235
+ THUMBNAIL: 11,
236
+ MEDIA_GALLERY: 12,
237
+ FILE: 13,
238
+ SEPARATOR: 14,
239
+ CONTAINER: 17,
240
+ LABEL: 18,
241
+ FILE_UPLOAD: 19,
242
+ RADIO_GROUP: 21,
243
+ CHECKBOX_GROUP: 22,
244
+ CHECKBOX: 23
151
245
  };
152
246
  var ButtonStyle = {
153
247
  PRIMARY: 1,
@@ -838,6 +932,40 @@ function buildMessage(raw, cache, oldMessage) {
838
932
  const msgId = raw.id ?? oldMessage?.id;
839
933
  const channelId = raw.channel_id ?? oldMessage?.channelId;
840
934
  const guildId = raw.guild_id ? raw.guild_id : oldMessage?.guildId;
935
+ const stickerItems = raw.sticker_items ?? oldMessage?.stickerItems;
936
+ const stickers = raw.stickers ?? oldMessage?.stickers;
937
+ const poll = raw.poll ?? oldMessage?.poll;
938
+ const components = raw.components ?? oldMessage?.components;
939
+ const webhookId = raw.webhook_id ?? oldMessage?.webhookId;
940
+ const flags = raw.flags ?? oldMessage?.flags;
941
+ const messageReference = raw.message_reference ?? oldMessage?.messageReference;
942
+ const referencedMessage = raw.referenced_message ?? oldMessage?.referencedMessage;
943
+ const interactionMetadata = raw.interaction_metadata ?? oldMessage?.interactionMetadata;
944
+ const interaction = raw.interaction ?? oldMessage?.interaction;
945
+ const thread = raw.thread ?? oldMessage?.thread;
946
+ const call = raw.call ?? oldMessage?.call;
947
+ const messageSnapshots = raw.message_snapshots ?? oldMessage?.messageSnapshots;
948
+ const type = raw.type ?? oldMessage?.type ?? 0;
949
+ const attachments = raw.attachments ?? oldMessage?.attachments ?? [];
950
+ const embeds = raw.embeds ?? oldMessage?.embeds ?? [];
951
+ const mentionEveryone = raw.mention_everyone ?? oldMessage?.mentionEveryone ?? false;
952
+ const tts = raw.tts ?? oldMessage?.tts ?? false;
953
+ const pinned = raw.pinned ?? oldMessage?.pinned ?? false;
954
+ const editedTimestamp = raw.edited_timestamp ? Date.parse(raw.edited_timestamp) : oldMessage?.editedTimestamp ?? null;
955
+ const hasReply = Boolean(messageReference || referencedMessage || type === MessageType.REPLY);
956
+ const hasForward = Boolean(
957
+ (messageReference?.type ?? 0) === MessageReferenceType.FORWARD || (raw.message_snapshots ?? oldMessage?.messageSnapshots ?? []).length > 0 || (flags ?? 0) & MessageFlag.HAS_SNAPSHOT
958
+ );
959
+ const hasVoiceMessage = Boolean((flags ?? 0) & MessageFlag.IS_VOICE_MESSAGE);
960
+ const hasStickers = (stickerItems ?? stickers ?? []).length > 0;
961
+ const systemPresence = {
962
+ any: type !== MessageType.DEFAULT && type !== MessageType.REPLY,
963
+ booster: type === MessageType.GUILD_BOOST || type === MessageType.GUILD_BOOST_TIER_1 || type === MessageType.GUILD_BOOST_TIER_2 || type === MessageType.GUILD_BOOST_TIER_3,
964
+ call: type === MessageType.CALL,
965
+ pinned: type === MessageType.CHANNEL_PINNED_MESSAGE,
966
+ thread: type === MessageType.THREAD_STARTER_MESSAGE,
967
+ welcome: type === MessageType.USER_JOIN
968
+ };
841
969
  const msg = {
842
970
  id: msgId,
843
971
  channelId,
@@ -846,15 +974,47 @@ function buildMessage(raw, cache, oldMessage) {
846
974
  url: `https://discord.com/channels/${guildId ?? "@me"}/${channelId}/${msgId}`,
847
975
  content: raw.content ?? oldMessage?.content ?? "",
848
976
  timestamp: raw.timestamp ? Date.parse(raw.timestamp) : oldMessage?.timestamp ?? Date.now(),
849
- editedTimestamp: raw.edited_timestamp ? Date.parse(raw.edited_timestamp) : oldMessage?.editedTimestamp ?? null,
850
- tts: raw.tts ?? oldMessage?.tts ?? false,
851
- mentionEveryone: raw.mention_everyone ?? oldMessage?.mentionEveryone ?? false,
977
+ editedTimestamp,
978
+ tts,
979
+ mentionEveryone,
852
980
  mentions: raw.mentions ? raw.mentions.map((m) => buildUser(m)) : oldMessage?.mentions ?? [],
853
981
  mentionRoles: raw.mention_roles ?? oldMessage?.mentionRoles ?? [],
854
- attachments: raw.attachments ?? oldMessage?.attachments ?? [],
855
- embeds: raw.embeds ?? oldMessage?.embeds ?? [],
856
- pinned: raw.pinned ?? oldMessage?.pinned ?? false,
857
- type: raw.type ?? oldMessage?.type ?? 0
982
+ attachments,
983
+ embeds,
984
+ pinned,
985
+ type,
986
+ ...webhookId ? { webhookId } : {},
987
+ ...flags !== void 0 ? { flags } : {},
988
+ ...messageReference ? { messageReference } : {},
989
+ ...messageSnapshots ? { messageSnapshots } : {},
990
+ ...referencedMessage !== void 0 ? { referencedMessage } : {},
991
+ ...interactionMetadata ? { interactionMetadata } : {},
992
+ ...interaction ? { interaction } : {},
993
+ ...thread ? { thread } : {},
994
+ ...components ? { components } : {},
995
+ ...stickerItems ? { stickerItems } : {},
996
+ ...stickers ? { stickers } : {},
997
+ ...poll ? { poll } : {},
998
+ ...call ? { call } : {},
999
+ has: {
1000
+ attachments: attachments.length > 0 && !hasVoiceMessage,
1001
+ components: (components ?? []).length > 0,
1002
+ edited: editedTimestamp !== null,
1003
+ embeds: embeds.length > 0,
1004
+ forwarded: hasForward,
1005
+ interaction: Boolean(interactionMetadata || interaction),
1006
+ mentionHere: mentionEveryone && (raw.content ?? oldMessage?.content ?? "").includes("@here"),
1007
+ mentionEveryone,
1008
+ pinned,
1009
+ poll: Boolean(poll),
1010
+ reply: hasReply,
1011
+ stickers: hasStickers,
1012
+ system: systemPresence,
1013
+ thread: Boolean(thread),
1014
+ tts,
1015
+ voiceMessage: hasVoiceMessage,
1016
+ webhook: Boolean(webhookId)
1017
+ }
858
1018
  };
859
1019
  return msg;
860
1020
  }
@@ -874,6 +1034,12 @@ function resolveRole(roleId, client, guildId) {
874
1034
  }
875
1035
 
876
1036
  export {
1037
+ MessageType,
1038
+ MessageActivityType,
1039
+ MessageFlag,
1040
+ MessageReferenceType,
1041
+ EmbedType,
1042
+ AttachmentFlag,
877
1043
  ComponentType,
878
1044
  ButtonStyle,
879
1045
  Colors,