seyfert 4.5.0 → 5.0.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 (230) hide show
  1. package/lib/api/Routes/cdn.d.ts +2 -2
  2. package/lib/api/Routes/guilds.d.ts +2 -2
  3. package/lib/api/Routes/invites.d.ts +2 -2
  4. package/lib/api/api.d.ts +20 -8
  5. package/lib/api/api.js +198 -44
  6. package/lib/api/shared.d.ts +30 -1
  7. package/lib/api/utils/constants.d.ts +1 -1
  8. package/lib/api/utils/constants.js +1 -1
  9. package/lib/api/utils/utils.d.ts +2 -1
  10. package/lib/api/utils/utils.js +1 -1
  11. package/lib/builders/Attachment.d.ts +1 -1
  12. package/lib/builders/Attachment.js +30 -8
  13. package/lib/builders/MediaGallery.d.ts +2 -2
  14. package/lib/builders/MediaGallery.js +10 -0
  15. package/lib/builders/Modal.d.ts +18 -8
  16. package/lib/builders/Modal.js +36 -7
  17. package/lib/builders/Poll.js +18 -0
  18. package/lib/builders/RadioGroup.d.ts +4 -3
  19. package/lib/builders/RadioGroup.js +24 -3
  20. package/lib/builders/SelectMenu.d.ts +8 -6
  21. package/lib/builders/SelectMenu.js +24 -3
  22. package/lib/builders/types.d.ts +3 -2
  23. package/lib/cache/adapters/default.d.ts +1 -1
  24. package/lib/cache/adapters/default.js +23 -26
  25. package/lib/cache/adapters/limited.d.ts +1 -0
  26. package/lib/cache/adapters/limited.js +47 -33
  27. package/lib/cache/index.d.ts +19 -25
  28. package/lib/cache/index.js +58 -6
  29. package/lib/cache/resources/bans.d.ts +1 -1
  30. package/lib/cache/resources/bans.js +4 -4
  31. package/lib/cache/resources/channels.d.ts +1 -1
  32. package/lib/cache/resources/channels.js +4 -4
  33. package/lib/cache/resources/default/base.d.ts +1 -1
  34. package/lib/cache/resources/default/base.js +8 -8
  35. package/lib/cache/resources/default/guild-based.d.ts +5 -5
  36. package/lib/cache/resources/default/guild-based.js +29 -16
  37. package/lib/cache/resources/default/guild-related.d.ts +5 -5
  38. package/lib/cache/resources/default/guild-related.js +14 -14
  39. package/lib/cache/resources/emojis.d.ts +1 -1
  40. package/lib/cache/resources/emojis.js +4 -4
  41. package/lib/cache/resources/guilds.js +28 -15
  42. package/lib/cache/resources/members.d.ts +1 -1
  43. package/lib/cache/resources/members.js +6 -6
  44. package/lib/cache/resources/messages.d.ts +7 -2
  45. package/lib/cache/resources/messages.js +43 -20
  46. package/lib/cache/resources/overwrites.d.ts +1 -1
  47. package/lib/cache/resources/overwrites.js +5 -8
  48. package/lib/cache/resources/roles.d.ts +1 -1
  49. package/lib/cache/resources/roles.js +4 -4
  50. package/lib/cache/resources/stickers.d.ts +1 -1
  51. package/lib/cache/resources/stickers.js +4 -4
  52. package/lib/cache/resources/users.js +4 -4
  53. package/lib/cache/resources/voice-states.d.ts +1 -1
  54. package/lib/cache/resources/voice-states.js +4 -4
  55. package/lib/client/base.d.ts +83 -24
  56. package/lib/client/base.js +594 -39
  57. package/lib/client/client.d.ts +28 -3
  58. package/lib/client/client.js +33 -9
  59. package/lib/client/collectors.d.ts +9 -8
  60. package/lib/client/collectors.js +19 -52
  61. package/lib/client/httpclient.d.ts +3 -0
  62. package/lib/client/index.d.ts +3 -1
  63. package/lib/client/index.js +4 -0
  64. package/lib/client/intents.d.ts +3 -0
  65. package/lib/client/intents.js +9 -0
  66. package/lib/client/plugins/api.d.ts +4 -0
  67. package/lib/client/plugins/api.js +550 -0
  68. package/lib/client/plugins/errors.d.ts +25 -0
  69. package/lib/client/plugins/errors.js +79 -0
  70. package/lib/client/plugins/order.d.ts +10 -0
  71. package/lib/client/plugins/order.js +32 -0
  72. package/lib/client/plugins/registry.d.ts +273 -0
  73. package/lib/client/plugins/registry.js +868 -0
  74. package/lib/client/plugins/shared.d.ts +23 -0
  75. package/lib/client/plugins/shared.js +193 -0
  76. package/lib/client/plugins/types.d.ts +398 -0
  77. package/lib/client/plugins/types.js +8 -0
  78. package/lib/client/plugins.d.ts +78 -0
  79. package/lib/client/plugins.js +558 -0
  80. package/lib/client/transformers.d.ts +33 -33
  81. package/lib/client/workerclient.d.ts +10 -1
  82. package/lib/client/workerclient.js +27 -17
  83. package/lib/collection.d.ts +10 -8
  84. package/lib/collection.js +19 -25
  85. package/lib/commands/applications/chat.d.ts +20 -18
  86. package/lib/commands/applications/chat.js +39 -14
  87. package/lib/commands/applications/chatcontext.d.ts +23 -15
  88. package/lib/commands/applications/chatcontext.js +23 -2
  89. package/lib/commands/applications/entryPoint.d.ts +4 -3
  90. package/lib/commands/applications/entryPoint.js +1 -1
  91. package/lib/commands/applications/entrycontext.d.ts +7 -9
  92. package/lib/commands/applications/entrycontext.js +3 -1
  93. package/lib/commands/applications/menu.d.ts +4 -3
  94. package/lib/commands/applications/menucontext.d.ts +7 -9
  95. package/lib/commands/applications/menucontext.js +3 -1
  96. package/lib/commands/applications/options.d.ts +23 -23
  97. package/lib/commands/applications/shared.d.ts +39 -17
  98. package/lib/commands/decorators.d.ts +50 -38
  99. package/lib/commands/decorators.js +15 -5
  100. package/lib/commands/handle.d.ts +19 -8
  101. package/lib/commands/handle.js +224 -143
  102. package/lib/commands/handler.d.ts +21 -8
  103. package/lib/commands/handler.js +157 -69
  104. package/lib/commands/index.d.ts +1 -0
  105. package/lib/commands/optionresolver.d.ts +2 -2
  106. package/lib/common/it/colors.js +12 -2
  107. package/lib/common/it/error.d.ts +9 -0
  108. package/lib/common/it/error.js +8 -0
  109. package/lib/common/it/fake-promise.d.ts +4 -0
  110. package/lib/common/it/fake-promise.js +10 -0
  111. package/lib/common/it/formatter.d.ts +14 -11
  112. package/lib/common/it/formatter.js +4 -3
  113. package/lib/common/it/logger.d.ts +7 -1
  114. package/lib/common/it/logger.js +24 -6
  115. package/lib/common/it/utils.d.ts +6 -8
  116. package/lib/common/it/utils.js +44 -42
  117. package/lib/common/shorters/application.d.ts +3 -3
  118. package/lib/common/shorters/application.js +3 -2
  119. package/lib/common/shorters/bans.d.ts +8 -4
  120. package/lib/common/shorters/bans.js +13 -5
  121. package/lib/common/shorters/channels.d.ts +4 -4
  122. package/lib/common/shorters/channels.js +4 -4
  123. package/lib/common/shorters/emojis.js +1 -0
  124. package/lib/common/shorters/guilds.d.ts +8 -8
  125. package/lib/common/shorters/guilds.js +14 -31
  126. package/lib/common/shorters/interaction.d.ts +1 -1
  127. package/lib/common/shorters/invites.d.ts +201 -201
  128. package/lib/common/shorters/members.d.ts +7 -7
  129. package/lib/common/shorters/members.js +13 -14
  130. package/lib/common/shorters/messages.d.ts +2 -2
  131. package/lib/common/shorters/soundboard.d.ts +5 -5
  132. package/lib/common/shorters/users.d.ts +1 -1
  133. package/lib/common/shorters/webhook.d.ts +3 -2
  134. package/lib/common/shorters/webhook.js +0 -7
  135. package/lib/common/types/options.d.ts +4 -0
  136. package/lib/common/types/util.d.ts +8 -0
  137. package/lib/common/types/write.d.ts +2 -1
  138. package/lib/components/BaseSelectMenuComponent.d.ts +1 -1
  139. package/lib/components/BaseSelectMenuComponent.js +1 -1
  140. package/lib/components/ButtonComponent.d.ts +3 -3
  141. package/lib/components/ChannelSelectMenuComponent.d.ts +2 -2
  142. package/lib/components/File.d.ts +1 -1
  143. package/lib/components/MediaGallery.d.ts +1 -1
  144. package/lib/components/MentionableSelectMenuComponent.d.ts +1 -1
  145. package/lib/components/RoleSelectMenuComponent.d.ts +1 -1
  146. package/lib/components/Separator.d.ts +1 -1
  147. package/lib/components/StringSelectMenuComponent.d.ts +1 -1
  148. package/lib/components/TextInputComponent.d.ts +1 -1
  149. package/lib/components/Thumbnail.d.ts +1 -1
  150. package/lib/components/UserSelectMenuComponent.d.ts +1 -1
  151. package/lib/components/componentcommand.d.ts +8 -7
  152. package/lib/components/componentcontext.d.ts +24 -36
  153. package/lib/components/componentcontext.js +7 -17
  154. package/lib/components/handler.d.ts +17 -7
  155. package/lib/components/handler.js +108 -49
  156. package/lib/components/index.d.ts +1 -0
  157. package/lib/components/index.js +1 -0
  158. package/lib/components/interactioncontext.d.ts +45 -0
  159. package/lib/components/interactioncontext.js +93 -0
  160. package/lib/components/modalcommand.d.ts +5 -4
  161. package/lib/components/modalcontext.d.ts +39 -20
  162. package/lib/components/modalcontext.js +59 -6
  163. package/lib/events/event.d.ts +9 -3
  164. package/lib/events/handler.d.ts +51 -6
  165. package/lib/events/handler.js +165 -36
  166. package/lib/events/hooks/application_command.d.ts +1 -1
  167. package/lib/events/hooks/auto_moderation.d.ts +2 -2
  168. package/lib/events/hooks/guild.d.ts +150 -150
  169. package/lib/events/hooks/interactions.d.ts +1 -1
  170. package/lib/events/hooks/invite.d.ts +20 -20
  171. package/lib/events/hooks/message.d.ts +27 -27
  172. package/lib/events/hooks/presence.d.ts +11 -11
  173. package/lib/events/hooks/soundboard.d.ts +6 -6
  174. package/lib/events/hooks/stage.d.ts +2 -2
  175. package/lib/events/hooks/subscriptions.d.ts +3 -3
  176. package/lib/events/hooks/thread.d.ts +30 -30
  177. package/lib/events/hooks/voice.d.ts +3 -4
  178. package/lib/events/hooks/voice.js +2 -1
  179. package/lib/events/utils.d.ts +4 -0
  180. package/lib/events/utils.js +59 -0
  181. package/lib/index.d.ts +9 -4
  182. package/lib/index.js +13 -8
  183. package/lib/langs/handler.d.ts +14 -11
  184. package/lib/langs/handler.js +46 -9
  185. package/lib/langs/router.d.ts +10 -3
  186. package/lib/structures/Application.d.ts +1 -1
  187. package/lib/structures/Emoji.d.ts +3 -3
  188. package/lib/structures/Emoji.js +2 -2
  189. package/lib/structures/Guild.d.ts +154 -154
  190. package/lib/structures/GuildBan.d.ts +4 -4
  191. package/lib/structures/GuildBan.js +3 -3
  192. package/lib/structures/GuildMember.d.ts +7 -7
  193. package/lib/structures/GuildMember.js +28 -7
  194. package/lib/structures/GuildRole.d.ts +1 -1
  195. package/lib/structures/GuildRole.js +2 -2
  196. package/lib/structures/Interaction.d.ts +11 -9
  197. package/lib/structures/Interaction.js +33 -12
  198. package/lib/structures/Message.d.ts +21 -14
  199. package/lib/structures/Message.js +29 -14
  200. package/lib/structures/User.d.ts +1 -1
  201. package/lib/structures/VoiceState.d.ts +4 -0
  202. package/lib/structures/VoiceState.js +13 -1
  203. package/lib/structures/Webhook.d.ts +9 -1
  204. package/lib/structures/Webhook.js +4 -1
  205. package/lib/structures/channels.d.ts +148 -134
  206. package/lib/structures/channels.js +27 -26
  207. package/lib/structures/extra/BitField.d.ts +4 -4
  208. package/lib/structures/extra/BitField.js +20 -4
  209. package/lib/structures/extra/DiscordBase.js +1 -1
  210. package/lib/structures/extra/Permissions.d.ts +2 -4
  211. package/lib/structures/extra/Permissions.js +1 -17
  212. package/lib/types/payloads/_interactions/responses.d.ts +2 -2
  213. package/lib/types/payloads/components.d.ts +4 -4
  214. package/lib/websocket/SharedTypes.d.ts +4 -4
  215. package/lib/websocket/constants/index.d.ts +1 -1
  216. package/lib/websocket/constants/index.js +3 -2
  217. package/lib/websocket/discord/events/memberUpdate.js +2 -2
  218. package/lib/websocket/discord/heartbeater.d.ts +1 -0
  219. package/lib/websocket/discord/heartbeater.js +7 -0
  220. package/lib/websocket/discord/shard.d.ts +2 -2
  221. package/lib/websocket/discord/shard.js +15 -13
  222. package/lib/websocket/discord/sharder.d.ts +8 -7
  223. package/lib/websocket/discord/sharder.js +25 -5
  224. package/lib/websocket/discord/shared.d.ts +19 -6
  225. package/lib/websocket/discord/socket/custom.js +5 -0
  226. package/lib/websocket/discord/worker.d.ts +1 -0
  227. package/lib/websocket/discord/worker.js +2 -0
  228. package/lib/websocket/discord/workermanager.d.ts +25 -11
  229. package/lib/websocket/discord/workermanager.js +41 -10
  230. package/package.json +12 -16
