seyfert 2.0.0 → 2.1.1-dev-11310514874.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 (265) hide show
  1. package/lib/api/Router.d.ts +2 -2
  2. package/lib/api/Router.js +2 -1
  3. package/lib/api/Routes/applications.d.ts +29 -30
  4. package/lib/api/Routes/cdn.d.ts +6 -1
  5. package/lib/api/Routes/channels.d.ts +44 -45
  6. package/lib/api/Routes/gateway.d.ts +3 -4
  7. package/lib/api/Routes/guilds.d.ts +81 -80
  8. package/lib/api/Routes/index.d.ts +3 -1
  9. package/lib/api/Routes/interactions.d.ts +9 -3
  10. package/lib/api/Routes/invites.d.ts +3 -4
  11. package/lib/api/Routes/skus.d.ts +10 -0
  12. package/lib/api/Routes/skus.js +2 -0
  13. package/lib/api/Routes/soundboard.d.ts +23 -0
  14. package/lib/api/Routes/soundboard.js +2 -0
  15. package/lib/api/Routes/stage-instances.d.ts +5 -6
  16. package/lib/api/Routes/stickers.d.ts +3 -4
  17. package/lib/api/Routes/users.d.ts +11 -12
  18. package/lib/api/Routes/voice.d.ts +2 -3
  19. package/lib/api/Routes/webhooks.d.ts +16 -15
  20. package/lib/api/api.d.ts +17 -11
  21. package/lib/api/api.js +26 -22
  22. package/lib/api/shared.d.ts +2 -2
  23. package/lib/api/utils/constants.d.ts +3 -1
  24. package/lib/api/utils/constants.js +3 -2
  25. package/lib/builders/ActionRow.d.ts +1 -1
  26. package/lib/builders/Attachment.d.ts +3 -3
  27. package/lib/builders/Attachment.js +13 -13
  28. package/lib/builders/Button.d.ts +1 -1
  29. package/lib/builders/Button.js +1 -1
  30. package/lib/builders/Embed.d.ts +1 -1
  31. package/lib/builders/Embed.js +2 -2
  32. package/lib/builders/Modal.d.ts +1 -1
  33. package/lib/builders/Poll.d.ts +1 -1
  34. package/lib/builders/Poll.js +1 -1
  35. package/lib/builders/SelectMenu.d.ts +1 -1
  36. package/lib/builders/SelectMenu.js +1 -1
  37. package/lib/builders/types.d.ts +2 -1
  38. package/lib/cache/adapters/default.js +5 -3
  39. package/lib/cache/adapters/limited.d.ts +1 -2
  40. package/lib/cache/adapters/limited.js +34 -30
  41. package/lib/cache/adapters/workeradapter.js +3 -1
  42. package/lib/cache/index.d.ts +12 -12
  43. package/lib/cache/index.js +48 -39
  44. package/lib/cache/resources/bans.d.ts +2 -2
  45. package/lib/cache/resources/bans.js +1 -1
  46. package/lib/cache/resources/channels.d.ts +1 -1
  47. package/lib/cache/resources/default/guild-related.d.ts +1 -2
  48. package/lib/cache/resources/emojis.d.ts +2 -2
  49. package/lib/cache/resources/emojis.js +1 -1
  50. package/lib/cache/resources/guilds.d.ts +2 -2
  51. package/lib/cache/resources/guilds.js +7 -11
  52. package/lib/cache/resources/members.d.ts +2 -2
  53. package/lib/cache/resources/members.js +1 -1
  54. package/lib/cache/resources/messages.d.ts +2 -2
  55. package/lib/cache/resources/messages.js +3 -3
  56. package/lib/cache/resources/overwrites.d.ts +1 -1
  57. package/lib/cache/resources/roles.d.ts +2 -2
  58. package/lib/cache/resources/roles.js +1 -1
  59. package/lib/cache/resources/stickers.d.ts +2 -2
  60. package/lib/cache/resources/stickers.js +1 -1
  61. package/lib/cache/resources/users.d.ts +2 -2
  62. package/lib/cache/resources/users.js +1 -1
  63. package/lib/cache/resources/voice-states.d.ts +2 -2
  64. package/lib/cache/resources/voice-states.js +1 -1
  65. package/lib/client/base.d.ts +10 -15
  66. package/lib/client/base.js +48 -44
  67. package/lib/client/client.d.ts +4 -4
  68. package/lib/client/client.js +37 -38
  69. package/lib/client/collectors.js +1 -1
  70. package/lib/client/httpclient.d.ts +1 -1
  71. package/lib/client/httpclient.js +2 -2
  72. package/lib/client/transformers.d.ts +37 -34
  73. package/lib/client/transformers.js +66 -63
  74. package/lib/client/workerclient.d.ts +13 -13
  75. package/lib/client/workerclient.js +182 -65
  76. package/lib/collection.d.ts +3 -3
  77. package/lib/commands/applications/chat.d.ts +3 -3
  78. package/lib/commands/applications/chat.js +5 -6
  79. package/lib/commands/applications/chatcontext.d.ts +6 -6
  80. package/lib/commands/applications/chatcontext.js +16 -8
  81. package/lib/commands/applications/entryPoint.d.ts +46 -0
  82. package/lib/commands/applications/entryPoint.js +56 -0
  83. package/lib/commands/applications/entrycontext.d.ts +40 -0
  84. package/lib/commands/applications/entrycontext.js +85 -0
  85. package/lib/commands/applications/menu.d.ts +1 -1
  86. package/lib/commands/applications/menucontext.d.ts +5 -5
  87. package/lib/commands/applications/menucontext.js +6 -6
  88. package/lib/commands/applications/options.d.ts +7 -6
  89. package/lib/commands/applications/shared.d.ts +5 -2
  90. package/lib/commands/basecontext.d.ts +1 -1
  91. package/lib/commands/decorators.d.ts +20 -26
  92. package/lib/commands/decorators.js +8 -4
  93. package/lib/commands/handle.d.ts +13 -12
  94. package/lib/commands/handle.js +133 -65
  95. package/lib/commands/handler.d.ts +9 -7
  96. package/lib/commands/handler.js +27 -18
  97. package/lib/commands/index.d.ts +2 -0
  98. package/lib/commands/index.js +2 -0
  99. package/lib/commands/optionresolver.d.ts +4 -4
  100. package/lib/commands/optionresolver.js +4 -4
  101. package/lib/common/bot/watcher.d.ts +1 -1
  102. package/lib/common/it/formatter.d.ts +21 -21
  103. package/lib/common/it/formatter.js +40 -41
  104. package/lib/common/it/logger.js +1 -1
  105. package/lib/common/it/utils.d.ts +14 -6
  106. package/lib/common/it/utils.js +62 -27
  107. package/lib/common/shorters/application.d.ts +2 -3
  108. package/lib/common/shorters/application.js +3 -3
  109. package/lib/common/shorters/bans.js +1 -1
  110. package/lib/common/shorters/channels.d.ts +3 -3
  111. package/lib/common/shorters/channels.js +3 -3
  112. package/lib/common/shorters/emojis.js +4 -4
  113. package/lib/common/shorters/guilds.d.ts +3 -3
  114. package/lib/common/shorters/guilds.js +5 -9
  115. package/lib/common/shorters/interaction.d.ts +3 -3
  116. package/lib/common/shorters/interaction.js +6 -5
  117. package/lib/common/shorters/members.d.ts +4 -5
  118. package/lib/common/shorters/members.js +6 -7
  119. package/lib/common/shorters/messages.d.ts +1 -1
  120. package/lib/common/shorters/messages.js +4 -4
  121. package/lib/common/shorters/reactions.d.ts +1 -1
  122. package/lib/common/shorters/reactions.js +1 -1
  123. package/lib/common/shorters/roles.js +1 -1
  124. package/lib/common/shorters/templates.js +2 -2
  125. package/lib/common/shorters/threads.d.ts +1 -1
  126. package/lib/common/shorters/threads.js +17 -11
  127. package/lib/common/shorters/webhook.d.ts +1 -1
  128. package/lib/common/shorters/webhook.js +4 -4
  129. package/lib/common/types/options.d.ts +2 -2
  130. package/lib/common/types/resolvables.d.ts +1 -1
  131. package/lib/common/types/util.d.ts +4 -1
  132. package/lib/common/types/write.d.ts +3 -3
  133. package/lib/components/BaseComponent.js +1 -1
  134. package/lib/components/ButtonComponent.d.ts +1 -1
  135. package/lib/components/componentcommand.d.ts +1 -1
  136. package/lib/components/componentcontext.d.ts +4 -4
  137. package/lib/components/componentcontext.js +1 -1
  138. package/lib/components/handler.d.ts +10 -8
  139. package/lib/components/handler.js +16 -13
  140. package/lib/components/index.js +2 -1
  141. package/lib/components/modalcontext.d.ts +2 -2
  142. package/lib/components/modalcontext.js +1 -1
  143. package/lib/deps/mixer.d.ts +1 -1
  144. package/lib/deps/mixer.js +6 -1
  145. package/lib/events/handler.d.ts +5 -5
  146. package/lib/events/handler.js +69 -19
  147. package/lib/events/hooks/application_command.d.ts +1 -1
  148. package/lib/events/hooks/auto_moderation.d.ts +1 -1
  149. package/lib/events/hooks/auto_moderation.js +1 -1
  150. package/lib/events/hooks/channel.d.ts +1 -1
  151. package/lib/events/hooks/custom.d.ts +1 -0
  152. package/lib/events/hooks/custom.js +5 -1
  153. package/lib/events/hooks/dispatch.d.ts +1 -1
  154. package/lib/events/hooks/entitlement.d.ts +4 -5
  155. package/lib/events/hooks/entitlement.js +4 -4
  156. package/lib/events/hooks/guild.d.ts +3 -3
  157. package/lib/events/hooks/guild.js +1 -1
  158. package/lib/events/hooks/index.d.ts +1 -0
  159. package/lib/events/hooks/index.js +1 -0
  160. package/lib/events/hooks/integration.d.ts +1 -1
  161. package/lib/events/hooks/integration.js +1 -1
  162. package/lib/events/hooks/interactions.d.ts +3 -3
  163. package/lib/events/hooks/invite.d.ts +1 -1
  164. package/lib/events/hooks/message.d.ts +3 -3
  165. package/lib/events/hooks/message.js +1 -1
  166. package/lib/events/hooks/presence.d.ts +2 -2
  167. package/lib/events/hooks/soundboard.d.ts +155 -0
  168. package/lib/events/hooks/soundboard.js +28 -0
  169. package/lib/events/hooks/stage.d.ts +2 -2
  170. package/lib/events/hooks/subscriptions.d.ts +35 -0
  171. package/lib/events/hooks/subscriptions.js +16 -0
  172. package/lib/events/hooks/thread.d.ts +2 -2
  173. package/lib/events/hooks/thread.js +2 -2
  174. package/lib/events/hooks/typing.d.ts +1 -1
  175. package/lib/events/hooks/typing.js +1 -1
  176. package/lib/events/hooks/user.d.ts +2 -2
  177. package/lib/events/hooks/voice.d.ts +2 -2
  178. package/lib/events/hooks/voice.js +1 -1
  179. package/lib/events/hooks/webhook.d.ts +1 -1
  180. package/lib/index.d.ts +2 -2
  181. package/lib/index.js +3 -5
  182. package/lib/langs/handler.d.ts +2 -2
  183. package/lib/structures/Guild.d.ts +7 -4
  184. package/lib/structures/Guild.js +1 -1
  185. package/lib/structures/GuildBan.d.ts +1 -1
  186. package/lib/structures/GuildMember.d.ts +7 -5
  187. package/lib/structures/GuildMember.js +5 -3
  188. package/lib/structures/GuildRole.d.ts +1 -1
  189. package/lib/structures/GuildTemplate.d.ts +1 -1
  190. package/lib/structures/Interaction.d.ts +39 -16
  191. package/lib/structures/Interaction.js +82 -26
  192. package/lib/structures/Message.d.ts +4 -10
  193. package/lib/structures/Message.js +5 -8
  194. package/lib/structures/Poll.d.ts +3 -3
  195. package/lib/structures/Sticker.d.ts +2 -2
  196. package/lib/structures/Sticker.js +1 -1
  197. package/lib/structures/VoiceState.d.ts +2 -1
  198. package/lib/structures/VoiceState.js +1 -1
  199. package/lib/structures/Webhook.d.ts +3 -3
  200. package/lib/structures/Webhook.js +1 -1
  201. package/lib/structures/channels.d.ts +4 -4
  202. package/lib/structures/channels.js +8 -7
  203. package/lib/structures/extra/BaseGuild.d.ts +11 -1
  204. package/lib/structures/extra/BaseGuild.js +27 -0
  205. package/lib/structures/extra/BitField.d.ts +3 -3
  206. package/lib/structures/extra/BitField.js +34 -33
  207. package/lib/structures/extra/DiscordBase.js +1 -1
  208. package/lib/structures/extra/Permissions.d.ts +2 -0
  209. package/lib/structures/extra/Permissions.js +21 -0
  210. package/lib/types/gateway.d.ts +71 -6
  211. package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +6 -1
  212. package/lib/types/payloads/_interactions/applicationCommands.d.ts +41 -6
  213. package/lib/types/payloads/_interactions/applicationCommands.js +28 -1
  214. package/lib/types/payloads/_interactions/base.d.ts +1 -1
  215. package/lib/types/payloads/_interactions/responses.d.ts +74 -2
  216. package/lib/types/payloads/_interactions/responses.js +4 -0
  217. package/lib/types/payloads/channel.d.ts +46 -6
  218. package/lib/types/payloads/channel.js +5 -1
  219. package/lib/types/payloads/guild.d.ts +9 -1
  220. package/lib/types/payloads/guild.js +8 -0
  221. package/lib/types/payloads/index.d.ts +1 -0
  222. package/lib/types/payloads/index.js +1 -0
  223. package/lib/types/payloads/monetization.d.ts +29 -1
  224. package/lib/types/payloads/monetization.js +10 -1
  225. package/lib/types/payloads/soundboard.d.ts +23 -0
  226. package/lib/types/payloads/soundboard.js +5 -0
  227. package/lib/types/payloads/user.js +0 -1
  228. package/lib/types/rest/application.d.ts +3 -3
  229. package/lib/types/rest/auditLog.d.ts +1 -1
  230. package/lib/types/rest/channel.d.ts +5 -18
  231. package/lib/types/rest/guild.d.ts +2 -2
  232. package/lib/types/rest/guildScheduledEvent.d.ts +1 -1
  233. package/lib/types/rest/index.d.ts +1 -0
  234. package/lib/types/rest/index.js +1 -0
  235. package/lib/types/rest/interactions.d.ts +30 -8
  236. package/lib/types/rest/monetization.d.ts +22 -1
  237. package/lib/types/rest/oauth2.d.ts +1 -1
  238. package/lib/types/rest/poll.d.ts +1 -1
  239. package/lib/types/rest/soundboard.d.ts +64 -0
  240. package/lib/types/rest/soundboard.js +2 -0
  241. package/lib/types/rest/stageInstance.d.ts +1 -1
  242. package/lib/types/rest/template.d.ts +1 -1
  243. package/lib/types/rest/user.d.ts +1 -1
  244. package/lib/types/rest/webhook.d.ts +3 -3
  245. package/lib/types/utils/index.d.ts +27 -7
  246. package/lib/types/utils/index.js +25 -6
  247. package/lib/websocket/SharedTypes.d.ts +18 -3
  248. package/lib/websocket/constants/index.d.ts +3 -2
  249. package/lib/websocket/constants/index.js +4 -4
  250. package/lib/websocket/discord/basesocket.d.ts +1 -1
  251. package/lib/websocket/discord/shard.d.ts +4 -3
  252. package/lib/websocket/discord/shard.js +47 -24
  253. package/lib/websocket/discord/sharder.d.ts +9 -6
  254. package/lib/websocket/discord/sharder.js +92 -17
  255. package/lib/websocket/discord/shared.d.ts +12 -3
  256. package/lib/websocket/discord/socket/custom.d.ts +1 -1
  257. package/lib/websocket/discord/socket/custom.js +70 -40
  258. package/lib/websocket/discord/worker.d.ts +9 -2
  259. package/lib/websocket/discord/workermanager.d.ts +42 -16
  260. package/lib/websocket/discord/workermanager.js +170 -46
  261. package/lib/websocket/structures/timeout.d.ts +4 -5
  262. package/lib/websocket/structures/timeout.js +23 -24
  263. package/package.json +72 -65
  264. package/lib/cache/resources/threads.d.ts +0 -14
  265. package/lib/cache/resources/threads.js +0 -32
