@buape/carbon 0.4.2 → 0.5.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.
Files changed (121) hide show
  1. package/README.md +15 -3
  2. package/dist/package.json +1 -1
  3. package/dist/src/abstracts/BaseChannel.d.ts +22 -21
  4. package/dist/src/abstracts/BaseChannel.d.ts.map +1 -1
  5. package/dist/src/abstracts/BaseChannel.js +37 -27
  6. package/dist/src/abstracts/BaseChannel.js.map +1 -1
  7. package/dist/src/abstracts/BaseComponentInteraction.d.ts +3 -2
  8. package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
  9. package/dist/src/abstracts/BaseComponentInteraction.js +3 -4
  10. package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
  11. package/dist/src/abstracts/BaseGuildChannel.d.ts +12 -10
  12. package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
  13. package/dist/src/abstracts/BaseGuildChannel.js +35 -22
  14. package/dist/src/abstracts/BaseGuildChannel.js.map +1 -1
  15. package/dist/src/abstracts/BaseGuildTextChannel.d.ts +13 -9
  16. package/dist/src/abstracts/BaseGuildTextChannel.d.ts.map +1 -1
  17. package/dist/src/abstracts/BaseGuildTextChannel.js +25 -9
  18. package/dist/src/abstracts/BaseGuildTextChannel.js.map +1 -1
  19. package/dist/src/abstracts/BaseInteraction.d.ts +7 -23
  20. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
  21. package/dist/src/abstracts/BaseInteraction.js +12 -12
  22. package/dist/src/abstracts/BaseInteraction.js.map +1 -1
  23. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +14 -13
  24. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
  25. package/dist/src/abstracts/GuildThreadOnlyChannel.js +31 -16
  26. package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -1
  27. package/dist/src/classes/Button.d.ts +0 -4
  28. package/dist/src/classes/Button.d.ts.map +1 -1
  29. package/dist/src/classes/Button.js +6 -0
  30. package/dist/src/classes/Button.js.map +1 -1
  31. package/dist/src/classes/Client.d.ts +35 -0
  32. package/dist/src/classes/Client.d.ts.map +1 -1
  33. package/dist/src/classes/Client.js +52 -0
  34. package/dist/src/classes/Client.js.map +1 -1
  35. package/dist/src/factories/channelFactory.d.ts +1 -1
  36. package/dist/src/factories/channelFactory.d.ts.map +1 -1
  37. package/dist/src/internals/AutocompleteInteraction.d.ts +2 -3
  38. package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -1
  39. package/dist/src/internals/AutocompleteInteraction.js +2 -8
  40. package/dist/src/internals/AutocompleteInteraction.js.map +1 -1
  41. package/dist/src/internals/CommandHandler.d.ts.map +1 -1
  42. package/dist/src/internals/CommandHandler.js +4 -2
  43. package/dist/src/internals/CommandHandler.js.map +1 -1
  44. package/dist/src/internals/CommandInteraction.d.ts +3 -4
  45. package/dist/src/internals/CommandInteraction.d.ts.map +1 -1
  46. package/dist/src/internals/CommandInteraction.js +6 -12
  47. package/dist/src/internals/CommandInteraction.js.map +1 -1
  48. package/dist/src/internals/ModalInteraction.d.ts +3 -2
  49. package/dist/src/internals/ModalInteraction.d.ts.map +1 -1
  50. package/dist/src/internals/ModalInteraction.js +3 -3
  51. package/dist/src/internals/ModalInteraction.js.map +1 -1
  52. package/dist/src/internals/OptionsHandler.d.ts +8 -12
  53. package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
  54. package/dist/src/internals/OptionsHandler.js +27 -9
  55. package/dist/src/internals/OptionsHandler.js.map +1 -1
  56. package/dist/src/structures/DmChannel.d.ts +7 -6
  57. package/dist/src/structures/DmChannel.d.ts.map +1 -1
  58. package/dist/src/structures/DmChannel.js +7 -6
  59. package/dist/src/structures/DmChannel.js.map +1 -1
  60. package/dist/src/structures/GroupDmChannel.d.ts +17 -19
  61. package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
  62. package/dist/src/structures/GroupDmChannel.js +48 -41
  63. package/dist/src/structures/GroupDmChannel.js.map +1 -1
  64. package/dist/src/structures/Guild.d.ts +29 -28
  65. package/dist/src/structures/Guild.d.ts.map +1 -1
  66. package/dist/src/structures/Guild.js +82 -57
  67. package/dist/src/structures/Guild.js.map +1 -1
  68. package/dist/src/structures/GuildAnnouncementChannel.d.ts +3 -4
  69. package/dist/src/structures/GuildAnnouncementChannel.d.ts.map +1 -1
  70. package/dist/src/structures/GuildAnnouncementChannel.js +1 -3
  71. package/dist/src/structures/GuildAnnouncementChannel.js.map +1 -1
  72. package/dist/src/structures/GuildCategoryChannel.d.ts +3 -3
  73. package/dist/src/structures/GuildCategoryChannel.d.ts.map +1 -1
  74. package/dist/src/structures/GuildCategoryChannel.js +0 -1
  75. package/dist/src/structures/GuildCategoryChannel.js.map +1 -1
  76. package/dist/src/structures/GuildForumChannel.d.ts +4 -3
  77. package/dist/src/structures/GuildForumChannel.d.ts.map +1 -1
  78. package/dist/src/structures/GuildForumChannel.js +4 -3
  79. package/dist/src/structures/GuildForumChannel.js.map +1 -1
  80. package/dist/src/structures/GuildMediaChannel.d.ts +3 -7
  81. package/dist/src/structures/GuildMediaChannel.d.ts.map +1 -1
  82. package/dist/src/structures/GuildMediaChannel.js +1 -6
  83. package/dist/src/structures/GuildMediaChannel.js.map +1 -1
  84. package/dist/src/structures/GuildMember.d.ts +28 -26
  85. package/dist/src/structures/GuildMember.d.ts.map +1 -1
  86. package/dist/src/structures/GuildMember.js +95 -57
  87. package/dist/src/structures/GuildMember.js.map +1 -1
  88. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts +12 -11
  89. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts.map +1 -1
  90. package/dist/src/structures/GuildStageOrVoiceChannel.js +22 -13
  91. package/dist/src/structures/GuildStageOrVoiceChannel.js.map +1 -1
  92. package/dist/src/structures/GuildTextChannel.d.ts +6 -6
  93. package/dist/src/structures/GuildTextChannel.d.ts.map +1 -1
  94. package/dist/src/structures/GuildTextChannel.js +9 -7
  95. package/dist/src/structures/GuildTextChannel.js.map +1 -1
  96. package/dist/src/structures/GuildThreadChannel.d.ts +14 -13
  97. package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -1
  98. package/dist/src/structures/GuildThreadChannel.js +59 -28
  99. package/dist/src/structures/GuildThreadChannel.js.map +1 -1
  100. package/dist/src/structures/Message.d.ts +50 -41
  101. package/dist/src/structures/Message.d.ts.map +1 -1
  102. package/dist/src/structures/Message.js +163 -93
  103. package/dist/src/structures/Message.js.map +1 -1
  104. package/dist/src/structures/Role.d.ts +27 -25
  105. package/dist/src/structures/Role.d.ts.map +1 -1
  106. package/dist/src/structures/Role.js +100 -61
  107. package/dist/src/structures/Role.js.map +1 -1
  108. package/dist/src/structures/User.d.ts +34 -32
  109. package/dist/src/structures/User.d.ts.map +1 -1
  110. package/dist/src/structures/User.js +97 -64
  111. package/dist/src/structures/User.js.map +1 -1
  112. package/dist/src/types.d.ts +37 -0
  113. package/dist/src/types.d.ts.map +1 -0
  114. package/dist/src/types.js +2 -0
  115. package/dist/src/types.js.map +1 -0
  116. package/dist/src/utils.d.ts +16 -0
  117. package/dist/src/utils.d.ts.map +1 -1
  118. package/dist/src/utils.js +9 -0
  119. package/dist/src/utils.js.map +1 -1
  120. package/dist/tsconfig.tsbuildinfo +1 -1
  121. package/package.json +1 -1