@@ -34,12 +34,16 @@ class Logger {
34
34
  /**
35
35
  * The custom callback function for logging.
36
36
  */
37
+ static __memoryCache = { rss: 0, ts: 0 };
37
38
  static __callback = (self, level, args) => {
38
39
  const color = Logger.colorFunctions.get(level) ?? Logger.noColor;
39
- const memoryData = process.memoryUsage?.();
40
- const date = new Date();
40
+ const now = Date.now();
41
+ if (now - Logger.__memoryCache.ts > 1000) {
42
+ Logger.__memoryCache = { rss: process.memoryUsage?.()?.rss ?? 0, ts: now };
43
+ }
44
+ const date = new Date(now);
41
45
  return [
42
- (0, colors_1.brightBlack)(formatMemoryUsage(memoryData?.rss ?? 0)),
46
+ (0, colors_1.brightBlack)(formatMemoryUsage(Logger.__memoryCache.rss)),
43
47
  (0, colors_1.bgBrightWhite)((0, colors_1.black)(`[${date.toLocaleDateString()} ${date.toLocaleTimeString()}]`)),
44
48
  color(Logger.prefixes.get(level) ?? 'DEBUG'),
45
49
  self.name ? `${self.name} >` : '>',
@@ -53,9 +57,21 @@ class Logger {
53
57
  * Logger.customize((logger, level, args) => {
54
58
  * // Custom logging implementation
55
59
  * });
60
+ * @returns A disposer that restores the previous callback (no-op if a newer one replaced it).
56
61
  */
57
62
  static customize(cb) {
63
+ const previous = Logger.__callback;
58
64
  Logger.__callback = cb;
65
+ return () => {
66
+ if (Logger.__callback === cb)
67
+ Logger.__callback = previous;
68
+ };
69
+ }
70
+ /**
71
+ * Returns the current logging callback, so a customizer can chain the previous one.
72
+ */
73
+ static getCustomizer() {
74
+ return Logger.__callback;
59
75
  }
60
76
  /**
61
77
  * Customizes the logging filename by providing a callback function.
@@ -186,15 +202,17 @@ class Logger {
186
202
  }
187
203
  __write(log) {
188
204
  if (this.saveOnFile || Logger.saveOnFile === 'all' || Logger.saveOnFile?.includes(this.name)) {
189
- if (!(Logger.createdDir || (0, node_fs_1.existsSync)((0, node_path_1.join)(process.cwd(), Logger.dirname)))) {
205
+ const dirname = (0, node_path_1.join)(process.cwd(), Logger.dirname);
206
+ if (!Logger.createdDir) {
207
+ if (!(0, node_fs_1.existsSync)(dirname))
208
+ (0, node_fs_1.mkdirSync)(dirname, { recursive: true });
190
209
  Logger.createdDir = true;
191
- (0, node_fs_1.mkdirSync)((0, node_path_1.join)(process.cwd(), Logger.dirname), { recursive: true });
192
210
  }
193
211
  const fileName = (Logger.fileNames[this.name] ??= (() => {
194
212
  return (Logger.fileNames[this.name] = Logger.__assignFileName(this));
195
213
  })());
196
214
  if (!Logger.streams[fileName]) {
197
- Logger.streams[fileName] = (0, node_fs_1.createWriteStream)((0, node_path_1.join)(process.cwd(), Logger.dirname, fileName));
215
+ Logger.streams[fileName] = (0, node_fs_1.createWriteStream)((0, node_path_1.join)(dirname, fileName));
198
216
  }
199
217
  Logger.streams[fileName].write(`${(0, colors_1.stripColor)(log.join(' '))}\n`);
200
218
  }
@@ -1,5 +1,6 @@
1
1
  import type { Cache } from '../../cache';
2
2
  import { type APIPartialEmoji, GatewayIntentBits } from '../../types';
3
+ export { type FakePromiseResult, fakePromise } from './fake-promise';
3
4
  import { type ColorResolvable, type EmojiResolvable, type Logger, type ObjectToLower, type ObjectToSnake, type TypeArray } from '..';
4
5
  /**
5
6
  * Calculates the shard ID for a guild based on its ID.
@@ -101,18 +102,15 @@ export declare const ReplaceRegex: {
101
102
  };
102
103
  export declare function magicImport(path: string): Promise<any>;
103
104
  export type OnFailCallback = (error: unknown) => any;
104
- export declare function fakePromise<T = unknown | Promise<unknown>>(value: T): {
105
- then<R>(callback: (arg: Awaited<T>) => R): R;
106
- };
107
105
  export declare function lazyLoadPackage<T>(mod: string): T | undefined;
108
- export declare function isCloudfareWorker(): boolean;
106
+ export declare function isCloudflareWorker(): boolean;
109
107
  /**
110
108
  *
111
- * Convert a timestamp to a snowflake.
112
- * @param id The timestamp to convert.
113
- * @returns The snowflake.
109
+ * Converts a Discord snowflake to its unix millisecond timestamp.
110
+ * @param id The snowflake to convert.
111
+ * @returns The unix millisecond timestamp.
114
112
  */
115
- export declare function snowflakeToTimestamp(id: string): bigint;
113
+ export declare function snowflakeToTimestamp(id: string): number;
116
114
  export declare function resolvePartialEmoji(emoji: EmojiResolvable): APIPartialEmoji | undefined;
117
115
  export declare function resolveEmoji(emoji: EmojiResolvable, cache: Cache): Promise<APIPartialEmoji | undefined>;
118
116
  export declare function encodeEmoji(rawEmoji: APIPartialEmoji): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReplaceRegex = exports.BaseHandler = void 0;
3
+ exports.ReplaceRegex = exports.BaseHandler = exports.fakePromise = void 0;
4
4
  exports.calculateShardId = calculateShardId;
5
5
  exports.resolveColor = resolveColor;
6
6
  exports.delay = delay;
@@ -10,9 +10,8 @@ exports.filterSplit = filterSplit;
10
10
  exports.toSnakeCase = toSnakeCase;
11
11
  exports.toCamelCase = toCamelCase;
12
12
  exports.magicImport = magicImport;
13
- exports.fakePromise = fakePromise;
14
13
  exports.lazyLoadPackage = lazyLoadPackage;
15
- exports.isCloudfareWorker = isCloudfareWorker;
14
+ exports.isCloudflareWorker = isCloudflareWorker;
16
15
  exports.snowflakeToTimestamp = snowflakeToTimestamp;
17
16
  exports.resolvePartialEmoji = resolvePartialEmoji;
18
17
  exports.resolveEmoji = resolveEmoji;
@@ -25,6 +24,8 @@ exports.assertString = assertString;
25
24
  const node_fs_1 = require("node:fs");
26
25
  const node_path_1 = require("node:path");
27
26
  const types_1 = require("../../types");
27
+ var fake_promise_1 = require("./fake-promise");
28
+ Object.defineProperty(exports, "fakePromise", { enumerable: true, get: function () { return fake_promise_1.fakePromise; } });
28
29
  const __1 = require("..");
29
30
  /**
30
31
  * Calculates the shard ID for a guild based on its ID.
@@ -54,10 +55,16 @@ function resolveColor(color) {
54
55
  }
55
56
  if (type === 'string') {
56
57
  const lookupColor = ColorLookup[color];
57
- if (lookupColor) {
58
+ if (lookupColor != null) {
58
59
  return lookupColor === -1 ? Math.floor(Math.random() * 0xffffff) : lookupColor;
59
60
  }
60
- return color.startsWith('#') ? Number.parseInt(color.slice(1), 16) : __1.EmbedColors.Default;
61
+ if (color.startsWith('#')) {
62
+ const hex = color.slice(1);
63
+ if (!/^[\da-f]+$/i.test(hex))
64
+ throw new __1.SeyfertError('INTERNAL_ERROR', { metadata: { detail: `Invalid color: ${color}` } });
65
+ return Number.parseInt(hex, 16);
66
+ }
67
+ return __1.EmbedColors.Default;
61
68
  }
62
69
  return Array.isArray(color) && color.length >= 3
63
70
  ? (color[0] << 16) | (color[1] << 8) | color[2]
@@ -80,6 +87,12 @@ function delay(time, result) {
80
87
  function isObject(o) {
81
88
  return o && typeof o === 'object' && !Array.isArray(o);
82
89
  }
90
+ function isPlainObject(o) {
91
+ if (!o || typeof o !== 'object')
92
+ return false;
93
+ const proto = Object.getPrototypeOf(o);
94
+ return proto === Object.prototype || proto === null;
95
+ }
83
96
  /**
84
97
  * Merges multiple options objects together, deeply extending objects.
85
98
  * @param defaults The default options object.
@@ -195,19 +208,19 @@ function toSnakeCase(target) {
195
208
  result[exports.ReplaceRegex.snake(key)] = value;
196
209
  break;
197
210
  case 'object': {
198
- if (Array.isArray(value)) {
199
- result[exports.ReplaceRegex.snake(key)] = value.map(prop => typeof prop === 'object' && prop ? toSnakeCase(prop) : prop);
211
+ if (value === null) {
212
+ result[exports.ReplaceRegex.snake(key)] = null;
200
213
  break;
201
214
  }
202
- if (isObject(value)) {
203
- result[exports.ReplaceRegex.snake(key)] = toSnakeCase(value);
215
+ if (Array.isArray(value)) {
216
+ result[exports.ReplaceRegex.snake(key)] = value.map(prop => (isPlainObject(prop) ? toSnakeCase(prop) : prop));
204
217
  break;
205
218
  }
206
- if (!Number.isNaN(value)) {
207
- result[exports.ReplaceRegex.snake(key)] = null;
219
+ if (isPlainObject(value)) {
220
+ result[exports.ReplaceRegex.snake(key)] = toSnakeCase(value);
208
221
  break;
209
222
  }
210
- result[exports.ReplaceRegex.snake(key)] = toSnakeCase(value);
223
+ result[exports.ReplaceRegex.snake(key)] = value;
211
224
  break;
212
225
  }
213
226
  }
@@ -233,19 +246,19 @@ function toCamelCase(target) {
233
246
  result[exports.ReplaceRegex.camel(key)] = value;
234
247
  break;
235
248
  case 'object': {
236
- if (Array.isArray(value)) {
237
- result[exports.ReplaceRegex.camel(key)] = value.map(prop => typeof prop === 'object' && prop ? toCamelCase(prop) : prop);
249
+ if (value === null) {
250
+ result[exports.ReplaceRegex.camel(key)] = null;
238
251
  break;
239
252
  }
240
- if (isObject(value)) {
241
- result[exports.ReplaceRegex.camel(key)] = toCamelCase(value);
253
+ if (Array.isArray(value)) {
254
+ result[exports.ReplaceRegex.camel(key)] = value.map(prop => (isPlainObject(prop) ? toCamelCase(prop) : prop));
242
255
  break;
243
256
  }
244
- if (!Number.isNaN(value)) {
245
- result[exports.ReplaceRegex.camel(key)] = null;
257
+ if (isPlainObject(value)) {
258
+ result[exports.ReplaceRegex.camel(key)] = toCamelCase(value);
246
259
  break;
247
260
  }
248
- result[exports.ReplaceRegex.camel(key)] = toCamelCase(value);
261
+ result[exports.ReplaceRegex.camel(key)] = value;
249
262
  break;
250
263
  }
251
264
  }
@@ -268,13 +281,6 @@ async function magicImport(path) {
268
281
  return new Function('path', 'return import(`file:///${path}?update=${Date.now()}`)')(path);
269
282
  }
270
283
  }
271
- function fakePromise(value) {
272
- if (value instanceof Promise)
273
- return value;
274
- return {
275
- then: callback => callback(value),
276
- };
277
- }
278
284
  function lazyLoadPackage(mod) {
279
285
  try {
280
286
  return require(mod);
@@ -284,18 +290,18 @@ function lazyLoadPackage(mod) {
284
290
  return;
285
291
  }
286
292
  }
287
- function isCloudfareWorker() {
293
+ function isCloudflareWorker() {
288
294
  //@ts-expect-error
289
295
  return process.platform === 'browser';
290
296
  }
291
297
  /**
292
298
  *
293
- * Convert a timestamp to a snowflake.
294
- * @param id The timestamp to convert.
295
- * @returns The snowflake.
299
+ * Converts a Discord snowflake to its unix millisecond timestamp.
300
+ * @param id The snowflake to convert.
301
+ * @returns The unix millisecond timestamp.
296
302
  */
297
303
  function snowflakeToTimestamp(id) {
298
- return (BigInt(id) >> 22n) + __1.DiscordEpoch;
304
+ return Number((BigInt(id) >> 22n) + __1.DiscordEpoch);
299
305
  }
300
306
  function resolvePartialEmoji(emoji) {
301
307
  if (typeof emoji === 'string') {
@@ -364,20 +370,16 @@ function hasIntent(intents, target) {
364
370
  return (intents & intent) === intent;
365
371
  }
366
372
  function toArrayBuffer(buffer) {
367
- const arrayBuffer = new ArrayBuffer(buffer.length);
368
- const view = new Uint8Array(arrayBuffer);
369
- for (let i = 0; i < buffer.length; ++i) {
370
- view[i] = buffer[i];
373
+ const { buffer: ab, byteOffset, byteLength } = buffer;
374
+ if (ab instanceof SharedArrayBuffer) {
375
+ const copy = new ArrayBuffer(byteLength);
376
+ new Uint8Array(copy).set(new Uint8Array(ab, byteOffset, byteLength));
377
+ return copy;
371
378
  }
372
- return arrayBuffer;
379
+ return ab.slice(byteOffset, byteOffset + byteLength);
373
380
  }
374
381
  function toBuffer(arrayBuffer) {
375
- const buffer = Buffer.alloc(arrayBuffer.byteLength);
376
- const view = new Uint8Array(arrayBuffer);
377
- for (let i = 0; i < buffer.length; ++i) {
378
- buffer[i] = view[i];
379
- }
380
- return buffer;
382
+ return Buffer.from(arrayBuffer);
381
383
  }
382
384
  function assertString(value, message) {
383
385
  if (!(typeof value === 'string' && value !== '')) {
@@ -32,7 +32,7 @@ export declare class ApplicationShorter extends BaseShorter {
32
32
  * Deletes an emoji for the application.
33
33
  * @param emojiId The ID of the emoji.
34
34
  */
35
- deleteEmoji(emojiId: string): Promise<undefined>;
35
+ deleteEmoji(emojiId: string): Promise<void>;
36
36
  /**
37
37
  * Lists the entitlements for the application.
38
38
  * @param [query] The query parameters.
@@ -57,8 +57,8 @@ export declare class ApplicationShorter extends BaseShorter {
57
57
  * Lists the SKUs for the application.
58
58
  * @returns The SKUs.
59
59
  */
60
- listSKUs(): Promise<import("../../types").RESTGetAPISKUsResult>;
60
+ listSKUs(): Promise<import("../..").RESTGetAPISKUsResult>;
61
61
  fetch(): Promise<ApplicationStructure>;
62
62
  edit(body: RESTPatchCurrentApplicationJSONBody): Promise<ApplicationStructure>;
63
- getActivityInstance(instanceId: string): Promise<import("../../types").RestGetAPIApplicationActivityInstanceResult>;
63
+ getActivityInstance(instanceId: string): Promise<import("../..").RestGetAPIApplicationActivityInstanceResult>;
64
64
  }
@@ -62,8 +62,9 @@ class ApplicationShorter extends base_1.BaseShorter {
62
62
  * Deletes an emoji for the application.
63
63
  * @param emojiId The ID of the emoji.
64
64
  */
65
- deleteEmoji(emojiId) {
66
- return this.client.proxy.applications(this.client.applicationId).emojis(emojiId).delete();
65
+ async deleteEmoji(emojiId) {
66
+ await this.client.proxy.applications(this.client.applicationId).emojis(emojiId).delete();
67
+ await this.client.cache.emojis?.remove(emojiId, this.client.applicationId);
67
68
  }
68
69
  /**
69
70
  * Lists the entitlements for the application.
@@ -1,6 +1,11 @@
1
1
  import { type GuildBanStructure } from '../../client/transformers';
2
2
  import type { RESTGetAPIGuildBansQuery, RESTPostAPIGuildBulkBanJSONBody, RESTPutAPIGuildBanJSONBody } from '../../types';
3
+ import type { BanOptions } from '../types/options';
3
4
  import { BaseShorter } from './base';
5
+ export declare function resolveBanOptions(options?: BanOptions): {
6
+ body: RESTPutAPIGuildBanJSONBody | undefined;
7
+ reason?: string;
8
+ };
4
9
  export declare class BanShorter extends BaseShorter {
5
10
  /**
6
11
  * Bulk creates bans in the guild.
@@ -8,7 +13,7 @@ export declare class BanShorter extends BaseShorter {
8
13
  * @param body The request body for bulk banning members.
9
14
  * @param reason The reason for bulk banning members.
10
15
  */
11
- bulkCreate(guildId: string, body: RESTPostAPIGuildBulkBanJSONBody, reason?: string): Promise<import("../../types").RESTPostAPIGuildBulkBanResult>;
16
+ bulkCreate(guildId: string, body: RESTPostAPIGuildBulkBanJSONBody, reason?: string): Promise<import("../..").RESTPostAPIGuildBulkBanResult>;
12
17
  /**
13
18
  * Unbans a member from the guild.
14
19
  * @param guildId The ID of the guild.
@@ -20,10 +25,9 @@ export declare class BanShorter extends BaseShorter {
20
25
  * Bans a member from the guild.
21
26
  * @param guildId The ID of the guild.
22
27
  * @param memberId The ID of the member to ban.
23
- * @param body The request body for banning the member.
24
- * @param reason The reason for banning the member.
28
+ * @param options The options for banning the member.
25
29
  */
26
- create(guildId: string, memberId: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string): Promise<void>;
30
+ create(guildId: string, memberId: string, options?: BanOptions): Promise<void>;
27
31
  /**
28
32
  * Fetches a ban from the guild.
29
33
  * @param guildId The ID of the guild.
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BanShorter = void 0;
4
+ exports.resolveBanOptions = resolveBanOptions;
4
5
  const cache_1 = require("../../cache");
5
6
  const transformers_1 = require("../../client/transformers");
6
7
  const base_1 = require("./base");
8
+ function resolveBanOptions(options) {
9
+ return {
10
+ body: options?.deleteMessageSeconds === undefined
11
+ ? undefined
12
+ : { delete_message_seconds: options.deleteMessageSeconds },
13
+ reason: options?.reason,
14
+ };
15
+ }
7
16
  class BanShorter extends base_1.BaseShorter {
8
17
  /**
9
18
  * Bulk creates bans in the guild.
@@ -29,11 +38,10 @@ class BanShorter extends base_1.BaseShorter {
29
38
  * Bans a member from the guild.
30
39
  * @param guildId The ID of the guild.
31
40
  * @param memberId The ID of the member to ban.
32
- * @param body The request body for banning the member.
33
- * @param reason The reason for banning the member.
41
+ * @param options The options for banning the member.
34
42
  */
35
- async create(guildId, memberId, body, reason) {
36
- await this.client.proxy.guilds(guildId).bans(memberId).put({ reason, body });
43
+ async create(guildId, memberId, options) {
44
+ await this.client.proxy.guilds(guildId).bans(memberId).put(resolveBanOptions(options));
37
45
  await this.client.cache.members?.removeIfNI('GuildModeration', memberId, guildId);
38
46
  }
39
47
  /**
@@ -51,7 +59,7 @@ class BanShorter extends base_1.BaseShorter {
51
59
  return ban;
52
60
  }
53
61
  ban = await this.client.proxy.guilds(guildId).bans(userId).get();
54
- await this.client.cache.members?.set(cache_1.CacheFrom.Rest, ban.user.id, guildId, ban);
62
+ await this.client.cache.bans?.set(cache_1.CacheFrom.Rest, ban.user.id, guildId, ban);
55
63
  return transformers_1.Transformers.GuildBan(this.client, ban, guildId);
56
64
  }
57
65
  /**
@@ -53,7 +53,7 @@ export declare class ChannelShorter extends BaseShorter {
53
53
  pins(channelId: string, query?: RESTGetAPIChannelMessagesPinsQuery): Promise<{
54
54
  hasMore: boolean;
55
55
  items: {
56
- pinnedAt: string;
56
+ pinnedAt: number;
57
57
  message: MessageStructure;
58
58
  }[];
59
59
  }>;
@@ -83,21 +83,21 @@ export declare class ChannelShorter extends BaseShorter {
83
83
  memberPermissions(channelId: string, member: GuildMember, checkAdmin?: boolean): Promise<PermissionsBitField>;
84
84
  overwritesFor(channelId: string, member: GuildMember): Promise<{
85
85
  everyone: {
86
- type: import("../../types").OverwriteType;
86
+ type: import("../..").OverwriteType;
87
87
  id: string;
88
88
  deny: PermissionsBitField;
89
89
  allow: PermissionsBitField;
90
90
  guildId: string;
91
91
  } | undefined;
92
92
  roles: {
93
- type: import("../../types").OverwriteType;
93
+ type: import("../..").OverwriteType;
94
94
  id: string;
95
95
  deny: PermissionsBitField;
96
96
  allow: PermissionsBitField;
97
97
  guildId: string;
98
98
  }[];
99
99
  member: {
100
- type: import("../../types").OverwriteType;
100
+ type: import("../..").OverwriteType;
101
101
  id: string;
102
102
  deny: PermissionsBitField;
103
103
  allow: PermissionsBitField;
@@ -23,9 +23,9 @@ class ChannelShorter extends base_1.BaseShorter {
23
23
  const channel = await this.client.cache.channels?.raw(id);
24
24
  if (channel) {
25
25
  const overwrites = await this.client.cache.overwrites?.raw(id);
26
- if (overwrites)
27
- channel.permission_overwrites = overwrites;
28
- return channel;
26
+ return overwrites
27
+ ? { ...channel, permission_overwrites: overwrites }
28
+ : channel;
29
29
  }
30
30
  }
31
31
  const channel = await this.client.proxy.channels(id).get();
@@ -129,7 +129,7 @@ class ChannelShorter extends base_1.BaseShorter {
129
129
  return {
130
130
  hasMore: pins.has_more,
131
131
  items: pins.items.map(x => ({
132
- pinnedAt: x.pinned_at,
132
+ pinnedAt: Date.parse(x.pinned_at),
133
133
  message: transformers_1.Transformers.Message(this.client, x.message),
134
134
  })),
135
135
  };
@@ -50,6 +50,7 @@ class EmojiShorter extends base_1.BaseShorter {
50
50
  return emoji;
51
51
  }
52
52
  const emoji = await this.client.proxy.guilds(guildId).emojis(emojiId).get();
53
+ await this.client.cache.emojis?.set(cache_1.CacheFrom.Rest, emoji.id, guildId, emoji);
53
54
  return transformers_1.Transformers.GuildEmoji(this.client, emoji, guildId);
54
55
  }
55
56
  /**
@@ -1,7 +1,7 @@
1
1
  import { type AnonymousGuildStructure, type AutoModerationRuleStructure, type GuildMemberStructure, type GuildStructure, type MessageStructure, type StickerStructure } from '../../client/transformers';
2
2
  import type { SeyfertChannelMap } from '../../commands';
3
3
  import { type AllChannels, type CreateStickerBodyRequest, type GuildChannelTypes } from '../../structures';
4
- import type { GuildWidgetStyle, RESTGetAPICurrentUserGuildsQuery, RESTGetAPIGuildMessagesSearchQuery, RESTGetAPIGuildMessagesSearchResult, RESTGetAPIGuildQuery, RESTPatchAPIAutoModerationRuleJSONBody, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPatchAPIGuildJSONBody, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIGuildChannelJSONBody } from '../../types';
4
+ import type { GuildWidgetStyle, RESTGetAPICurrentUserGuildsQuery, RESTGetAPIGuildMessagesSearchQuery, RESTGetAPIGuildMessagesSearchResult, RESTGetAPIGuildQuery, RESTPatchAPIAutoModerationRuleJSONBody, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPatchAPIGuildJSONBody, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIChannelFollowersResult, RESTPostAPIGuildChannelJSONBody } from '../../types';
5
5
  import type { If } from '../types/util';
6
6
  import { BaseShorter } from './base';
7
7
  export declare class GuildShorter extends BaseShorter {
@@ -13,7 +13,7 @@ export declare class GuildShorter extends BaseShorter {
13
13
  * @param options.force Whether to force fetching the guild from the API even if it exists in the cache.
14
14
  * @returns A Promise that resolves to the fetched guild.
15
15
  */
16
- fetch(id: string, options?: GuildFetchOptions | boolean): Promise<import("../../structures").Guild<"api">>;
16
+ fetch(id: string, options?: GuildFetchOptions | boolean): Promise<import("../..").Guild<"api">>;
17
17
  /**
18
18
  * Fetches a guild by its ID.
19
19
  * @param id The ID of the guild to fetch.
@@ -22,14 +22,14 @@ export declare class GuildShorter extends BaseShorter {
22
22
  * @param options.force Whether to force fetching the guild from the API even if it exists in the cache.
23
23
  * @returns A Promise that resolves to the fetched guild.
24
24
  */
25
- raw(id: string, options?: GuildFetchOptions | boolean): Promise<import("../../types").APIGuild>;
25
+ raw(id: string, options?: GuildFetchOptions | boolean): Promise<import("../..").APIGuild>;
26
26
  /**
27
27
  * Generates the widget URL for the guild.
28
28
  * @param id The ID of the guild.
29
29
  * @param style The style of the widget.
30
30
  * @returns The generated widget URL.
31
31
  */
32
- widgetURL(id: string, style?: GuildWidgetStyle): Promise<import("../../types").APIGuildWidgetSettings>;
32
+ widgetURL(id: string, style?: GuildWidgetStyle): Promise<import("../..").APIGuildWidgetSettings>;
33
33
  edit(guildId: string, body: RESTPatchAPIGuildJSONBody, reason?: string): Promise<GuildStructure<'api'>>;
34
34
  list<T extends boolean = false>(query?: RESTGetAPICurrentUserGuildsQuery, force?: T): Promise<If<T, AnonymousGuildStructure[], GuildStructure<'cached'>[] | AnonymousGuildStructure[]>>;
35
35
  fetchSelf(id: string, force?: boolean): Promise<GuildMemberStructure>;
@@ -61,7 +61,7 @@ export declare class GuildShorter extends BaseShorter {
61
61
  * @param force Whether to force fetching the channel from the API even if it exists in the cache.
62
62
  * @returns A Promise that resolves to the fetched channel.
63
63
  */
64
- fetch: (guildId: string, channelId: string, force?: boolean) => Promise<AllChannels>;
64
+ fetch: (_guildId: string, channelId: string, force?: boolean) => Promise<AllChannels>;
65
65
  /**
66
66
  * Creates a new channel in the guild.
67
67
  * @param guildId The ID of the guild.
@@ -81,20 +81,20 @@ export declare class GuildShorter extends BaseShorter {
81
81
  delete: (guildId: string, channelId: string, reason?: string) => Promise<AllChannels>;
82
82
  /**
83
83
  * Edits a channel in the guild.
84
- * @param guildchannelId The ID of the guild.
84
+ * @param guildId The ID of the guild.
85
85
  * @param channelId The ID of the channel to edit.
86
86
  * @param body The data to update the channel with.
87
87
  * @param reason The reason for editing the channel.
88
88
  * @returns A Promise that resolves to the edited channel.
89
89
  */
90
- edit: (guildchannelId: string, channelId: string, body: RESTPatchAPIChannelJSONBody, reason?: string) => Promise<AllChannels>;
90
+ edit: (guildId: string, channelId: string, body: RESTPatchAPIChannelJSONBody, reason?: string) => Promise<AllChannels>;
91
91
  /**
92
92
  * Edits the positions of channels in the guild.
93
93
  * @param guildId The ID of the guild.
94
94
  * @param body The data containing the new positions of channels.
95
95
  */
96
96
  editPositions: (guildId: string, body: RESTPatchAPIGuildChannelPositionsJSONBody) => Promise<undefined>;
97
- addFollower: (channelId: string, webhook_channel_id: string, reason?: string) => Promise<import("../../types").APIFollowedChannel>;
97
+ addFollower: (channelId: string, webhook_channel_id: string, reason?: string) => Promise<RESTPostAPIChannelFollowersResult>;
98
98
  };
99
99
  /**
100
100
  * Provides access to auto-moderation rule-related functionality in a guild.
@@ -119,14 +119,13 @@ class GuildShorter extends base_1.BaseShorter {
119
119
  * @returns A Promise that resolves to an array of channels.
120
120
  */
121
121
  list: async (guildId, force = false) => {
122
- let channels;
123
122
  if (!force) {
124
- channels = (await this.client.cache.channels?.values(guildId)) ?? [];
125
- if (channels.length) {
126
- return channels;
123
+ const cachedChannels = (await this.client.cache.channels?.values(guildId)) ?? [];
124
+ if (cachedChannels.length) {
125
+ return cachedChannels;
127
126
  }
128
127
  }
129
- channels = await this.client.proxy.guilds(guildId).channels.get();
128
+ const channels = await this.client.proxy.guilds(guildId).channels.get();
130
129
  await this.client.cache.channels?.set(cache_1.CacheFrom.Rest, channels.map(x => [x.id, x]), guildId);
131
130
  const filtered = channels.filter((ch) => {
132
131
  return 'permission_overwrites' in ch && ch.permission_overwrites !== undefined && ch.guild_id !== undefined;
@@ -145,19 +144,8 @@ class GuildShorter extends base_1.BaseShorter {
145
144
  * @param force Whether to force fetching the channel from the API even if it exists in the cache.
146
145
  * @returns A Promise that resolves to the fetched channel.
147
146
  */
148
- fetch: async (guildId, channelId, force) => {
149
- let channel;
150
- if (!force) {
151
- channel = await this.client.cache.channels?.get(channelId);
152
- if (channel)
153
- return channel;
154
- }
155
- channel = await this.client.proxy.channels(channelId).get();
156
- await this.client.cache.channels?.patch(cache_1.CacheFrom.Rest, channelId, guildId, channel);
157
- if ('permission_overwrites' in channel && channel.permission_overwrites) {
158
- await this.client.cache.overwrites?.set(cache_1.CacheFrom.Rest, channelId, guildId, channel.permission_overwrites);
159
- }
160
- return (0, structures_1.channelFrom)(channel, this.client);
147
+ fetch: async (_guildId, channelId, force) => {
148
+ return this.client.channels.fetch(channelId, force);
161
149
  },
162
150
  /**
163
151
  * Creates a new channel in the guild.
@@ -178,22 +166,18 @@ class GuildShorter extends base_1.BaseShorter {
178
166
  * @returns A Promise that resolves to the deleted channel.
179
167
  */
180
168
  delete: async (guildId, channelId, reason) => {
181
- const res = await this.client.proxy.channels(channelId).delete({ reason });
182
- await this.client.cache.channels?.removeIfNI(structures_1.BaseChannel.__intent__(guildId), res.id, guildId);
183
- return (0, structures_1.channelFrom)(res, this.client);
169
+ return this.client.channels.delete(channelId, { guildId, reason });
184
170
  },
185
171
  /**
186
172
  * Edits a channel in the guild.
187
- * @param guildchannelId The ID of the guild.
173
+ * @param guildId The ID of the guild.
188
174
  * @param channelId The ID of the channel to edit.
189
175
  * @param body The data to update the channel with.
190
176
  * @param reason The reason for editing the channel.
191
177
  * @returns A Promise that resolves to the edited channel.
192
178
  */
193
- edit: async (guildchannelId, channelId, body, reason) => {
194
- const res = await this.client.proxy.channels(channelId).patch({ body, reason });
195
- await this.client.cache.channels?.setIfNI(cache_1.CacheFrom.Rest, structures_1.BaseChannel.__intent__(guildchannelId), res.id, guildchannelId, res);
196
- return (0, structures_1.channelFrom)(res, this.client);
179
+ edit: async (guildId, channelId, body, reason) => {
180
+ return this.client.channels.edit(channelId, body, { guildId, reason });
197
181
  },
198
182
  /**
199
183
  * Edits the positions of channels in the guild.
@@ -318,13 +302,12 @@ class GuildShorter extends base_1.BaseShorter {
318
302
  * @returns A Promise that resolves to the fetched sticker.
319
303
  */
320
304
  fetch: async (guildId, stickerId, force = false) => {
321
- let sticker;
322
305
  if (!force) {
323
- sticker = await this.client.cache.stickers?.get(stickerId);
324
- if (sticker)
325
- return sticker;
306
+ const cachedSticker = await this.client.cache.stickers?.get(stickerId);
307
+ if (cachedSticker)
308
+ return cachedSticker;
326
309
  }
327
- sticker = await this.client.proxy.guilds(guildId).stickers(stickerId).get();
310
+ const sticker = await this.client.proxy.guilds(guildId).stickers(stickerId).get();
328
311
  await this.client.cache.stickers?.patch(cache_1.CacheFrom.Rest, stickerId, guildId, sticker);
329
312
  return transformers_1.Transformers.Sticker(this.client, sticker);
330
313
  },
@@ -3,7 +3,7 @@ import { type WebhookMessageStructure } from '../../client/transformers';
3
3
  import type { InteractionMessageUpdateBodyRequest, MessageWebhookCreateBodyRequest } from '../types/write';
4
4
  import { BaseShorter } from './base';
5
5
  export declare class InteractionShorter extends BaseShorter {
6
- reply(id: string, token: string, body: ReplyInteractionBody, withResponse?: boolean): Promise<import("../../types").RESTPostAPIInteractionCallbackWithResponseResult | undefined>;
6
+ reply(id: string, token: string, body: ReplyInteractionBody, withResponse?: boolean): Promise<import("../..").RESTPostAPIInteractionCallbackWithResponseResult | undefined>;
7
7
  fetchResponse(token: string, messageId: string, threadId?: string): Promise<WebhookMessageStructure>;
8
8
  fetchOriginal(token: string): Promise<WebhookMessageStructure>;
9
9
  editMessage(token: string, messageId: string, body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure>;