package/lib/api/api.js CHANGED
@@ -15,7 +15,6 @@ class ApiHandler {
15
15
  ratelimits = new Map();
16
16
  readyQueue = [];
17
17
  cdn = Router_1.CDNRouter.createProxy();
18
- debugger;
19
18
  workerPromises;
20
19
  constructor(options) {
21
20
  this.options = {
@@ -41,6 +40,9 @@ class ApiHandler {
41
40
  parentPort = worker_threads.parentPort;
42
41
  }
43
42
  }
43
+ get proxy() {
44
+ return (this._proxy_ ??= new Router_1.Router(this).createProxy());
45
+ }
44
46
  globalUnblock() {
45
47
  this.globalBlock = false;
46
48
  let cb;
@@ -118,7 +120,7 @@ class ApiHandler {
118
120
  this.clearResetInterval(route);
119
121
  next();
120
122
  if (result.length > 0) {
121
- if (response.headers.get('content-type') === 'application/json') {
123
+ if (response.headers.get('content-type')?.includes('application/json')) {
122
124
  try {
123
125
  result = JSON.parse(result);
124
126
  }
@@ -135,7 +137,7 @@ class ApiHandler {
135
137
  return;
136
138
  }
137
139
  if (result.length > 0) {
138
- if (response.headers.get('content-type') === 'application/json') {
140
+ if (response.headers.get('content-type')?.includes('application/json')) {
139
141
  try {
140
142
  result = JSON.parse(result);
141
143
  }
@@ -148,7 +150,7 @@ class ApiHandler {
148
150
  }
149
151
  }
150
152
  next();
151
- return resolve((result || undefined));
153
+ return resolve(result || undefined);
152
154
  };
153
155
  return new Promise((resolve, reject) => {
154
156
  if (this.globalBlock && auth) {
@@ -177,10 +179,10 @@ class ApiHandler {
177
179
  errMessage += `${JSON.stringify(result.errors, null, 2)}\n`;
178
180
  }
179
181
  }
180
- if (response.status) {
181
- return new Error(errMessage ?? response.statusText);
182
+ if (errMessage.length) {
183
+ return new Error(errMessage);
182
184
  }
183
- return new Error('Unknown error');
185
+ return new Error(response.statusText);
184
186
  }
185
187
  async handle50X(method, url, request, next) {
186
188
  const wait = Math.floor(Math.random() * 1900 + 100);
@@ -196,17 +198,19 @@ class ApiHandler {
196
198
  });
197
199
  }
198
200
  async handle429(route, method, url, request, response, result, next, reject, now) {
199
- const content = typeof request === 'object' ? `${JSON.stringify(request)} ` : '';
200
- let retryAfter;
201
- try {
202
- retryAfter = JSON.parse(result).retry_after * 1000;
203
- }
204
- catch (err) {
205
- this.debugger?.warn(`Unexpected error: ${err}`);
206
- reject(err);
207
- return false;
201
+ const content = `${JSON.stringify(request)} `;
202
+ let retryAfter = Number(response.headers.get('x-ratelimit-reset-after') || response.headers.get('retry-after')) * 1000;
203
+ if (Number.isNaN(retryAfter)) {
204
+ try {
205
+ retryAfter = JSON.parse(result).retry_after * 1000;
206
+ }
207
+ catch (err) {
208
+ this.debugger?.warn(`Unexpected error: ${err}`);
209
+ reject(err);
210
+ return false;
211
+ }
208
212
  }
209
- this.debugger?.info(`${response.headers.get('x-ratelimit-global') ? 'Global' : 'Unexpected'} 429: ${result}\n${content} ${now} ${route} ${response.status}: ${this.ratelimits.get(route).remaining}/${this.ratelimits.get(route).limit} left | Reset ${retryAfter} (${this.ratelimits.get(route).reset - now}ms left) | Scope ${response.headers.get('x-ratelimit-scope')}`);
213
+ this.debugger?.info(`${response.headers.get('x-ratelimit-global') ? 'Global' : 'Unexpected'} 429: ${result.slice(0, 256)}\n${content} ${now} ${route} ${response.status}: ${this.ratelimits.get(route).remaining}/${this.ratelimits.get(route).limit} left | Reset ${retryAfter} (${this.ratelimits.get(route).reset - now}ms left) | Scope ${response.headers.get('x-ratelimit-scope')}`);
210
214
  if (retryAfter) {
211
215
  await (0, common_1.delay)(retryAfter);
212
216
  next();
@@ -255,13 +259,13 @@ class ApiHandler {
255
259
  }
256
260
  }
257
261
  setRatelimitsBucket(route, resp) {
258
- if (resp.headers.get('x-ratelimit-limit')) {
262
+ if (resp.headers.has('x-ratelimit-limit')) {
259
263
  this.ratelimits.get(route).limit = +resp.headers.get('x-ratelimit-limit');
260
264
  }
261
265
  this.ratelimits.get(route).remaining =
262
266
  resp.headers.get('x-ratelimit-remaining') === undefined ? 1 : +resp.headers.get('x-ratelimit-remaining');
263
267
  if (this.options.smartBucket) {
264
- if (resp.headers.get('x-ratelimit-reset-after') &&
268
+ if (resp.headers.has('x-ratelimit-reset-after') &&
265
269
  !this.ratelimits.get(route).resetAfter &&
266
270
  Number(resp.headers.get('x-ratelimit-limit')) === Number(resp.headers.get('x-ratelimit-remaining')) + 1) {
267
271
  this.ratelimits.get(route).resetAfter = +resp.headers.get('x-ratelimit-reset-after') * 1000;
@@ -280,15 +284,15 @@ class ApiHandler {
280
284
  if (options.request.query) {
281
285
  finalUrl += `?${new URLSearchParams(options.request.query)}`;
282
286
  }
283
- if (options.request.files) {
287
+ if (options.request.files?.length) {
284
288
  const formData = new FormData();
285
289
  for (const [index, file] of options.request.files.entries()) {
286
290
  const fileKey = file.key ?? `files[${index}]`;
287
291
  if ((0, utils_1.isBufferLike)(file.data)) {
288
- formData.append(fileKey, new Blob([file.data], { type: file.contentType }), file.name);
292
+ formData.append(fileKey, new Blob([file.data], { type: file.contentType }), file.filename);
289
293
  }
290
294
  else {
291
- formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name);
295
+ formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.filename);
292
296
  }
293
297
  }
294
298
  if (options.request.body) {
@@ -18,9 +18,9 @@ export interface ApiHandlerInternalOptions extends MakeRequired<ApiHandlerOption
18
18
  }
19
19
  export interface RawFile {
20
20
  contentType?: string;
21
- data: Buffer | Uint8Array | boolean | number | string;
21
+ data: ArrayBuffer | Buffer | Uint8Array | boolean | number | string;
22
22
  key?: string;
23
- name: string;
23
+ filename: string;
24
24
  }
25
25
  export interface ApiRequestOptions {
26
26
  body?: Record<string, any>;
@@ -1,7 +1,9 @@
1
- export declare const DefaultUserAgent = "DiscordBot (https://seyfert.dev, v2.0.0)";
1
+ export declare const DefaultUserAgent = "DiscordBot (https://seyfert.dev, v2.1.0)";
2
2
  export declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
3
3
  export declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
4
4
  export declare const ALLOWED_SIZES: readonly [16, 32, 64, 100, 128, 256, 512, 1024, 2048, 4096];
5
+ export declare const ALLOWED_SOUNDS_EXTENSIONS: readonly ["mp3", "ogg"];
5
6
  export type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
6
7
  export type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
7
8
  export type ImageSize = (typeof ALLOWED_SIZES)[number];
9
+ export type SoundExtension = (typeof ALLOWED_SOUNDS_EXTENSIONS)[number];
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALLOWED_SIZES = exports.ALLOWED_STICKER_EXTENSIONS = exports.ALLOWED_EXTENSIONS = exports.DefaultUserAgent = void 0;
4
- exports.DefaultUserAgent = 'DiscordBot (https://seyfert.dev, v2.0.0)';
3
+ exports.ALLOWED_SOUNDS_EXTENSIONS = exports.ALLOWED_SIZES = exports.ALLOWED_STICKER_EXTENSIONS = exports.ALLOWED_EXTENSIONS = exports.DefaultUserAgent = void 0;
4
+ exports.DefaultUserAgent = 'DiscordBot (https://seyfert.dev, v2.1.0)';
5
5
  exports.ALLOWED_EXTENSIONS = ['webp', 'png', 'jpg', 'jpeg', 'gif'];
6
6
  exports.ALLOWED_STICKER_EXTENSIONS = ['png', 'json', 'gif'];
7
7
  exports.ALLOWED_SIZES = [16, 32, 64, 100, 128, 256, 512, 1_024, 2_048, 4_096];
8
+ exports.ALLOWED_SOUNDS_EXTENSIONS = ['mp3', 'ogg'];
@@ -1,5 +1,5 @@
1
- import { type APIActionRowComponent, type APIActionRowComponentTypes, type APIMessageActionRowComponent } from '../types';
2
1
  import type { RestOrArray } from '../common/types/util';
2
+ import { type APIActionRowComponent, type APIActionRowComponentTypes, type APIMessageActionRowComponent } from '../types';
3
3
  import { BaseComponentBuilder } from './Base';
4
4
  import type { BuilderComponents, FixedComponents } from './types';
5
5
  /**
@@ -1,7 +1,7 @@
1
- import type { APIAttachment, RESTAPIAttachment } from '../types';
2
- import type { UsingClient, RawFile } from '..';
1
+ import type { RawFile, UsingClient } from '..';
3
2
  import type { ImageResolvable, ObjectToLower } from '../common';
4
3
  import { Base } from '../structures/extra/Base';
4
+ import type { APIAttachment, RESTAPIAttachment } from '../types';
5
5
  export interface AttachmentResolvableMap {
6
6
  url: string;
7
7
  buffer: Buffer | ArrayBuffer;
@@ -10,7 +10,7 @@ export interface AttachmentResolvableMap {
10
10
  export type AttachmentResolvable = AttachmentResolvableMap[keyof AttachmentResolvableMap] | AttachmentBuilder | Attachment;
11
11
  export type AttachmentDataType = keyof AttachmentResolvableMap;
12
12
  export interface AttachmentData {
13
- name: string;
13
+ filename: string;
14
14
  description: string;
15
15
  resolvable: AttachmentResolvable;
16
16
  type: AttachmentDataType;
@@ -10,9 +10,9 @@ exports.resolveAttachmentData = resolveAttachmentData;
10
10
  exports.resolveBase64 = resolveBase64;
11
11
  exports.resolveImage = resolveImage;
12
12
  const node_crypto_1 = require("node:crypto");
13
+ const node_fs_1 = require("node:fs");
13
14
  const node_path_1 = __importDefault(require("node:path"));
14
15
  const Base_1 = require("../structures/extra/Base");
15
- const node_fs_1 = require("node:fs");
16
16
  class Attachment extends Base_1.Base {
17
17
  data;
18
18
  constructor(client, data) {
@@ -28,7 +28,7 @@ class AttachmentBuilder {
28
28
  * Creates a new Attachment instance.
29
29
  * @param data - The partial attachment data.
30
30
  */
31
- constructor(data = { name: `${((0, node_crypto_1.randomBytes)?.(8))?.toString('base64url') || 'default'}.jpg` }) {
31
+ constructor(data = { filename: `${((0, node_crypto_1.randomBytes)?.(8))?.toString('base64url') || 'default'}.jpg` }) {
32
32
  this.data = data;
33
33
  }
34
34
  /**
@@ -39,7 +39,7 @@ class AttachmentBuilder {
39
39
  * attachment.setName('example.jpg');
40
40
  */
41
41
  setName(name) {
42
- this.data.name = name;
42
+ this.data.filename = name;
43
43
  return this;
44
44
  }
45
45
  /**
@@ -79,17 +79,17 @@ class AttachmentBuilder {
79
79
  if (spoiler === this.spoiler)
80
80
  return this;
81
81
  if (!spoiler) {
82
- this.data.name = this.data.name.slice('SPOILER_'.length);
82
+ this.data.filename = this.data.filename.slice('SPOILER_'.length);
83
83
  return this;
84
84
  }
85
- this.data.name = `SPOILER_${this.data.name}`;
85
+ this.data.filename = `SPOILER_${this.data.filename}`;
86
86
  return this;
87
87
  }
88
88
  /**
89
89
  * Gets whether the attachment is a spoiler.
90
90
  */
91
91
  get spoiler() {
92
- return this.data.name?.startsWith('SPOILER_') ?? false;
92
+ return this.data.filename?.startsWith('SPOILER_') ?? false;
93
93
  }
94
94
  /**
95
95
  * Converts the Attachment instance to JSON.
@@ -109,10 +109,10 @@ function resolveAttachment(resolve) {
109
109
  if ('id' in resolve)
110
110
  return resolve;
111
111
  if (resolve instanceof AttachmentBuilder) {
112
- const data = resolve.toJSON();
113
- return { filename: data.name, description: data.description };
112
+ const { filename, description } = resolve.toJSON();
113
+ return { filename, description };
114
114
  }
115
- return { filename: resolve.name, description: resolve.description };
115
+ return { filename: resolve.filename, description: resolve.description };
116
116
  }
117
117
  /**
118
118
  * Resolves a list of attachments to raw files.
@@ -122,9 +122,9 @@ function resolveAttachment(resolve) {
122
122
  async function resolveFiles(resources) {
123
123
  const data = await Promise.all(resources.map(async (resource, i) => {
124
124
  if (resource instanceof AttachmentBuilder) {
125
- const { type, resolvable, name } = resource.toJSON();
125
+ const { type, resolvable, filename } = resource.toJSON();
126
126
  const resolve = await resolveAttachmentData(resolvable, type);
127
- return { ...resolve, key: `files[${i}]`, name };
127
+ return { ...resolve, key: `files[${i}]`, filename };
128
128
  }
129
129
  if (resource instanceof Attachment) {
130
130
  const resolve = await resolveAttachmentData(resource.url, 'url');
@@ -132,14 +132,14 @@ async function resolveFiles(resources) {
132
132
  data: resolve.data,
133
133
  contentType: resolve.contentType,
134
134
  key: `files[${i}]`,
135
- name: resource.filename,
135
+ filename: resource.filename,
136
136
  };
137
137
  }
138
138
  return {
139
139
  data: resource.data,
140
140
  contentType: resource.contentType,
141
141
  key: `files[${i}]`,
142
- name: resource.name,
142
+ filename: resource.filename,
143
143
  };
144
144
  }));
145
145
  return data;
@@ -1,5 +1,5 @@
1
- import { type ButtonStyle, type APIButtonComponent } from '../types';
2
1
  import { type EmojiResolvable } from '../common';
2
+ import { type APIButtonComponent, type ButtonStyle } from '../types';
3
3
  /**
4
4
  * Represents a button component.
5
5
  * @template Type - The type of the button component.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Button = void 0;
4
- const types_1 = require("../types");
5
4
  const common_1 = require("../common");
5
+ const types_1 = require("../types");
6
6
  /**
7
7
  * Represents a button component.
8
8
  * @template Type - The type of the button component.
@@ -1,5 +1,5 @@
1
- import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter } from '../types';
2
1
  import { type ColorResolvable, type ObjectToLower, type RestOrArray } from '../common';
2
+ import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter } from '../types';
3
3
  /**
4
4
  * Represents a message embed.
5
5
  * @example
@@ -20,8 +20,8 @@ class Embed {
20
20
  * const embed = new Embed({ title: 'Hello', description: 'This is an example embed' });
21
21
  */
22
22
  constructor(data = {}) {
23
- this.data = data;
24
- if (!data.fields)
23
+ this.data = { ...data };
24
+ if (!this.data.fields)
25
25
  this.data.fields = [];
26
26
  }
27
27
  /**
@@ -1,5 +1,5 @@
1
- import { type APIModalInteractionResponseCallbackData, type APITextInputComponent, type TextInputStyle } from '../types';
2
1
  import type { RestOrArray } from '../common';
2
+ import { type APIModalInteractionResponseCallbackData, type APITextInputComponent, type TextInputStyle } from '../types';
3
3
  import type { ActionRow } from './ActionRow';
4
4
  import { BaseComponentBuilder, type OptionValuesLength } from './Base';
5
5
  import type { ModalBuilderComponents, ModalSubmitCallback } from './types';
@@ -1,5 +1,5 @@
1
- import { type APIPollMedia, type RESTAPIPollCreate } from '../types';
2
1
  import { type DeepPartial, type EmojiResolvable, type RestOrArray } from '../common';
2
+ import { type APIPollMedia, type RESTAPIPollCreate } from '../types';
3
3
  export declare class PollBuilder {
4
4
  data: DeepPartial<RESTAPIPollCreate>;
5
5
  constructor(data?: DeepPartial<RESTAPIPollCreate>);
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PollBuilder = void 0;
4
- const types_1 = require("../types");
5
4
  const common_1 = require("../common");
5
+ const types_1 = require("../types");
6
6
  class PollBuilder {
7
7
  data;
8
8
  constructor(data = {}) {
@@ -1,6 +1,6 @@
1
- import { type APIChannelSelectComponent, type APIMentionableSelectComponent, type APIRoleSelectComponent, type APISelectMenuComponent, type APISelectMenuOption, type APIStringSelectComponent, type APIUserSelectComponent, type ChannelType, SelectMenuDefaultValueType } from '../types';
2
1
  import type { EmojiResolvable, RestOrArray, ToClass } from '../common';
3
2
  import type { ChannelSelectMenuInteraction, ComponentInteraction, MentionableSelectMenuInteraction, RoleSelectMenuInteraction, StringSelectMenuInteraction, UserSelectMenuInteraction } from '../structures';
3
+ import { type APIChannelSelectComponent, type APIMentionableSelectComponent, type APIRoleSelectComponent, type APISelectMenuComponent, type APISelectMenuOption, type APIStringSelectComponent, type APIUserSelectComponent, type ChannelType, SelectMenuDefaultValueType } from '../types';
4
4
  import { BaseComponentBuilder, type OptionValuesLength } from './Base';
5
5
  export type BuilderSelectMenus = RoleSelectMenu | UserSelectMenu | MentionableSelectMenu | ChannelSelectMenu | StringSelectMenu;
6
6
  /**
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StringSelectOption = exports.StringSelectMenu = exports.ChannelSelectMenu = exports.MentionableSelectMenu = exports.RoleSelectMenu = exports.UserSelectMenu = exports.SelectMenu = void 0;
4
- const types_1 = require("../types");
5
4
  const utils_1 = require("../common/it/utils");
5
+ const types_1 = require("../types");
6
6
  const Base_1 = require("./Base");
7
7
  /**
8
8
  * Maps default values for Select Menus.
@@ -4,7 +4,7 @@ import type { TextInput } from './Modal';
4
4
  import type { BuilderSelectMenus } from './SelectMenu';
5
5
  export type ComponentCallback<T extends ComponentInteraction | StringSelectMenuInteraction = ComponentInteraction | StringSelectMenuInteraction> = (interaction: T, stop: ComponentStopCallback, refresh: ComponentRefreshCallback) => any;
6
6
  export type ComponentFilterCallback<T = ComponentInteraction> = (interaction: T) => any;
7
- export type ComponentStopCallback = (reason?: string, refresh?: ComponentRefreshCallback) => any;
7
+ export type ComponentStopCallback = (reason: 'messageDelete' | 'channelDelete' | 'guildDelete' | (string & {}) | undefined, refresh: ComponentRefreshCallback) => any;
8
8
  export type ComponentRefreshCallback = () => any;
9
9
  export type ModalSubmitCallback<T = ModalSubmitInteraction> = (interaction: T) => any;
10
10
  export type ButtonLink = Omit<Button, 'setCustomId'>;
@@ -17,5 +17,6 @@ export interface ListenerOptions {
17
17
  timeout?: number;
18
18
  idle?: number;
19
19
  filter?: ComponentFilterCallback;
20
+ onPass?: ComponentFilterCallback;
20
21
  onStop?: ComponentStopCallback;
21
22
  }
@@ -8,15 +8,17 @@ class MemoryAdapter {
8
8
  relationships = new Map();
9
9
  constructor(options = {
10
10
  encode(data) {
11
- return JSON.stringify(data);
11
+ return data;
12
12
  },
13
13
  decode(data) {
14
- return JSON.parse(data);
14
+ return data;
15
15
  },
16
16
  }) {
17
17
  this.options = options;
18
18
  }
19
- start() { }
19
+ start() {
20
+ //
21
+ }
20
22
  scan(query, keys = false) {
21
23
  const values = [];
22
24
  const sq = query.split('.');
@@ -18,7 +18,6 @@ export interface LimitedMemoryAdapterOptions<T> {
18
18
  role?: ResourceLimitedMemoryAdapter;
19
19
  stage_instance?: ResourceLimitedMemoryAdapter;
20
20
  sticker?: ResourceLimitedMemoryAdapter;
21
- thread?: ResourceLimitedMemoryAdapter;
22
21
  overwrite?: ResourceLimitedMemoryAdapter;
23
22
  message?: ResourceLimitedMemoryAdapter;
24
23
  encode?(data: any): T;
@@ -34,7 +33,7 @@ export declare class LimitedMemoryAdapter<T> implements Adapter {
34
33
  scan(query: string, keys?: false): any[];
35
34
  scan(query: string, keys: true): string[];
36
35
  bulkGet(keys: string[]): unknown[];
37
- get(keys: string): unknown;
36
+ get(key: string): unknown;
38
37
  private __set;
39
38
  bulkSet(keys: [string, any][]): void;
40
39
  set(keys: string, data: any): void;
@@ -15,37 +15,41 @@ class LimitedMemoryAdapter {
15
15
  limit: Number.POSITIVE_INFINITY,
16
16
  },
17
17
  encode(data) {
18
- return JSON.stringify(data);
18
+ return data;
19
19
  },
20
20
  decode(data) {
21
- return JSON.parse(data);
21
+ return data;
22
22
  },
23
23
  }, options);
24
24
  }
25
- start() { }
25
+ start() {
26
+ //
27
+ }
26
28
  scan(query, keys = false) {
27
- const values = [];
28
29
  const sq = query.split('.');
29
- for (const iterator of [...this.storage.values()].flatMap(x => x.entries()))
30
- for (const [key, value] of iterator) {
31
- if (key.split('.').every((value, i) => (sq[i] === '*' ? !!value : sq[i] === value))) {
32
- values.push(keys ? key : this.options.decode(value.value));
33
- }
34
- }
35
- return values;
30
+ const isWildcard = sq.map(segment => segment === '*');
31
+ return [...this.storage.values()].flatMap(storageEntry => Array.from(storageEntry.entries())
32
+ .filter(([key]) => key.split('.').every((value, i) => isWildcard[i] || sq[i] === value))
33
+ .map(([key, value]) => (keys ? key : this.options.decode(value.value))));
36
34
  }
37
35
  bulkGet(keys) {
38
- const iterator = [...this.storage.values()];
39
- return keys
40
- .map(key => {
41
- const data = iterator.find(x => x.has(key))?.get(key);
42
- return data ? this.options.decode(data) : null;
36
+ const storageArray = Array.from(this.storage.values());
37
+ const keySet = new Set(keys);
38
+ return storageArray
39
+ .flatMap(storageEntry => {
40
+ const entries = Array.from(storageEntry.entries());
41
+ return entries.filter(([key]) => keySet.has(key)).map(([, value]) => this.options.decode(value.value));
43
42
  })
44
- .filter(x => x);
43
+ .filter(Boolean);
45
44
  }
46
- get(keys) {
47
- const data = [...this.storage.values()].find(x => x.has(keys))?.get(keys);
48
- return data ? this.options.decode(data) : null;
45
+ get(key) {
46
+ for (const storageEntry of this.storage.values()) {
47
+ if (storageEntry.has(key)) {
48
+ const data = storageEntry.get(key);
49
+ return data ? this.options.decode(data) : null;
50
+ }
51
+ }
52
+ return null;
49
53
  }
50
54
  __set(key, data) {
51
55
  const __guildId = Array.isArray(data) ? data[0].guild_id : data.guild_id;
@@ -63,10 +67,6 @@ class LimitedMemoryAdapter {
63
67
  const existsRelation = self.relationships.has(relationshipNamespace);
64
68
  if (existsRelation) {
65
69
  switch (relationshipNamespace) {
66
- case 'guild':
67
- case 'user':
68
- self.removeToRelationship(namespace, k.split('.')[1]);
69
- break;
70
70
  case 'ban':
71
71
  case 'member':
72
72
  case 'voice_state':
@@ -81,11 +81,15 @@ class LimitedMemoryAdapter {
81
81
  case 'role':
82
82
  case 'stage_instance':
83
83
  case 'sticker':
84
- case 'thread':
85
84
  case 'overwrite':
86
85
  case 'message':
87
86
  self.removeToRelationship(namespace, k.split('.')[1]);
88
87
  break;
88
+ // case 'guild':
89
+ // case 'user':
90
+ default:
91
+ self.removeToRelationship(namespace, k.split('.')[1]);
92
+ break;
89
93
  }
90
94
  }
91
95
  },
@@ -152,17 +156,12 @@ class LimitedMemoryAdapter {
152
156
  ?.delete(`${parentNamespace}.${keySplit.at(1)}.${keySplit.at(2)}`);
153
157
  }
154
158
  break;
155
- case 'user':
156
- case 'guild':
157
- this.storage.get(parentNamespace)?.delete(`${parentNamespace}.${keySplit.at(1)}`);
158
- break;
159
159
  case 'channel':
160
160
  case 'emoji':
161
161
  case 'presence':
162
162
  case 'role':
163
163
  case 'stage_instance':
164
164
  case 'sticker':
165
- case 'thread':
166
165
  case 'overwrite':
167
166
  case 'message':
168
167
  for (const keyStorage of this.storage.keys()) {
@@ -175,6 +174,11 @@ class LimitedMemoryAdapter {
175
174
  }
176
175
  }
177
176
  break;
177
+ // case 'user':
178
+ // case 'guild':
179
+ default:
180
+ this.storage.get(parentNamespace)?.delete(`${parentNamespace}.${keySplit.at(1)}`);
181
+ break;
178
182
  }
179
183
  }
180
184
  flush() {
@@ -14,7 +14,9 @@ class WorkerAdapter {
14
14
  if (worker_threads?.parentPort)
15
15
  parentPort = worker_threads.parentPort;
16
16
  }
17
- start() { }
17
+ start() {
18
+ //
19
+ }
18
20
  postMessage(body) {
19
21
  if (parentPort)
20
22
  return parentPort.postMessage(body);
@@ -1,7 +1,8 @@
1
- import { Logger, type If } from '../common';
1
+ import { type If, Logger } from '../common';
2
2
  import type { Adapter } from './adapters';
3
3
  import { Guilds } from './resources/guilds';
4
4
  import { Users } from './resources/users';
5
+ import { Bans } from './resources/bans';
5
6
  import { Channels } from './resources/channels';
6
7
  import { Emojis } from './resources/emojis';
7
8
  import { Members } from './resources/members';
@@ -9,19 +10,20 @@ import { Presences } from './resources/presence';
9
10
  import { Roles } from './resources/roles';
10
11
  import { StageInstances } from './resources/stage-instances';
11
12
  import { Stickers } from './resources/stickers';
12
- import { Threads } from './resources/threads';
13
13
  import { VoiceStates } from './resources/voice-states';
14
- import { Bans } from './resources/bans';
15
- import { GatewayIntentBits, type GatewayDispatchPayload } from '../types';
16
14
  import type { InternalOptions, UsingClient } from '../commands';
17
- import { Overwrites } from './resources/overwrites';
15
+ import { type GatewayDispatchPayload, GatewayIntentBits } from '../types';
18
16
  import { Messages } from './resources/messages';
17
+ import { Overwrites } from './resources/overwrites';
18
+ export { BaseResource } from './resources/default/base';
19
+ export { GuildRelatedResource } from './resources/default/guild-related';
20
+ export { GuildBasedResource } from './resources/default/guild-based';
19
21
  export type InferAsyncCache = InternalOptions extends {
20
22
  asyncCache: infer P;
21
23
  } ? P : false;
22
24
  export type ReturnCache<T> = If<InferAsyncCache, Promise<T>, T>;
23
25
  export type GuildBased = 'members' | 'voiceStates';
24
- export type GuildRelated = 'emojis' | 'roles' | 'threads' | 'channels' | 'stickers' | 'presences' | 'stageInstances' | 'overwrites' | 'messages' | 'bans';
26
+ export type GuildRelated = 'emojis' | 'roles' | 'channels' | 'stickers' | 'presences' | 'stageInstances' | 'overwrites' | 'messages' | 'bans';
25
27
  export type NonGuildBased = 'users' | 'guilds';
26
28
  export type SeyfertBased = 'onPacket';
27
29
  export * from './adapters/index';
@@ -40,7 +42,6 @@ export declare class Cache {
40
42
  overwrites?: Overwrites;
41
43
  roles?: Roles;
42
44
  emojis?: Emojis;
43
- threads?: Threads;
44
45
  channels?: Channels;
45
46
  stickers?: Stickers;
46
47
  presences?: Presences;
@@ -55,7 +56,7 @@ export declare class Cache {
55
56
  get hasRolesIntent(): boolean;
56
57
  get hasChannelsIntent(): boolean;
57
58
  get hasGuildMembersIntent(): boolean;
58
- get hasEmojisAndStickersIntent(): boolean;
59
+ get hasGuildExpressionsIntent(): boolean;
59
60
  get hasVoiceStatesIntent(): boolean;
60
61
  get hasPrenseceUpdates(): boolean;
61
62
  get hasDirectMessages(): boolean;
@@ -75,16 +76,14 @@ export declare class Cache {
75
76
  members: import("..").GuildMember[];
76
77
  users: import("..").User[];
77
78
  channels: NonNullable<ReturnCache<import("..").AllChannels | undefined>>[];
78
- threads: import("..").ThreadChannel[];
79
79
  messages: import("..").Message[];
80
+ voiceStates: import("..").VoiceState[];
80
81
  presences: (Omit<import("../types").GatewayPresenceUpdate, "user"> & {
81
82
  id: string;
82
83
  user_id: string;
83
84
  } & {
84
85
  guild_id: string;
85
86
  })[];
86
- bans: import("../structures/GuildBan").GuildBan[];
87
- voiceStates: import("..").VoiceState[];
88
87
  stageInstances: (import("../types").APIStageInstance & {
89
88
  guild_id: string;
90
89
  })[];
@@ -95,6 +94,7 @@ export declare class Cache {
95
94
  allow: import("../structures/extra/Permissions").PermissionsBitField;
96
95
  guildId: string;
97
96
  }[][];
97
+ bans: import("../structures/GuildBan").GuildBan[];
98
98
  }>>;
99
99
  bulkPatch(keys: (readonly [
100
100
  NonGuildBased,
@@ -116,7 +116,7 @@ export declare class Cache {
116
116
  string,
117
117
  string
118
118
  ])[]): Promise<void>;
119
- onPacket?(event: GatewayDispatchPayload): Promise<void>;
119
+ onPacket(event: GatewayDispatchPayload): Promise<void>;
120
120
  testAdapter(): Promise<void>;
121
121
  private testUsersAndMembers;
122
122
  private testChannelsAndOverwrites;