lunibee 0.2.2 → 0.2.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.
Files changed (43) hide show
  1. package/dist/builders/attachment.d.ts +2 -2
  2. package/dist/builders/commands.d.ts +39 -36
  3. package/dist/builders/components.d.ts +44 -44
  4. package/dist/builders/embed.d.ts +2 -2
  5. package/dist/builders/index.d.ts +1 -1
  6. package/dist/builders/index.js +12 -3
  7. package/dist/builders/index.js.map +7 -7
  8. package/dist/core/index.d.ts +1 -0
  9. package/dist/core/index.js +196 -96
  10. package/dist/core/index.js.map +21 -21
  11. package/dist/core/permissions.d.ts +2 -2
  12. package/dist/index.js +254 -105
  13. package/dist/index.js.map +29 -28
  14. package/dist/managers/base.d.ts +4 -0
  15. package/dist/managers/emoji.d.ts +7 -1
  16. package/dist/managers/guild-resources.d.ts +11 -3
  17. package/dist/managers/guild.d.ts +13 -5
  18. package/dist/managers/index.d.ts +26 -13
  19. package/dist/managers/index.js +139 -68
  20. package/dist/managers/index.js.map +16 -16
  21. package/dist/managers/member.d.ts +5 -3
  22. package/dist/managers/role.d.ts +13 -1
  23. package/dist/rest/error-codes.d.ts +48 -0
  24. package/dist/rest/errors.d.ts +1 -0
  25. package/dist/rest/index.d.ts +1 -0
  26. package/dist/rest/index.js +53 -3
  27. package/dist/rest/index.js.map +7 -6
  28. package/dist/rest/routes.d.ts +4 -2
  29. package/dist/sharding/index.js +6 -6
  30. package/dist/sharding/index.js.map +4 -4
  31. package/dist/structures/base.d.ts +18 -9
  32. package/dist/structures/index.d.ts +6 -6
  33. package/dist/structures/index.js +74 -42
  34. package/dist/structures/index.js.map +11 -11
  35. package/dist/structures/interactions.d.ts +2 -2
  36. package/dist/structures/resources.d.ts +2 -2
  37. package/dist/types/index.d.ts +43 -18
  38. package/dist/types/index.js.map +2 -2
  39. package/dist/voice/index.js +4 -3
  40. package/dist/voice/index.js.map +3 -3
  41. package/dist/ws/index.js +1 -1
  42. package/dist/ws/index.js.map +3 -3
  43. package/package.json +15 -15
