seyfert 2.1.1-dev-12334128354.0 → 2.1.1-dev-12340785707.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.
@@ -462,7 +462,7 @@ class Cache {
462
462
  name: '[CACHE]',
463
463
  });
464
464
  await this.adapter.flush();
465
- // this method will only check the cache for `users`, `members` y `channels`
465
+ // this method will only check the cache for `users`, `members`, and `channels`
466
466
  // likewise these have the three types of resources (GuildRelatedResource, GuildBasedResource, BaseResource)
467
467
  // will also check `overwrites`, since the latter stores an array not as an object but as data.
468
468
  await this.testUsersAndMembers();
@@ -1,5 +1,5 @@
1
1
  import type { CommandContext, Message } from '..';
2
- import { type Awaitable, type DeepPartial, type If, type MakePartial } from '../common';
2
+ import { type Awaitable, type DeepPartial, type If, type PickPartial } from '../common';
3
3
  import { EventHandler } from '../events';
4
4
  import type { GatewayDispatchPayload, GatewayPresenceUpdateData } from '../types';
5
5
  import { ShardManager, type ShardManagerOptions } from '../websocket';
@@ -49,5 +49,5 @@ export interface ClientOptions extends BaseClientOptions {
49
49
  reply?: (ctx: CommandContext) => boolean;
50
50
  };
51
51
  handlePayload?: ShardManagerOptions['handlePayload'];
52
- resharding?: MakePartial<NonNullable<ShardManagerOptions['resharding']>, 'getInfo'>;
52
+ resharding?: PickPartial<NonNullable<ShardManagerOptions['resharding']>, 'getInfo'>;
53
53
  }
@@ -1,7 +1,7 @@
1
1
  import type { GatewayDispatchPayload, GatewaySendPayload } from '../../types';
2
2
  import type { ShardManager, ShardManagerOptions } from '../../websocket';