@@ -1,92 +1,139 @@
1
1
  import { Routes } from "discord-api-types/v10";
2
2
  import { Base } from "../abstracts/Base.js";
3
3
  export class Role extends Base {
4
+ constructor(client, rawDataOrId) {
5
+ super(client);
6
+ if (typeof rawDataOrId === "string") {
7
+ this.id = rawDataOrId;
8
+ }
9
+ else {
10
+ this.rawData = rawDataOrId;
11
+ this.id = rawDataOrId.id;
12
+ this.setData(rawDataOrId);
13
+ }
14
+ }
15
+ rawData = null;
16
+ setData(data) {
17
+ if (!data)
18
+ throw new Error("Cannot set data without having data... smh");
19
+ this.rawData = data;
20
+ }
21
+ setField(key, value) {
22
+ if (!this.rawData)
23
+ throw new Error("Cannot set field without having data... smh");
24
+ Reflect.set(this.rawData, key, value);
25
+ }
4
26
  /**
5
27
  * The ID of the role.
6
28
  */
7
29
  id;
30
+ /**
31
+ * Whether the role is a partial role (meaning it does not have all the data).
32
+ * If this is true, you should use {@link Role.fetch} to get the full data of the role.
33
+ */
34
+ get partial() {
35
+ return (this.rawData === null);
36
+ }
8
37
  /**
9
38
  * The name of the role.
10
39
  */
11
- name;
40
+ get name() {
41
+ if (!this.rawData)
42
+ return undefined;
43
+ return this.rawData.name;
44
+ }
12
45
  /**
13
46
  * The color of the role.
14
47
  */
15
- color;
48
+ get color() {
49
+ if (!this.rawData)
50
+ return undefined;
51
+ return this.rawData.color;
52
+ }
16
53
  /**
17
54
  * The icon hash of the role.
18
55
  * You can use {@link Role.iconUrl} to get the URL of the icon.
19
56
  */
20
- icon;
57
+ get icon() {
58
+ if (!this.rawData)
59
+ return undefined;
60
+ return this.rawData.icon ?? null;
61
+ }
62
+ /**
63
+ * Get the URL of the role's icon
64
+ */
65
+ get iconUrl() {
66
+ if (!this.rawData)
67
+ return undefined;
68
+ if (!this.icon)
69
+ return null;
70
+ return `https://cdn.discordapp.com/role-icons/${this.id}/${this.icon}.png`;
71
+ }
21
72
  /**
22
73
  * If this role is mentionable.
23
74
  */
24
- mentionable;
75
+ get mentionable() {
76
+ if (!this.rawData)
77
+ return undefined;
78
+ return this.rawData.mentionable;
79
+ }
25
80
  /**
26
81
  * If this role is hoisted.
27
82
  */
28
- hoisted;
83
+ get hoisted() {
84
+ if (!this.rawData)
85
+ return undefined;
86
+ return this.rawData.hoist;
87
+ }
29
88
  /**
30
89
  * The position of the role.
31
90
  */
32
- position;
91
+ get position() {
92
+ if (!this.rawData)
93
+ return undefined;
94
+ return this.rawData.position;
95
+ }
33
96
  /**
34
97
  * The permissions of the role.
35
98
  */
36
- permissions;
99
+ get permissions() {
100
+ if (!this.rawData)
101
+ return undefined;
102
+ return this.rawData.permissions;
103
+ }
37
104
  /**
38
105
  * If this role is managed by an integration.
39
106
  */
40
- managed;
107
+ get managed() {
108
+ if (!this.rawData)
109
+ return undefined;
110
+ return this.rawData.managed;
111
+ }
41
112
  /**
42
113
  * The unicode emoji for the role.
43
114
  */
44
- unicodeEmoji;
115
+ get unicodeEmoji() {
116
+ if (!this.rawData)
117
+ return undefined;
118
+ return this.rawData.unicode_emoji ?? null;
119
+ }
45
120
  /**
46
121
  * The flags of this role.
47
122
  * @see https://discord.com/developers/docs/topics/permissions#role-object-role-flags
48
123
  */
49
- flags;
124
+ get flags() {
125
+ if (!this.rawData)
126
+ return undefined;
127
+ return this.rawData.flags;
128
+ }
50
129
  /**
51
130
  * The tags of this role.
52
131
  * @see https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure
53
132
  */
54
- tags;
55
- /**
56
- * Whether the role is a partial role (meaning it does not have all the data).
57
- * If this is true, you should use {@link Role.fetch} to get the full data of the role.
58
- */
59
- partial;
60
- rawData = null;
61
- constructor(client, rawDataOrId) {
62
- super(client);
63
- if (typeof rawDataOrId === "string") {
64
- this.id = rawDataOrId;
65
- this.partial = true;
66
- }
67
- else {
68
- this.rawData = rawDataOrId;
69
- this.id = rawDataOrId.id;
70
- this.partial = false;
71
- this.setData(rawDataOrId);
72
- }
73
- }
74
- setData(data) {
75
- if (!data)
76
- throw new Error("Cannot set data without having data... smh");
77
- this.rawData = data;
78
- this.name = data.name;
79
- this.color = data.color;
80
- this.icon = data.icon;
81
- this.mentionable = data.mentionable;
82
- this.hoisted = data.hoist;
83
- this.position = data.position;
84
- this.permissions = data.permissions;
85
- this.managed = data.managed;
86
- this.unicodeEmoji = data.unicode_emoji;
87
- this.flags = data.flags;
88
- this.tags = data.tags;
89
- this.partial = false;
133
+ get tags() {
134
+ if (!this.rawData)
135
+ return undefined;
136
+ return this.rawData.tags;
90
137
  }
91
138
  /**
92
139
  * Fetch updated data for this role.
@@ -108,7 +155,7 @@ export class Role extends Base {
108
155
  name
109
156
  }
110
157
  });
111
- this.name = name;
158
+ this.setField("name", name);
112
159
  }
113
160
  /**
114
161
  * Set the color of the role
@@ -117,7 +164,7 @@ export class Role extends Base {
117
164
  await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
118
165
  body: { color }
119
166
  });
120
- this.color = color;
167
+ this.setField("color", color);
121
168
  }
122
169
  /**
123
170
  * Set the icon of the role
@@ -127,7 +174,7 @@ export class Role extends Base {
127
174
  await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
128
175
  body: { icon }
129
176
  });
130
- this.icon = icon;
177
+ this.setField("icon", icon);
131
178
  }
132
179
  /**
133
180
  * Set the mentionable status of the role
@@ -136,7 +183,7 @@ export class Role extends Base {
136
183
  await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
137
184
  body: { mentionable }
138
185
  });
139
- this.mentionable = mentionable;
186
+ this.setField("mentionable", mentionable);
140
187
  }
141
188
  /**
142
189
  * Set the hoisted status of the role
@@ -145,7 +192,7 @@ export class Role extends Base {
145
192
  await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
146
193
  body: { hoist: hoisted }
147
194
  });
148
- this.hoisted = hoisted;
195
+ this.setField("hoist", hoisted);
149
196
  }
150
197
  /**
151
198
  * Set the position of the role
@@ -154,7 +201,7 @@ export class Role extends Base {
154
201
  await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
155
202
  body: { position }
156
203
  });
157
- this.position = position;
204
+ this.setField("position", position);
158
205
  }
159
206
  /**
160
207
  * Set the permissions of the role
@@ -164,18 +211,10 @@ export class Role extends Base {
164
211
  await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
165
212
  body: { permissions }
166
213
  });
167
- this.permissions = permissions;
214
+ this.setField("permissions", permissions);
168
215
  }
169
216
  async delete(guildId) {
170
217
  await this.client.rest.delete(Routes.guildRole(guildId, this.id));
171
218
  }
172
- /**
173
- * Get the URL of the role's icon
174
- */
175
- get iconUrl() {
176
- return this.icon
177
- ? `https://cdn.discordapp.com/role-icons/${this.id}/${this.icon}.png`
178
- : null;
179
- }
180
219
  }
181
220
  //# sourceMappingURL=Role.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AAC,EAAE,CAAC,EAAE;YAChE,IAAI,EAAE,EAAE,QAAQ,EAAE;SAClB,CAAC,CAAA;QACF,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACpC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,OAAe,EAAE,WAAmB;QACxD,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE;YAChE,IAAI,EAAE,EAAE,WAAW,EAAE;SACrB,CAAC,CAAA;QACF,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;IAC1C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QAC3B,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IAClE,CAAC;CACD"}
@@ -1,59 +1,69 @@
1
- import { type APIDMChannel, type APIUser, type RESTPostAPIChannelMessageJSONBody, type UserFlags } from "discord-api-types/v10";
1
+ import { type APIDMChannel, type APIUser, type UserFlags } from "discord-api-types/v10";
2
2
  import { Base } from "../abstracts/Base.js";
3
3
  import type { Client } from "../classes/Client.js";
4
+ import type { MessagePayload } from "../types.js";
5
+ import type { IfPartial } from "../utils.js";
4
6
  import { Message } from "./Message.js";
5
- export declare class User extends Base {
7
+ export declare class User<IsPartial extends boolean = false> extends Base {
8
+ constructor(client: Client, rawDataOrId: IsPartial extends true ? string : APIUser);
9
+ private rawData;
10
+ private setData;
6
11
  /**
7
12
  * The ID of the user
8
13
  */
9
- id: string;
14
+ readonly id: string;
15
+ /**
16
+ * Whether the user is a partial user (meaning it does not have all the data).
17
+ * If this is true, you should use {@link User.fetch} to get the full data of the user.
18
+ */
19
+ get partial(): IsPartial;
10
20
  /**
11
21
  * The username of the user.
12
22
  */
13
- username?: string;
23
+ get username(): IfPartial<IsPartial, string>;
14
24
  /**
15
25
  * The global name of the user.
16
26
  */
17
- globalName?: string | null;
27
+ get globalName(): IfPartial<IsPartial, string | null>;
18
28
  /**
19
29
  * The discriminator of the user.
20
30
  */
21
- discriminator?: string;
22
- /**
23
- * The avatar hash of the user.
24
- * You can use {@link User.avatarUrl} to get the URL of the avatar.
25
- */
26
- avatar?: string | null;
31
+ get discriminator(): IfPartial<IsPartial, string>;
27
32
  /**
28
33
  * Is this user a bot?
29
34
  */
30
- bot?: boolean;
35
+ get bot(): IfPartial<IsPartial, boolean>;
31
36
  /**
32
37
  * Is this user a system user?
33
38
  */
34
- system?: boolean;
39
+ get system(): IfPartial<IsPartial, boolean>;
35
40
  /**
36
41
  * The public flags of the user. (Bitfield)
37
42
  * @see https://discord.com/developers/docs/resources/user#user-object-user-flags
38
43
  */
39
- flags?: UserFlags;
44
+ get flags(): IfPartial<IsPartial, UserFlags | undefined>;
45
+ /**
46
+ * The avatar hash of the user.
47
+ * You can use {@link User.avatarUrl} to get the URL of the avatar.
48
+ */
49
+ get avatar(): IfPartial<IsPartial, string | null>;
50
+ /**
51
+ * Get the URL of the user's avatar
52
+ */
53
+ get avatarUrl(): IfPartial<IsPartial, string | null>;
40
54
  /**
41
55
  * The banner hash of the user.
42
56
  * You can use {@link User.bannerUrl} to get the URL of the banner.
43
57
  */
44
- banner?: string | null;
58
+ get banner(): IfPartial<IsPartial, string | null>;
45
59
  /**
46
- * The accent color of the user.
60
+ * Get the URL of the user's banner
47
61
  */
48
- accentColor?: number | null;
62
+ get bannerUrl(): IfPartial<IsPartial, string | null>;
49
63
  /**
50
- * Whether the user is a partial user (meaning it does not have all the data).
51
- * If this is true, you should use {@link User.fetch} to get the full data of the user.
64
+ * The accent color of the user.
52
65
  */
53
- partial: boolean;
54
- private rawData;
55
- constructor(client: Client, rawDataOrId: APIUser | string);
56
- private setData;
66
+ get accentColor(): IfPartial<IsPartial, number | null>;
57
67
  /**
58
68
  * Fetch updated data for this user.
59
69
  * If the user is partial, this will fetch all the data for the user and populate the fields.
@@ -67,14 +77,6 @@ export declare class User extends Base {
67
77
  /**
68
78
  * Send a message to this user.
69
79
  */
70
- send(data: RESTPostAPIChannelMessageJSONBody): Promise<Message>;
71
- /**
72
- * Get the URL of the user's avatar
73
- */
74
- get avatarUrl(): string | null;
75
- /**
76
- * Get the URL of the user's banner
77
- */
78
- get bannerUrl(): string | null;
80
+ send(data: MessagePayload): Promise<Message<false>>;
79
81
  }
80
82
  //# sourceMappingURL=User.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../src/structures/User.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAEjB,KAAK,OAAO,EACZ,KAAK,iCAAiC,EAEtC,KAAK,SAAS,EACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,qBAAa,IAAK,SAAQ,IAAI;IAC7B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB;;OAEG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IACH,IAAI,QAAQ,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,CAG3C;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGpD;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,CAGhD;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAGvC;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAG1C;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC,CAGvD;IAED;;;OAGG;IAEH,IAAI,MAAM,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGhD;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAInD;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGhD;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAInD;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGrD;IAED;;;;OAIG;IACG,KAAK;IASX;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM;IAS7B;;OAEG;IACG,IAAI,CAAC,IAAI,EAAE,cAAc;CAU/B"}
@@ -1,83 +1,134 @@
1
1
  import { Routes } from "discord-api-types/v10";
2
2
  import { Base } from "../abstracts/Base.js";
3
+ import { serializePayload } from "../utils.js";
3
4
  import { Message } from "./Message.js";
4
5
  export class User extends Base {
6
+ constructor(client, rawDataOrId) {
7
+ super(client);
8
+ if (typeof rawDataOrId === "string") {
9
+ this.id = rawDataOrId;
10
+ }
11
+ else {
12
+ this.rawData = rawDataOrId;
13
+ this.id = rawDataOrId.id;
14
+ this.setData(rawDataOrId);
15
+ }
16
+ }
17
+ rawData = null;
18
+ setData(data) {
19
+ if (!data)
20
+ throw new Error("Cannot set data without having data... smh");
21
+ this.rawData = data;
22
+ }
23
+ // private setField(key: keyof APIUser, value: unknown) {
24
+ // if (!this.rawData) throw new Error("Cannot set field without having data... smh")
25
+ // Reflect.set(this.rawData, key, value)
26
+ // }
5
27
  /**
6
28
  * The ID of the user
7
29
  */
8
30
  id;
31
+ /**
32
+ * Whether the user is a partial user (meaning it does not have all the data).
33
+ * If this is true, you should use {@link User.fetch} to get the full data of the user.
34
+ */
35
+ get partial() {
36
+ return (this.rawData === null);
37
+ }
9
38
  /**
10
39
  * The username of the user.
11
40
  */
12
- username;
41
+ get username() {
42
+ if (!this.rawData)
43
+ return undefined;
44
+ return this.rawData.username;
45
+ }
13
46
  /**
14
47
  * The global name of the user.
15
48
  */
16
- globalName;
49
+ get globalName() {
50
+ if (!this.rawData)
51
+ return undefined;
52
+ return this.rawData.global_name;
53
+ }
17
54
  /**
18
55
  * The discriminator of the user.
19
56
  */
20
- discriminator;
21
- /**
22
- * The avatar hash of the user.
23
- * You can use {@link User.avatarUrl} to get the URL of the avatar.
24
- */
25
- avatar;
57
+ get discriminator() {
58
+ if (!this.rawData)
59
+ return undefined;
60
+ return this.rawData.discriminator;
61
+ }
26
62
  /**
27
63
  * Is this user a bot?
28
64
  */
29
- bot;
65
+ get bot() {
66
+ if (!this.rawData)
67
+ return undefined;
68
+ return this.rawData.bot ?? false;
69
+ }
30
70
  /**
31
71
  * Is this user a system user?
32
72
  */
33
- system;
73
+ get system() {
74
+ if (!this.rawData)
75
+ return undefined;
76
+ return this.rawData.system ?? false;
77
+ }
34
78
  /**
35
79
  * The public flags of the user. (Bitfield)
36
80
  * @see https://discord.com/developers/docs/resources/user#user-object-user-flags
37
81
  */
38
- flags;
82
+ get flags() {
83
+ if (!this.rawData)
84
+ return undefined;
85
+ return this.rawData.public_flags;
86
+ }
87
+ /**
88
+ * The avatar hash of the user.
89
+ * You can use {@link User.avatarUrl} to get the URL of the avatar.
90
+ */
91
+ get avatar() {
92
+ if (!this.rawData)
93
+ return undefined;
94
+ return this.rawData.avatar;
95
+ }
96
+ /**
97
+ * Get the URL of the user's avatar
98
+ */
99
+ get avatarUrl() {
100
+ if (!this.rawData)
101
+ return undefined;
102
+ if (!this.avatar)
103
+ return null;
104
+ return `https://cdn.discordapp.com/avatars/${this.id}/${this.avatar}.png`;
105
+ }
39
106
  /**
40
107
  * The banner hash of the user.
41
108
  * You can use {@link User.bannerUrl} to get the URL of the banner.
42
109
  */
43
- banner;
110
+ get banner() {
111
+ if (!this.rawData)
112
+ return undefined;
113
+ return this.rawData.banner ?? null;
114
+ }
44
115
  /**
45
- * The accent color of the user.
116
+ * Get the URL of the user's banner
46
117
  */
47
- accentColor;
118
+ get bannerUrl() {
119
+ if (!this.rawData)
120
+ return undefined;
121
+ if (!this.banner)
122
+ return null;
123
+ return `https://cdn.discordapp.com/banners/${this.id}/${this.banner}.png`;
124
+ }
48
125
  /**
49
- * Whether the user is a partial user (meaning it does not have all the data).
50
- * If this is true, you should use {@link User.fetch} to get the full data of the user.
126
+ * The accent color of the user.
51
127
  */
52
- partial;
53
- rawData = null;
54
- constructor(client, rawDataOrId) {
55
- super(client);
56
- if (typeof rawDataOrId === "string") {
57
- this.id = rawDataOrId;
58
- this.partial = true;
59
- }
60
- else {
61
- this.rawData = rawDataOrId;
62
- this.id = rawDataOrId.id;
63
- this.partial = false;
64
- this.setData(rawDataOrId);
65
- }
66
- }
67
- setData(data) {
68
- if (!data)
69
- throw new Error("Cannot set data without having data... smh");
70
- this.rawData = data;
71
- this.username = data.username;
72
- this.globalName = data.global_name;
73
- this.discriminator = data.discriminator;
74
- this.avatar = data.avatar;
75
- this.bot = data.bot;
76
- this.system = data.system;
77
- this.flags = data.public_flags;
78
- this.banner = data.banner;
79
- this.accentColor = data.accent_color;
80
- this.partial = false;
128
+ get accentColor() {
129
+ if (!this.rawData)
130
+ return undefined;
131
+ return this.rawData.accent_color ?? null;
81
132
  }
82
133
  /**
83
134
  * Fetch updated data for this user.
@@ -107,27 +158,9 @@ export class User extends Base {
107
158
  async send(data) {
108
159
  const dmChannel = await this.createDm(this.id);
109
160
  const message = (await this.client.rest.post(Routes.channelMessages(dmChannel.id), {
110
- body: {
111
- ...data
112
- }
161
+ body: serializePayload(data)
113
162
  }));
114
163
  return new Message(this.client, message);
115
164
  }
116
- /**
117
- * Get the URL of the user's avatar
118
- */
119
- get avatarUrl() {
120
- return this.avatar
121
- ? `https://cdn.discordapp.com/avatars/${this.id}/${this.avatar}.png`
122
- : null;
123
- }
124
- /**
125
- * Get the URL of the user's banner
126
- */
127
- get bannerUrl() {
128
- return this.banner
129
- ? `https://cdn.discordapp.com/banners/${this.id}/${this.banner}.png`
130
- : null;
131
- }
132
165
  }
133
166
  //# sourceMappingURL=User.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/structures/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,EAEN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,OAAO,IAAK,SAAQ,IAAI;IAC7B;;OAEG;IACH,EAAE,CAAQ;IACV;;OAEG;IACH,QAAQ,CAAS;IACjB;;OAEG;IACH,UAAU,CAAgB;IAC1B;;OAEG;IACH,aAAa,CAAS;IACtB;;;OAGG;IACH,MAAM,CAAgB;IACtB;;OAEG;IACH,GAAG,CAAU;IACb;;OAEG;IACH,MAAM,CAAU;IAChB;;;OAGG;IACH,KAAK,CAAY;IACjB;;;OAGG;IACH,MAAM,CAAgB;IACtB;;OAEG;I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KAAK,CAAC,IAAI,CAAC,IAAoB;QAC9B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC9C,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAC3C,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC,EACpC;YACC,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;SAC5B,CACD,CAAe,CAAA;QAChB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;CACD"}
@@ -0,0 +1,37 @@
1
+ import type { Embed } from "./classes/Embed.js";
2
+ import type { Row } from "./classes/Row.js";
3
+ /**
4
+ * The data that is sent to Discord when sending a message.
5
+ * If you pass just a string, it will be treated as the content of the message.
6
+ */
7
+ export type MessagePayload = {
8
+ /**
9
+ * The content of the message
10
+ */
11
+ content?: string;
12
+ /**
13
+ * The embeds of the message
14
+ */
15
+ embeds?: Embed[];
16
+ /**
17
+ * The components to send in the message, listed in rows
18
+ */
19
+ components?: Row[];
20
+ /**
21
+ * The settings for which mentions are allowed in the message
22
+ */
23
+ allowedMentions?: {
24
+ parse?: ["roles", "users", "everyone"];
25
+ roles?: string[];
26
+ users?: string[];
27
+ };
28
+ /**
29
+ * The flags for the message
30
+ */
31
+ flags?: number;
32
+ /**
33
+ * Whether the message should be TTS
34
+ */
35
+ tts?: boolean;
36
+ } | string;
37
+ //# sourceMappingURL=types.d.ts.map