@@ -61,8 +61,8 @@ export declare class Message extends BaseStructure {
61
61
  update(options: Record<string, unknown> & {
62
62
  content?: string;
63
63
  }): Promise<Message>;
64
- /** Deletes this message. @returns A promise fulfilled when Discord confirms deletion. @throws {Error} If the message is not attached to a client. */
65
- delete(): Promise<void>;
64
+ /** Deletes this message. @param reason Audit-log reason (shown when deleting someone else's message). @returns A promise fulfilled when Discord confirms deletion. @throws {Error} If the message is not attached to a client. */
65
+ delete(reason?: string): Promise<void>;
66
66
  /** Replies to this message. @param options Message content or payload. @returns The created reply message. @throws {Error} If the message is not attached to a client. */
67
67
  reply(options: string | (Record<string, unknown> & {
68
68
  content?: string;
@@ -90,10 +90,10 @@ export declare class Message extends BaseStructure {
90
90
  removeReaction(emoji: string, userId?: string): Promise<void>;
91
91
  /** Removes all reactions from this message. @returns A promise fulfilled when reactions are removed. @throws {Error} If reaction operations are unavailable. */
92
92
  removeAllReactions(): Promise<void>;
93
- /** Pins this message. @returns A promise fulfilled when the message is pinned. @throws {Error} If pin operations are unavailable. */
94
- pin(): Promise<void>;
95
- /** Unpins this message. @returns A promise fulfilled when the message is unpinned. @throws {Error} If pin operations are unavailable. */
96
- unpin(): Promise<void>;
93
+ /** Pins this message. @param reason Audit-log reason. @returns A promise fulfilled when the message is pinned. @throws {Error} If pin operations are unavailable. */
94
+ pin(reason?: string): Promise<void>;
95
+ /** Unpins this message. @param reason Audit-log reason. @returns A promise fulfilled when the message is unpinned. @throws {Error} If pin operations are unavailable. */
96
+ unpin(reason?: string): Promise<void>;
97
97
  /** Whether this message was sent ephemerally (only visible to the recipient). */
98
98
  get isEphemeral(): boolean;
99
99
  /** Whether this message is currently pinned in its channel. */
@@ -88,13 +88,13 @@ class Channel extends BaseStructure {
88
88
  this.permissionOverwrites = (data.permission_overwrites ?? []).map((overwrite) => ({ ...overwrite }));
89
89
  this.#context = context;
90
90
  }
91
- sendMessage(options) {
91
+ send(options) {
92
92
  if (!this.#context)
93
93
  throw new Error("This channel is not attached to a client.");
94
94
  return this.#context.sendMessage(this.id, options);
95
95
  }
96
- send(options) {
97
- return this.sendMessage(options);
96
+ sendMessage(options) {
97
+ return this.send(options);
98
98
  }
99
99
  edit(options) {
100
100
  if (!this.#context?.editChannel)
@@ -117,10 +117,10 @@ class Channel extends BaseStructure {
117
117
  editParent(parentId) {
118
118
  return this.edit({ parent_id: parentId });
119
119
  }
120
- delete() {
120
+ delete(reason) {
121
121
  if (!this.#context?.deleteChannel)
122
122
  throw new Error("This channel is not attached to a client.");
123
- return this.#context.deleteChannel(this.id);
123
+ return this.#context.deleteChannel(this.id, reason);
124
124
  }
125
125
  update(options) {
126
126
  return this.edit(options);
@@ -167,6 +167,15 @@ class Guild extends BaseStructure {
167
167
  mfaLevel;
168
168
  explicitContentFilter;
169
169
  defaultMessageNotifications;
170
+ afkChannelId;
171
+ afkTimeout;
172
+ widgetEnabled;
173
+ widgetChannelId;
174
+ applicationId;
175
+ publicUpdatesChannelId;
176
+ safetyAlertsChannelId;
177
+ maxPresences;
178
+ maxVideoChannelUsers;
170
179
  constructor(data) {
171
180
  super(data.id);
172
181
  if (!data.name)
@@ -188,14 +197,22 @@ class Guild extends BaseStructure {
188
197
  this.vanityUrlCode = data.vanity_url_code ?? null;
189
198
  this.nsfwLevel = data.nsfw_level ?? 0;
190
199
  this.discoverySplash = data.discovery_splash ?? null;
191
- const d = data;
192
- this.rulesChannelId = d.rules_channel_id ?? null;
193
- this.systemChannelId = d.system_channel_id ?? null;
194
- this.systemChannelFlags = d.system_channel_flags ?? 0;
195
- this.maxMembers = d.max_members ?? 0;
196
- this.mfaLevel = d.mfa_level ?? 0;
197
- this.explicitContentFilter = d.explicit_content_filter ?? 0;
198
- this.defaultMessageNotifications = d.default_message_notifications ?? 0;
200
+ this.rulesChannelId = data.rules_channel_id ?? null;
201
+ this.systemChannelId = data.system_channel_id ?? null;
202
+ this.systemChannelFlags = data.system_channel_flags ?? 0;
203
+ this.maxMembers = data.max_members ?? 0;
204
+ this.mfaLevel = data.mfa_level ?? 0;
205
+ this.explicitContentFilter = data.explicit_content_filter ?? 0;
206
+ this.defaultMessageNotifications = data.default_message_notifications ?? 0;
207
+ this.afkChannelId = data.afk_channel_id ?? null;
208
+ this.afkTimeout = data.afk_timeout;
209
+ this.widgetEnabled = data.widget_enabled ?? false;
210
+ this.widgetChannelId = data.widget_channel_id ?? null;
211
+ this.applicationId = data.application_id ?? null;
212
+ this.publicUpdatesChannelId = data.public_updates_channel_id ?? null;
213
+ this.safetyAlertsChannelId = data.safety_alerts_channel_id ?? null;
214
+ this.maxPresences = data.max_presences ?? null;
215
+ this.maxVideoChannelUsers = data.max_video_channel_users;
199
216
  }
200
217
  iconURL(options = {}) {
201
218
  if (!this.icon)
@@ -752,19 +769,22 @@ var InteractionResponseType = InteractionResponseEnum;
752
769
  // packages/rest/package.json
753
770
  var package_default = {
754
771
  name: "@lunibee/rest",
755
- version: "0.2.2",
772
+ version: "0.2.3",
756
773
  type: "module",
757
774
  module: "./src/index.ts",
758
775
  types: "./src/index.ts",
759
776
  exports: {
760
777
  ".": "./src/index.ts"
778
+ },
779
+ dependencies: {
780
+ "@lunibee/types": "workspace:*"
761
781
  }
762
782
  };
763
783
 
764
784
  // packages/rest/src/index.ts
765
785
  var LIBRARY_VERSION = package_default.version;
766
786
  var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
767
- var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${package_default.version})`;
787
+ var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${LIBRARY_VERSION})`;
768
788
  var REQUEST_DATA_KEYS = new Set([
769
789
  "body",
770
790
  "files",
@@ -1115,7 +1135,7 @@ class WelcomeScreenChannel {
1115
1135
  }
1116
1136
  }
1117
1137
 
1118
- class GuildWelcomeScreen2 {
1138
+ class GuildWelcomeScreen {
1119
1139
  description;
1120
1140
  channels;
1121
1141
  constructor(data) {
@@ -1158,7 +1178,7 @@ class OnboardingPrompt extends BaseStructure {
1158
1178
  }
1159
1179
  }
1160
1180
 
1161
- class GuildOnboarding2 extends BaseStructure {
1181
+ class GuildOnboarding extends BaseStructure {
1162
1182
  prompts;
1163
1183
  defaultChannelIds;
1164
1184
  enabled;
@@ -1290,6 +1310,13 @@ var OptionType = {
1290
1310
  class CommandOptions {
1291
1311
  #options;
1292
1312
  #resolved;
1313
+ #lookup(kind, id) {
1314
+ const group = this.#resolved?.[kind];
1315
+ if (typeof group !== "object" || group === null)
1316
+ return;
1317
+ const entry = group[id];
1318
+ return typeof entry === "object" && entry !== null ? entry : undefined;
1319
+ }
1293
1320
  constructor(options, resolved = {}) {
1294
1321
  let currentOptions = options;
1295
1322
  let group = null;
@@ -1378,7 +1405,7 @@ class CommandOptions {
1378
1405
  return null;
1379
1406
  }
1380
1407
  const userId = String(opt.value);
1381
- const resolved = this.#resolved?.users?.[userId] ?? null;
1408
+ const resolved = this.#lookup("users", userId) ?? null;
1382
1409
  if (!resolved && required)
1383
1410
  throw new TypeError(`Resolved user for option "${name}" is missing.`);
1384
1411
  return resolved;
@@ -1391,7 +1418,7 @@ class CommandOptions {
1391
1418
  return null;
1392
1419
  }
1393
1420
  const channelId = String(opt.value);
1394
- const resolved = this.#resolved?.channels?.[channelId] ?? null;
1421
+ const resolved = this.#lookup("channels", channelId) ?? null;
1395
1422
  if (!resolved && required)
1396
1423
  throw new TypeError(`Resolved channel for option "${name}" is missing.`);
1397
1424
  return resolved;
@@ -1404,7 +1431,7 @@ class CommandOptions {
1404
1431
  return null;
1405
1432
  }
1406
1433
  const roleId = String(opt.value);
1407
- const resolved = this.#resolved?.roles?.[roleId] ?? null;
1434
+ const resolved = this.#lookup("roles", roleId) ?? null;
1408
1435
  if (!resolved && required)
1409
1436
  throw new TypeError(`Resolved role for option "${name}" is missing.`);
1410
1437
  return resolved;
@@ -1417,7 +1444,7 @@ class CommandOptions {
1417
1444
  return null;
1418
1445
  }
1419
1446
  const id = String(opt.value);
1420
- const resolved = this.#resolved?.users?.[id] ?? this.#resolved?.roles?.[id] ?? null;
1447
+ const resolved = this.#lookup("users", id) ?? this.#lookup("roles", id) ?? null;
1421
1448
  if (!resolved && required)
1422
1449
  throw new TypeError(`Resolved mentionable for option "${name}" is missing.`);
1423
1450
  return resolved;
@@ -1427,9 +1454,9 @@ class CommandOptions {
1427
1454
  if (!opt || opt.type !== OptionType.Mentionable)
1428
1455
  return null;
1429
1456
  const id = String(opt.value);
1430
- if (this.#resolved?.users?.[id])
1457
+ if (this.#lookup("users", id))
1431
1458
  return "user";
1432
- if (this.#resolved?.roles?.[id])
1459
+ if (this.#lookup("roles", id))
1433
1460
  return "role";
1434
1461
  return null;
1435
1462
  }
@@ -1441,7 +1468,7 @@ class CommandOptions {
1441
1468
  return null;
1442
1469
  }
1443
1470
  const attachmentId = String(opt.value);
1444
- const resolved = this.#resolved?.attachments?.[attachmentId] ?? null;
1471
+ const resolved = this.#lookup("attachments", attachmentId) ?? null;
1445
1472
  if (!resolved && required)
1446
1473
  throw new TypeError(`Resolved attachment for option "${name}" is missing.`);
1447
1474
  return resolved;
@@ -1745,16 +1772,19 @@ class ContextMenuCommandInteraction extends CommandInteraction {
1745
1772
 
1746
1773
  class ComponentInteraction extends Interaction {
1747
1774
  get customId() {
1748
- return this.data?.data?.custom_id ?? "";
1775
+ const id = this.data.data?.custom_id;
1776
+ return typeof id === "string" ? id : "";
1749
1777
  }
1750
1778
  get messageId() {
1751
- return this.data?.message?.id;
1779
+ return this.data.message?.id;
1752
1780
  }
1753
1781
  get componentType() {
1754
- return this.data?.data?.component_type ?? 0;
1782
+ const type = this.data.data?.component_type;
1783
+ return typeof type === "number" ? type : 0;
1755
1784
  }
1756
1785
  get values() {
1757
- return this.data?.data?.values ?? [];
1786
+ const values = this.data.data?.values;
1787
+ return Array.isArray(values) ? values : [];
1758
1788
  }
1759
1789
  async deferUpdate(options = {}) {
1760
1790
  const withResponse = options.withResponse === true;
@@ -1766,10 +1796,11 @@ class ComponentInteraction extends Interaction {
1766
1796
 
1767
1797
  class ModalSubmitInteraction extends Interaction {
1768
1798
  get customId() {
1769
- return this.data?.data?.custom_id ?? "";
1799
+ const id = this.data.data?.custom_id;
1800
+ return typeof id === "string" ? id : "";
1770
1801
  }
1771
1802
  getInputValue(customId) {
1772
- const rows = this.data?.data?.components ?? [];
1803
+ const rows = this.data.data?.components ?? [];
1773
1804
  for (const row of rows) {
1774
1805
  for (const comp of row.components ?? []) {
1775
1806
  if (comp.custom_id === customId)
@@ -1793,11 +1824,12 @@ class AutocompleteInteraction extends Interaction {
1793
1824
  this.options = new CommandOptions(data.data?.options ?? []);
1794
1825
  }
1795
1826
  get commandName() {
1796
- return this.data?.data?.name ?? "";
1827
+ const name = this.data.data?.name;
1828
+ return typeof name === "string" ? name : "";
1797
1829
  }
1798
1830
  get focusedOption() {
1799
- const options = this.data?.data?.options ?? [];
1800
- return findFocused(options);
1831
+ const options = this.data.data?.options;
1832
+ return findFocused(Array.isArray(options) ? options : []);
1801
1833
  }
1802
1834
  async respond(choices) {
1803
1835
  if (!Array.isArray(choices))
@@ -2081,10 +2113,10 @@ class Message extends BaseStructure {
2081
2113
  update(options) {
2082
2114
  return this.edit(options);
2083
2115
  }
2084
- delete() {
2116
+ delete(reason) {
2085
2117
  if (!this.#context)
2086
2118
  throw new Error("This message is not attached to a client.");
2087
- return this.#context.deleteMessage(this.channelId, this.id);
2119
+ return this.#context.deleteMessage(this.channelId, this.id, reason);
2088
2120
  }
2089
2121
  reply(options) {
2090
2122
  if (!this.#context)
@@ -2131,15 +2163,15 @@ class Message extends BaseStructure {
2131
2163
  throw new Error("This message is not attached to a client.");
2132
2164
  return this.#context.removeAllReactions(this.channelId, this.id);
2133
2165
  }
2134
- pin() {
2166
+ pin(reason) {
2135
2167
  if (!this.#context?.pinMessage)
2136
2168
  throw new Error("This message is not attached to a client.");
2137
- return this.#context.pinMessage(this.channelId, this.id);
2169
+ return this.#context.pinMessage(this.channelId, this.id, reason);
2138
2170
  }
2139
- unpin() {
2171
+ unpin(reason) {
2140
2172
  if (!this.#context?.unpinMessage)
2141
2173
  throw new Error("This message is not attached to a client.");
2142
- return this.#context.unpinMessage(this.channelId, this.id);
2174
+ return this.#context.unpinMessage(this.channelId, this.id, reason);
2143
2175
  }
2144
2176
  get isEphemeral() {
2145
2177
  return (this.flags & 64) !== 0;
@@ -2206,8 +2238,8 @@ export {
2206
2238
  ForumChannel,
2207
2239
  Guild,
2208
2240
  GuildMember,
2209
- GuildOnboarding2 as GuildOnboarding,
2210
- GuildWelcomeScreen2 as GuildWelcomeScreen,
2241
+ GuildOnboarding,
2242
+ GuildWelcomeScreen,
2211
2243
  Interaction,
2212
2244
  InteractionEnum,
2213
2245
  InteractionResponse,
@@ -2237,4 +2269,4 @@ export {
2237
2269
  createInteraction
2238
2270
  };
2239
2271
 
2240
- //# debugId=1DD80FEE9EB768DF64756E2164756E21
2272
+ //# debugId=07D330C2B35D9E3E64756E2164756E21