3
- import type { MakePartial } from '../types/util';
4
- export interface WatcherOptions extends MakePartial<Omit<ShardManager['options'], 'handlePayload' | 'info' | 'token' | 'intents'>, 'compress' | 'presence' | 'properties' | 'shardEnd' | 'shardStart' | 'spawnShardDelay' | 'totalShards' | 'url' | 'version' | 'resharding' | 'debug'> {
3
+ import type { PickPartial } from '../types/util';
4
+ export interface WatcherOptions extends PickPartial<Omit<ShardManager['options'], 'handlePayload' | 'info' | 'token' | 'intents'>, 'compress' | 'presence' | 'properties' | 'shardEnd' | 'shardStart' | 'spawnShardDelay' | 'totalShards' | 'url' | 'version' | 'resharding' | 'debug'> {
5
5
  filePath: string;
6
6
  transpileCommand: string;
7
7
  srcPath: string;
@@ -3,7 +3,7 @@ export type ToClass<T, This> = new (...args: any[]) => {
3
3
  [K in keyof T]: T[K] extends (...args: any[]) => any ? ReturnType<T[K]> extends Promise<T> ? (...args: Parameters<T[K]>) => Promise<This> : ReturnType<T[K]> extends T ? (...args: Parameters<T[K]>) => This : T[K] : T[K];
4
4
  };
5
5
  export type StringToNumber<T extends string> = T extends `${infer N extends number}` ? N : never;
6
- export type MakePartial<T, K extends keyof T> = Omit<T, K> & {
6
+ export type PickPartial<T, K extends keyof T> = Omit<T, K> & {
7
7
  [P in K]?: T[P];
8
8
  };
9
9
  export type MakeDeepPartial<T, K extends keyof T> = Omit<T, K> & {
@@ -45,6 +45,9 @@ export type TupleOr<A, T> = ValueOf<A> extends never ? A : TupleOr<ArrayFirsElem
45
45
  export type MakeRequired<T, K extends keyof T = keyof T> = T & {
46
46
  [P in K]-?: NonFalsy<T[P]>;
47
47
  };
48
+ export type PickRequired<T, K extends keyof T> = Omit<T, K> & {
49
+ [P in K]: NonFalsy<T[P]>;
50
+ };
48
51
  export type NonFalsy<T> = T extends false | 0 | '' | null | undefined | 0n ? never : T;
49
52
  export type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
50
53
  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>;
@@ -38,13 +38,14 @@ export declare class ComponentHandler extends BaseHandler {
38
38
  filter: (path: string) => boolean;
39
39
  constructor(logger: Logger, client: UsingClient);
40
40
  private createMatchCallback;
41
- createComponentCollector(messageId: string, channelId: string, guildId: string | undefined, options?: ListenerOptions): CreateComponentCollectorResult;
41
+ createComponentCollector(messageId: string, channelId: string, guildId: string | undefined, options?: ListenerOptions, components?: COMPONENTS['components']): CreateComponentCollectorResult;
42
42
  onComponent(id: string, interaction: ComponentInteraction): Promise<any>;
43
43
  hasComponent(id: string, customId: string): boolean | undefined;
44
44
  resetTimeouts(id: string): void;
45
45
  hasModal(interaction: ModalSubmitInteraction): boolean;
46
46
  onModalSubmit(interaction: ModalSubmitInteraction): any;
47
47
  deleteValue(id: string, reason?: string): void;
48
+ clearValue(id: string): COMPONENTS | undefined;
48
49
  stablishDefaults(component: ComponentCommands): void;
49
50
  set(instances: (new () => ComponentCommands)[]): void;
50
51
  load(componentsDir: string): Promise<void>;
@@ -25,26 +25,30 @@ class ComponentHandler extends common_1.BaseHandler {
25
25
  return str => match.includes(str);
26
26
  return str => match.test(str);
27
27
  }
28
- createComponentCollector(messageId, channelId, guildId, options = {}) {
28
+ createComponentCollector(messageId, channelId, guildId, options = {}, components = []) {
29
29
  this.values.set(messageId, {
30
30
  messageId,
31
31
  channelId,
32
32
  guildId,
33
33
  options,
34
- components: [],
34
+ components,
35
35
  idle: options.idle && options.idle > 0
36
36
  ? setTimeout(() => {
37
- this.deleteValue(messageId);
37
+ const old = this.clearValue(messageId);
38
+ if (!old)
39
+ return;
38
40
  options.onStop?.('idle', () => {
39
- this.createComponentCollector(messageId, channelId, guildId, options);
41
+ this.createComponentCollector(messageId, channelId, guildId, options, old.components);
40
42
  });
41
43
  }, options.idle)
42
44
  : undefined,
43
45
  timeout: options.timeout && options.timeout > 0
44
46
  ? setTimeout(() => {
45
- this.deleteValue(messageId);
47
+ const old = this.clearValue(messageId);
48
+ if (!old)
49
+ return;
46
50
  options.onStop?.('timeout', () => {
47
- this.createComponentCollector(messageId, channelId, guildId, options);
51
+ this.createComponentCollector(messageId, channelId, guildId, options, old.components);
48
52
  });
49
53
  }, options.timeout)
50
54
  : undefined,
@@ -61,9 +65,11 @@ class ComponentHandler extends common_1.BaseHandler {
61
65
  //@ts-expect-error generic
62
66
  run: this.values.get(messageId).__run,
63
67
  stop: (reason) => {
64
- this.deleteValue(messageId);
68
+ const old = this.clearValue(messageId);
69
+ if (!old)
70
+ return;
65
71
  options.onStop?.(reason, () => {
66
- this.createComponentCollector(messageId, channelId, guildId, options);
72
+ this.createComponentCollector(messageId, channelId, guildId, options, old.components);
67
73
  });
68
74
  },
69
75
  };
@@ -79,10 +85,10 @@ class ComponentHandler extends common_1.BaseHandler {
79
85
  }
80
86
  row.idle?.refresh();
81
87
  await component.callback(interaction, reason => {
88
+ this.clearValue(id);
82
89
  row.options?.onStop?.(reason ?? 'stop', () => {
83
- this.createComponentCollector(row.messageId, row.channelId, row.guildId, row.options);
90
+ this.createComponentCollector(row.messageId, row.channelId, row.guildId, row.options, row.components);
84
91
  });
85
- this.deleteValue(id);
86
92
  }, () => {
87
93
  this.resetTimeouts(id);
88
94
  });
@@ -105,15 +111,21 @@ class ComponentHandler extends common_1.BaseHandler {
105
111
  return this.modals.get(interaction.user.id)?.(interaction);
106
112
  }
107
113
  deleteValue(id, reason) {
114
+ const component = this.clearValue(id);
115
+ if (!component)
116
+ return;
117
+ component.options?.onStop?.(reason, () => {
118
+ this.createComponentCollector(component.messageId, component.channelId, component.guildId, component.options, component.components);
119
+ });
120
+ }
121
+ clearValue(id) {
108
122
  const component = this.values.get(id);
109
- if (component) {
110
- component.options?.onStop?.(reason, () => {
111
- this.createComponentCollector(component.messageId, component.channelId, component.guildId, component.options);
112
- });
113
- clearTimeout(component.timeout);
114
- clearTimeout(component.idle);
115
- this.values.delete(id);
116
- }
123
+ if (!component)
124
+ return;
125
+ clearTimeout(component.timeout);
126
+ clearTimeout(component.idle);
127
+ this.values.delete(id);
128
+ return component;
117
129
  }
118
130
  stablishDefaults(component) {
119
131
  component.props ??= this.client.options.commands?.defaults?.props ?? {};
@@ -1,9 +1,8 @@
1
- import type { AllChannels, ModalCommand, ModalSubmitInteraction, ReturnCache } from '..';
1
+ import type { AllChannels, Interaction, ModalCommand, ModalSubmitInteraction, ReturnCache } from '..';
2
2
  import type { GuildMemberStructure, GuildStructure } from '../client/transformers';
3
3
  import type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands';
4
4
  import { BaseContext } from '../commands/basecontext';
5
5
  import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, ModalCreateBodyRequest, UnionToTuple } from '../common';
6
- import type { Interaction } from '../structures/Interaction';
7
6
  export interface ModalContext extends BaseContext, ExtendContext {
8
7
  }
9
8
  /**
package/lib/deps/mixer.js CHANGED
@@ -7,7 +7,21 @@ exports.Mixin = Mixin;
7
7
  * @param c The class to get the descriptors of.
8
8
  * @returns The descriptors of the class.
9
9
  */
10
- function getDescriptors(c) {
10
+ function getDenoDescriptors(c) {
11
+ const protos = [c.prototype];
12
+ let v = c;
13
+ while ((v = Object.getPrototypeOf(v))) {
14
+ if (v.prototype)
15
+ protos.push(v.prototype);
16
+ }
17
+ return protos.map(x => Object.getOwnPropertyDescriptors(x));
18
+ }
19
+ /**
20
+ * Gets the descriptors of a class.
21
+ * @param c The class to get the descriptors of.
22
+ * @returns The descriptors of the class.
23
+ */
24
+ function getNodeDescriptors(c) {
11
25
  let proto = c.prototype;
12
26
  const result = [];
13
27
  while (proto) {
@@ -20,6 +34,11 @@ function getDescriptors(c) {
20
34
  }
21
35
  return result;
22
36
  }
37
+ function getDescriptors(c) {
38
+ //@ts-expect-error
39
+ // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>
40
+ return typeof Deno === 'undefined' ? getNodeDescriptors(c) : getDenoDescriptors(c);
41
+ }
23
42
  /**
24
43
  * Mixes a class with other classes.
25
44
  * @param args The classes to mix.
@@ -2,7 +2,12 @@ import { type ThreadChannelStructure } from '../../client/transformers';
2
2
  import type { UsingClient } from '../../commands';
3
3
  import type { GatewayThreadCreateDispatchData, GatewayThreadDeleteDispatchData, GatewayThreadListSyncDispatchData, GatewayThreadMemberUpdateDispatchData, GatewayThreadMembersUpdateDispatchData, GatewayThreadUpdateDispatchData } from '../../types';
4
4
  export declare const THREAD_CREATE: (self: UsingClient, data: GatewayThreadCreateDispatchData) => import("../..").ThreadChannel;
5
- export declare const THREAD_DELETE: (self: UsingClient, data: GatewayThreadDeleteDispatchData) => import("../..").ThreadChannel;
5
+ export declare const THREAD_DELETE: (self: UsingClient, data: GatewayThreadDeleteDispatchData) => Promise<import("../..").BaseChannel<import("../../types").ChannelType> | import("../..").DMChannel | import("../..").CategoryChannel | {
6
+ id: string;
7
+ guildId: string;
8
+ parentId: string;
9
+ type: import("../../types").ChannelType;
10
+ }>;
6
11
  export declare const THREAD_LIST_SYNC: (_self: UsingClient, data: GatewayThreadListSyncDispatchData) => {
7
12
  guildId: string;
8
13
  channelIds?: string[] | undefined;
@@ -272,8 +277,8 @@ export declare const THREAD_LIST_SYNC: (_self: UsingClient, data: GatewayThreadL
272
277
  deny: string;
273
278
  }[] | undefined;
274
279
  position: number;
275
- parentId?: string | null | undefined;
276
280
  nsfw?: boolean | undefined;
281
+ parentId?: string | undefined;
277
282
  })[];
278
283
  members: {
279
284
  id?: string | undefined;
@@ -7,8 +7,8 @@ const THREAD_CREATE = (self, data) => {
7
7
  return transformers_1.Transformers.ThreadChannel(self, data);
8
8
  };
9
9
  exports.THREAD_CREATE = THREAD_CREATE;
10
- const THREAD_DELETE = (self, data) => {
11
- return transformers_1.Transformers.ThreadChannel(self, data);
10
+ const THREAD_DELETE = async (self, data) => {
11
+ return (await self.cache.channels?.get(data.id)) ?? (0, common_1.toCamelCase)(data);
12
12
  };
13
13
  exports.THREAD_DELETE = THREAD_DELETE;
14
14
  const THREAD_LIST_SYNC = (_self, data) => {
@@ -50,7 +50,7 @@ export declare class BaseInteraction<FromGuild extends boolean = boolean, Type e
50
50
  isModal(): this is ModalSubmitInteraction;
51
51
  isEntryPoint(): this is EntryPointInteraction;
52
52
  static from(client: UsingClient, gateway: GatewayInteractionCreateDispatchData, __reply?: __InternalReplyFunction): RoleSelectMenuInteraction | UserSelectMenuInteraction | MentionableSelectMenuInteraction | ChannelSelectMenuInteraction | ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | ButtonInteraction | StringSelectMenuInteraction<string[]> | ModalSubmitInteraction<boolean> | AutocompleteInteraction<boolean> | BaseInteraction<boolean, import("../types").APIPingInteraction>;
53
- fetchGuild(force?: boolean): Promise<import("./Guild").Guild<"api">> | undefined;
53
+ fetchGuild(force?: boolean): Promise<import("./Guild").Guild<"api"> | undefined>;
54
54
  }
55
55
  export type AllInteractions = AutocompleteInteraction | ChatInputCommandInteraction | UserCommandInteraction | MessageCommandInteraction | ComponentInteraction | SelectMenuInteraction | ModalSubmitInteraction | EntryPointInteraction | BaseInteraction;
56
56
  export interface AutocompleteInteraction extends ObjectToLower<Omit<APIApplicationCommandAutocompleteInteraction, 'user' | 'member' | 'type' | 'data' | 'message' | 'channel' | 'app_permissions'>> {
@@ -216,7 +216,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
216
216
  return new BaseInteraction(client, gateway);
217
217
  }
218
218
  }
219
- fetchGuild(force = false) {
219
+ async fetchGuild(force = false) {
220
220
  return this.guildId ? this.client.guilds.fetch(this.guildId, force) : undefined;
221
221
  }
222
222
  }
@@ -236,9 +236,10 @@ export interface ForumChannel extends ObjectToLower<Omit<APIGuildForumChannel, '
236
236
  export declare class ForumChannel extends BaseGuildChannel {
237
237
  type: ChannelType.GuildForum;
238
238
  }
239
- export interface ThreadChannel extends ObjectToLower<Omit<APIThreadChannel, 'permission_overwrites'>>, TextBaseGuildChannel {
239
+ export interface ThreadChannel extends ObjectToLower<Omit<APIThreadChannel, 'permission_overwrites'>>, Omit<TextBaseGuildChannel, 'edit' | 'parentId'> {
240
240
  }
241
241
  export declare class ThreadChannel extends BaseChannel<ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread> {
242
+ parentId: string;
242
243
  type: ChannelType.PublicThread | ChannelType.AnnouncementThread | ChannelType.PrivateThread;
243
244
  webhooks: {
244
245
  list: () => Promise<import("./Webhook").Webhook[]>;
@@ -375,6 +375,7 @@ exports.ForumChannel = ForumChannel = __decorate([
375
375
  (0, mixer_1.mix)(ThreadOnlyMethods, WebhookChannelMethods)
376
376
  ], ForumChannel);
377
377
  let ThreadChannel = class ThreadChannel extends BaseChannel {
378
+ parentId;
378
379
  webhooks = WebhookChannelMethods.channel({
379
380
  client: this.client,
380
381
  channelId: this.parentId,
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Types extracted from https://discord.com/developers/docs/resources/channel
3
3
  */
4
+ import type { PickRequired } from '../../common';
4
5
  import type { ChannelType, OverwriteType, Permissions, Snowflake, VideoQualityMode } from '../index';
5
6
  import type { APIApplication } from './application';
6
7
  import type { APIPartialEmoji } from './emoji';
@@ -176,7 +177,7 @@ export interface APIGroupDMChannel extends Omit<APIDMChannelBase<ChannelType.Gro
176
177
  managed?: boolean;
177
178
  }
178
179
  export type ThreadChannelType = ChannelType.AnnouncementThread | ChannelType.PrivateThread | ChannelType.PublicThread;
179
- export interface APIThreadChannel extends Omit<APITextBasedChannel<ThreadChannelType>, 'name'>, APIGuildChannel<ThreadChannelType> {
180
+ export interface APIThreadChannel extends Omit<APITextBasedChannel<ThreadChannelType>, 'name'>, PickRequired<APIGuildChannel<ThreadChannelType>, 'parent_id'> {
180
181
  /**
181
182
  * The client users member for the thread, only included in select endpoints
182
183
  */
@@ -2,7 +2,7 @@ import { type Worker as ClusterWorker } from 'node:cluster';
2
2
  import type { Worker as WorkerThreadsWorker } from 'node:worker_threads';
3
3
  import { ApiHandler, type CustomWorkerManagerEvents, Logger, type UsingClient, type WorkerClient } from '../..';
4
4
  import { type Adapter } from '../../cache';
5
- import { type Identify, type MakePartial } from '../../common';
5
+ import { type Identify, type PickPartial } from '../../common';
6
6
  import type { GatewayPresenceUpdateData, GatewaySendPayload } from '../../types';
7
7
  import { ConnectQueue } from '../structures/timeout';
8
8
  import type { ShardOptions, WorkerData, WorkerManagerOptions } from './shared';
@@ -19,7 +19,7 @@ export declare class WorkerManager extends Map<number, (ClusterWorker | WorkerTh
19
19
  shardEnd: number;
20
20
  shardsPerWorker: number;
21
21
  }, logger?: Logger): number[][];
22
- options: MakePartial<Required<WorkerManagerOptions>, 'adapter' | 'handleWorkerMessage' | 'handlePayload'>;
22
+ options: PickPartial<Required<WorkerManagerOptions>, 'adapter' | 'handleWorkerMessage' | 'handlePayload'>;
23
23
  debugger?: Logger;
24
24
  connectQueue: ConnectQueue;
25
25
  workerQueue: (() => void)[];
@@ -31,8 +31,8 @@ export declare class WorkerManager extends Map<number, (ClusterWorker | WorkerTh
31
31
  rest: ApiHandler;
32
32
  reshardingWorkerQueue: (() => void)[];
33
33
  private _info?;
34
- constructor(options: Omit<MakePartial<WorkerManagerOptions, 'token' | 'intents' | 'info' | 'handlePayload' | 'handleWorkerMessage'>, 'resharding'> & {
35
- resharding?: MakePartial<NonNullable<WorkerManagerOptions['resharding']>, 'getInfo'>;
34
+ constructor(options: Omit<PickPartial<WorkerManagerOptions, 'token' | 'intents' | 'info' | 'handlePayload' | 'handleWorkerMessage'>, 'resharding'> & {
35
+ resharding?: PickPartial<NonNullable<WorkerManagerOptions['resharding']>, 'getInfo'>;
36
36
  });
37
37
  setCache(adapter: Adapter): void;
38
38
  setRest(rest: ApiHandler): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.1.1-dev-12334128354.0",
3
+ "version": "2.1.1-dev-12340785707.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",