seyfert 1.3.0 → 1.3.2

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.
package/lib/api/api.js CHANGED
@@ -23,6 +23,7 @@ class ApiHandler {
23
23
  this.options = {
24
24
  baseUrl: 'api/v10',
25
25
  domain: 'https://discord.com',
26
+ type: 'Bot',
26
27
  ...options,
27
28
  userAgent: shared_1.DefaultUserAgent,
28
29
  };
@@ -270,7 +271,7 @@ class ApiHandler {
270
271
  let finalUrl = options.url;
271
272
  let data;
272
273
  if (options.request.auth) {
273
- options.headers.Authorization = `Bot ${this.options.token}`;
274
+ options.headers.Authorization = `${this.options.type} ${options.request.token || this.options.token}`;
274
275
  }
275
276
  if (options.request.query) {
276
277
  finalUrl += `?${new URLSearchParams(options.request.query)}`;
@@ -318,6 +319,9 @@ class ApiHandler {
318
319
  return { data, finalUrl };
319
320
  }
320
321
  routefy(url, method) {
322
+ if (url.startsWith('/interactions/') && url.endsWith('/callback')) {
323
+ return '/interactions/:id/:token/callback';
324
+ }
321
325
  let route = url
322
326
  .replace(/\/([a-z-]+)\/(?:[0-9]{17,19})/g, (match, p) => p === 'channels' || p === 'guilds' || p === 'webhooks' ? match : `/${p}/:id`)
323
327
  .replace(/\/reactions\/[^/]+/g, '/reactions/:id')
@@ -12,8 +12,9 @@ export interface ApiHandlerOptions {
12
12
  agent?: string;
13
13
  smartBucket?: boolean;
14
14
  workerProxy?: boolean;
15
+ type?: 'Bearer' | 'Bot';
15
16
  }
16
- export interface ApiHandlerInternalOptions extends MakeRequired<ApiHandlerOptions, 'baseUrl' | 'domain'> {
17
+ export interface ApiHandlerInternalOptions extends MakeRequired<ApiHandlerOptions, 'baseUrl' | 'domain' | 'type'> {
17
18
  userAgent: string;
18
19
  }
19
20
  export interface RawFile {
@@ -31,5 +32,6 @@ export interface ApiRequestOptions {
31
32
  route?: `/${string}`;
32
33
  unshift?: boolean;
33
34
  appendToFormData?: boolean;
35
+ token?: string;
34
36
  }
35
37
  export type HttpMethods = 'GET' | 'DELETE' | 'PUT' | 'POST' | 'PATCH';
@@ -122,7 +122,13 @@ class RedisAdapter {
122
122
  await this.client.del(...keys.map(x => this.buildKey(x)));
123
123
  }
124
124
  async flush() {
125
- await this.remove(await Promise.all([this.scan(this.buildKey('*'), true), this.__scanSets(this.buildKey('*'), true)]).then(x => x.flat()));
125
+ const keys = await Promise.all([
126
+ this.scan(this.buildKey('*'), true),
127
+ this.__scanSets(this.buildKey('*'), true),
128
+ ]).then(x => x.flat());
129
+ if (!keys.length)
130
+ return;
131
+ await this.remove(keys);
126
132
  }
127
133
  async contains(to, keys) {
128
134
  return (await this.client.sismember(`${this.buildKey(to)}:set`, keys)) === 1;
@@ -1,5 +1,5 @@
1
1
  import type { GuildWidgetStyle, RESTGetAPICurrentUserGuildsQuery, RESTPatchAPIAutoModerationRuleJSONBody, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIGuildChannelJSONBody, RESTPostAPIGuildsJSONBody } from 'discord-api-types/v10';
2
- import type { ObjectToLower } from '..';
2
+ import { type ObjectToLower } from '..';
3
3
  import { AnonymousGuild, AutoModerationRule, Guild, GuildMember, Sticker, type CreateStickerBodyRequest } from '../../structures';
4
4
  import { BaseShorter } from './base';
5
5
  export declare class GuildShorter extends BaseShorter {
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GuildShorter = void 0;
7
+ const __1 = require("..");
7
8
  const builders_1 = require("../../builders");
8
9
  const structures_1 = require("../../structures");
9
10
  const channels_1 = __importDefault(require("../../structures/channels"));
@@ -219,7 +220,7 @@ class GuildShorter extends base_1.BaseShorter {
219
220
  edit: (guildId, ruleId, body, reason) => {
220
221
  return this.client.proxy
221
222
  .guilds(guildId)['auto-moderation'].rules(ruleId)
222
- .patch({ body, reason })
223
+ .patch({ body: (0, __1.toSnakeCase)(body), reason })
223
224
  .then(rule => new structures_1.AutoModerationRule(this.client, rule));
224
225
  },
225
226
  };
@@ -49,10 +49,16 @@ export type NonFalsy<T> = T extends false | 0 | '' | null | undefined | 0n ? nev
49
49
  export type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
50
50
  export type SnakeCase<S extends string> = S extends `${infer A}${infer Rest}` ? A extends Uppercase<A> ? `_${Lowercase<A>}${SnakeCase<Rest>}` : `${A}${SnakeCase<Rest>}` : Lowercase<S>;
51
51
  export type ObjectToLower<T> = Identify<{
52
- [K in keyof T as CamelCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? Identify<ObjectToLower<T[K][0]>[]> : T[K] extends object ? Identify<ObjectToLower<T[K]>> : T[K];
52
+ [K in keyof T as CamelCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? Identify<ObjectToLower<T[K][0]>[]> : T[K] extends object ? Identify<ObjectToLower<T[K]>> : AuxIsStrictlyUndefined<T[K]> extends true ? undefined : ObjectToLowerUndefined<T[K]>;
53
+ }>;
54
+ export type ObjectToLowerUndefined<T> = T extends unknown[] ? ObjectToLower<T[0]>[] : Identify<{
55
+ [K in keyof T as CamelCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? ObjectToLower<T[K][0]>[] : T[K] extends object ? ObjectToLower<T[K]> : T[K];
53
56
  }>;
54
57
  export type ObjectToSnake<T> = Identify<{
55
- [K in keyof T as SnakeCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? Identify<ObjectToSnake<T[K][0]>[]> : T[K] extends object ? Identify<ObjectToSnake<T[K]>> : T[K];
58
+ [K in keyof T as SnakeCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? Identify<ObjectToSnake<T[K][0]>[]> : T[K] extends object ? Identify<ObjectToSnake<T[K]>> : AuxIsStrictlyUndefined<T[K]> extends true ? undefined : ObjectToSnakeUndefined<T[K]>;
59
+ }>;
60
+ export type ObjectToSnakeUndefined<T> = T extends unknown[] ? ObjectToSnake<T[0]>[] : Identify<{
61
+ [K in keyof T as SnakeCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? ObjectToSnake<T[K][0]>[] : T[K] extends object ? ObjectToSnake<T[K]> : T[K];
56
62
  }>;
57
63
  export type UnionToTuple<U, A extends any[] = []> = (U extends void ? void : (arg: () => U) => never) extends (arg: infer I) => void ? I extends () => infer W ? UnionToTuple<Exclude<U, W>, [W, ...A]> : A : never;
58
64
  export type KeysWithUndefined<T> = {
@@ -5,7 +5,11 @@ export declare const AUTO_MODERATION_ACTION_EXECUTION: (_self: BaseClient, data:
5
5
  guildId: string;
6
6
  action: {
7
7
  type: import("discord-api-types/v10").AutoModerationActionType;
8
- metadata?: import("discord-api-types/v10").APIAutoModerationActionMetadata | undefined;
8
+ metadata?: {
9
+ channelId?: string | undefined;
10
+ durationSeconds?: number | undefined;
11
+ customMessage?: string | undefined;
12
+ } | undefined;
9
13
  };
10
14
  ruleId: string;
11
15
  ruleTriggerType: import("discord-api-types/v10").AutoModerationRuleTriggerType;