mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
types: use wrapper utilities (#9945)
* types: use `Awaitable<T>` instead of `Promise<T> | T` * types: use `JSONEncodable<T>` over raw definition --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
6
packages/discord.js/typings/index.d.ts
vendored
6
packages/discord.js/typings/index.d.ts
vendored
@@ -1129,7 +1129,7 @@ export abstract class Collector<Key, Value, Extras extends unknown[] = []> exten
|
||||
public toJSON(): unknown;
|
||||
|
||||
protected listener: (...args: any[]) => void;
|
||||
public abstract collect(...args: unknown[]): Key | null | Promise<Key | null>;
|
||||
public abstract collect(...args: unknown[]): Awaitable<Key | null>;
|
||||
public abstract dispose(...args: unknown[]): Key | null;
|
||||
|
||||
public on<EventKey extends keyof CollectorEventTypes<Key, Value, Extras>>(
|
||||
@@ -5066,7 +5066,7 @@ export interface CloseEvent {
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export type CollectorFilter<Arguments extends unknown[]> = (...args: Arguments) => boolean | Promise<boolean>;
|
||||
export type CollectorFilter<Arguments extends unknown[]> = (...args: Arguments) => Awaitable<boolean>;
|
||||
|
||||
export interface CollectorOptions<FilterArguments extends unknown[]> {
|
||||
filter?: CollectorFilter<FilterArguments>;
|
||||
@@ -6647,7 +6647,7 @@ export type Serialized<Value> = Value extends symbol | bigint | (() => any)
|
||||
? never
|
||||
: Value extends number | string | boolean | undefined
|
||||
? Value
|
||||
: Value extends { toJSON(): infer JSONResult }
|
||||
: Value extends JSONEncodable<infer JSONResult>
|
||||
? JSONResult
|
||||
: Value extends ReadonlyArray<infer ItemType>
|
||||
? Serialized<ItemType>[]
|
||||
|
||||
@@ -185,6 +185,7 @@ import {
|
||||
PartialEmojiOnlyId,
|
||||
Emoji,
|
||||
PartialEmoji,
|
||||
Awaitable,
|
||||
} from '.';
|
||||
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
|
||||
@@ -412,7 +413,7 @@ client.on('messageCreate', async message => {
|
||||
(
|
||||
test: ButtonInteraction<'cached'>,
|
||||
items: Collection<Snowflake, ButtonInteraction<'cached'>>,
|
||||
) => boolean | Promise<boolean>
|
||||
) => Awaitable<boolean>
|
||||
>(buttonCollector.filter);
|
||||
expectType<GuildTextBasedChannel>(message.channel);
|
||||
expectType<Guild>(message.guild);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Readable } from 'node:stream';
|
||||
import type { ReadableStream } from 'node:stream/web';
|
||||
import type { Collection } from '@discordjs/collection';
|
||||
import type { Awaitable } from '@discordjs/util';
|
||||
import type { Agent, Dispatcher, RequestInit, BodyInit, Response } from 'undici';
|
||||
import type { IHandler } from '../interfaces/Handler.js';
|
||||
|
||||
@@ -183,7 +184,7 @@ export interface RateLimitData {
|
||||
/**
|
||||
* A function that determines whether the rate limit hit should throw an Error
|
||||
*/
|
||||
export type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Promise<boolean> | boolean;
|
||||
export type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
||||
|
||||
export interface APIRequest {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user