mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
refactor: switch api and gateway to V8 (#4879)
Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com>
This commit is contained in:
131
typings/index.d.ts
vendored
131
typings/index.d.ts
vendored
@@ -9,6 +9,11 @@ declare enum ChannelType {
|
||||
unknown = 7,
|
||||
}
|
||||
|
||||
declare enum OverwriteTypes {
|
||||
role = 0,
|
||||
member = 1,
|
||||
}
|
||||
|
||||
declare module 'discord.js' {
|
||||
import BaseCollection from '@discordjs/collection';
|
||||
import { ChildProcess } from 'child_process';
|
||||
@@ -47,7 +52,7 @@ declare module 'discord.js' {
|
||||
|
||||
export class ActivityFlags extends BitField<ActivityFlagsString> {
|
||||
public static FLAGS: Record<ActivityFlagsString, number>;
|
||||
public static resolve(bit?: BitFieldResolvable<ActivityFlagsString>): number;
|
||||
public static resolve(bit?: BitFieldResolvable<ActivityFlagsString, number>): number;
|
||||
}
|
||||
|
||||
export class APIMessage {
|
||||
@@ -118,7 +123,7 @@ declare module 'discord.js' {
|
||||
}
|
||||
|
||||
export class BaseClient extends EventEmitter {
|
||||
constructor(options?: ClientOptions);
|
||||
constructor(options?: ClientOptions | WebhookClientOptions);
|
||||
private _timeouts: Set<NodeJS.Timeout>;
|
||||
private _intervals: Set<NodeJS.Timeout>;
|
||||
private _immediates: Set<NodeJS.Immediate>;
|
||||
@@ -127,7 +132,7 @@ declare module 'discord.js' {
|
||||
private decrementMaxListeners(): void;
|
||||
private incrementMaxListeners(): void;
|
||||
|
||||
public options: ClientOptions;
|
||||
public options: ClientOptions | WebhookClientOptions;
|
||||
public clearInterval(interval: NodeJS.Timeout): void;
|
||||
public clearTimeout(timeout: NodeJS.Timeout): void;
|
||||
public clearImmediate(timeout: NodeJS.Immediate): void;
|
||||
@@ -155,23 +160,23 @@ declare module 'discord.js' {
|
||||
public broadcast: VoiceBroadcast;
|
||||
}
|
||||
|
||||
export class BitField<S extends string> {
|
||||
constructor(bits?: BitFieldResolvable<S>);
|
||||
public bitfield: number;
|
||||
public add(...bits: BitFieldResolvable<S>[]): BitField<S>;
|
||||
public any(bit: BitFieldResolvable<S>): boolean;
|
||||
public equals(bit: BitFieldResolvable<S>): boolean;
|
||||
public freeze(): Readonly<BitField<S>>;
|
||||
public has(bit: BitFieldResolvable<S>): boolean;
|
||||
public missing(bits: BitFieldResolvable<S>, ...hasParam: readonly unknown[]): S[];
|
||||
public remove(...bits: BitFieldResolvable<S>[]): BitField<S>;
|
||||
export class BitField<S extends string, N extends number | bigint = number> {
|
||||
constructor(bits?: BitFieldResolvable<S, N>);
|
||||
public bitfield: N;
|
||||
public add(...bits: BitFieldResolvable<S, N>[]): BitField<S, N>;
|
||||
public any(bit: BitFieldResolvable<S, N>): boolean;
|
||||
public equals(bit: BitFieldResolvable<S, N>): boolean;
|
||||
public freeze(): Readonly<BitField<S, N>>;
|
||||
public has(bit: BitFieldResolvable<S, N>): boolean;
|
||||
public missing(bits: BitFieldResolvable<S, N>, ...hasParam: readonly unknown[]): S[];
|
||||
public remove(...bits: BitFieldResolvable<S, N>[]): BitField<S, N>;
|
||||
public serialize(...hasParam: readonly unknown[]): Record<S, boolean>;
|
||||
public toArray(...hasParam: readonly unknown[]): S[];
|
||||
public toJSON(): number;
|
||||
public valueOf(): number;
|
||||
public [Symbol.iterator](): IterableIterator<S>;
|
||||
public static FLAGS: object;
|
||||
public static resolve(bit?: BitFieldResolvable<any>): number;
|
||||
public static resolve(bit?: BitFieldResolvable<any, number | bigint>): number | bigint;
|
||||
}
|
||||
|
||||
export class CategoryChannel extends GuildChannel {
|
||||
@@ -193,14 +198,15 @@ declare module 'discord.js' {
|
||||
}
|
||||
|
||||
export class Client extends BaseClient {
|
||||
constructor(options?: ClientOptions);
|
||||
constructor(options: ClientOptions);
|
||||
private actions: object;
|
||||
private _eval(script: string): any;
|
||||
private _validateOptions(options?: ClientOptions): void;
|
||||
private _validateOptions(options: ClientOptions): void;
|
||||
|
||||
public channels: ChannelManager;
|
||||
public readonly emojis: BaseGuildEmojiManager;
|
||||
public guilds: GuildManager;
|
||||
public options: ClientOptions;
|
||||
public readyAt: Date | null;
|
||||
public readonly readyTimestamp: number | null;
|
||||
public shard: ShardClientUtil | null;
|
||||
@@ -258,13 +264,14 @@ declare module 'discord.js' {
|
||||
export class ClientUser extends User {
|
||||
public mfaEnabled: boolean;
|
||||
public verified: boolean;
|
||||
public setActivity(options?: ActivityOptions): Promise<Presence>;
|
||||
public setActivity(name: string, options?: ActivityOptions): Promise<Presence>;
|
||||
public edit(data: ClientUserEditData): Promise<this>;
|
||||
public setActivity(options?: ActivityOptions): Presence;
|
||||
public setActivity(name: string, options?: ActivityOptions): Presence;
|
||||
public setAFK(afk: boolean): Promise<Presence>;
|
||||
public setAvatar(avatar: BufferResolvable | Base64Resolvable): Promise<ClientUser>;
|
||||
public setPresence(data: PresenceData): Promise<Presence>;
|
||||
public setStatus(status: PresenceStatusData, shardID?: number | number[]): Promise<Presence>;
|
||||
public setUsername(username: string): Promise<ClientUser>;
|
||||
public setAvatar(avatar: BufferResolvable | Base64Resolvable): Promise<this>;
|
||||
public setPresence(data: PresenceData): Presence;
|
||||
public setStatus(status: PresenceStatusData, shardID?: number | number[]): Presence;
|
||||
public setUsername(username: string): Promise<this>;
|
||||
}
|
||||
|
||||
export class ClientVoiceManager {
|
||||
@@ -517,6 +524,7 @@ declare module 'discord.js' {
|
||||
MessageTypes: MessageType[];
|
||||
SystemMessageTypes: SystemMessageType[];
|
||||
ActivityTypes: ActivityType[];
|
||||
OverwriteTypes: OverwriteTypes;
|
||||
ExplicitContentFilterLevels: ExplicitContentFilterLevel[];
|
||||
DefaultMessageNotifications: DefaultMessageNotifications[];
|
||||
VerificationLevels: VerificationLevel[];
|
||||
@@ -587,9 +595,6 @@ declare module 'discord.js' {
|
||||
public deleted: boolean;
|
||||
public description: string | null;
|
||||
public discoverySplash: string | null;
|
||||
public embedChannel: GuildChannel | null;
|
||||
public embedChannelID: Snowflake | null;
|
||||
public embedEnabled: boolean;
|
||||
public emojis: GuildEmojiManager;
|
||||
public explicitContentFilter: ExplicitContentFilterLevel;
|
||||
public features: GuildFeatures[];
|
||||
@@ -645,8 +650,7 @@ declare module 'discord.js' {
|
||||
public fetchAuditLogs(options?: GuildAuditLogsFetchOptions): Promise<GuildAuditLogs>;
|
||||
public fetchBan(user: UserResolvable): Promise<{ user: User; reason: string }>;
|
||||
public fetchBans(): Promise<Collection<Snowflake, { user: User; reason: string }>>;
|
||||
public fetchEmbed(): Promise<GuildWidget>;
|
||||
public fetchIntegrations(options?: FetchIntegrationsOptions): Promise<Collection<string, Integration>>;
|
||||
public fetchIntegrations(): Promise<Collection<string, Integration>>;
|
||||
public fetchInvites(): Promise<Collection<string, Invite>>;
|
||||
public fetchPreview(): Promise<GuildPreview>;
|
||||
public fetchTemplates(): Promise<Collection<GuildTemplate['code'], GuildTemplate>>;
|
||||
@@ -666,7 +670,6 @@ declare module 'discord.js' {
|
||||
reason?: string,
|
||||
): Promise<Guild>;
|
||||
public setDiscoverySplash(discoverySplash: Base64Resolvable | null, reason?: string): Promise<Guild>;
|
||||
public setEmbed(embed: GuildWidgetData, reason?: string): Promise<Guild>;
|
||||
public setExplicitContentFilter(
|
||||
explicitContentFilter: ExplicitContentFilterLevel | number,
|
||||
reason?: string,
|
||||
@@ -920,7 +923,7 @@ declare module 'discord.js' {
|
||||
public static PRIVILEGED: number;
|
||||
public static ALL: number;
|
||||
public static NON_PRIVILEGED: number;
|
||||
public static resolve(bit?: BitFieldResolvable<IntentsString>): number;
|
||||
public static resolve(bit?: BitFieldResolvable<IntentsString, number>): number;
|
||||
}
|
||||
|
||||
export class Invite extends Base {
|
||||
@@ -1095,7 +1098,7 @@ declare module 'discord.js' {
|
||||
|
||||
export class MessageFlags extends BitField<MessageFlagsString> {
|
||||
public static FLAGS: Record<MessageFlagsString, number>;
|
||||
public static resolve(bit?: BitFieldResolvable<MessageFlagsString>): number;
|
||||
public static resolve(bit?: BitFieldResolvable<MessageFlagsString, number>): number;
|
||||
}
|
||||
|
||||
export class MessageMentions {
|
||||
@@ -1189,17 +1192,17 @@ declare module 'discord.js' {
|
||||
public static resolve(overwrite: OverwriteResolvable, guild: Guild): RawOverwriteData;
|
||||
}
|
||||
|
||||
export class Permissions extends BitField<PermissionString> {
|
||||
export class Permissions extends BitField<PermissionString, bigint> {
|
||||
public any(permission: PermissionResolvable, checkAdmin?: boolean): boolean;
|
||||
public has(permission: PermissionResolvable, checkAdmin?: boolean): boolean;
|
||||
public missing(bits: BitFieldResolvable<PermissionString>, checkAdmin?: boolean): PermissionString[];
|
||||
public missing(bits: BitFieldResolvable<PermissionString, bigint>, checkAdmin?: boolean): PermissionString[];
|
||||
public serialize(checkAdmin?: boolean): Record<PermissionString, boolean>;
|
||||
public toArray(checkAdmin?: boolean): PermissionString[];
|
||||
|
||||
public static ALL: number;
|
||||
public static DEFAULT: number;
|
||||
public static ALL: bigint;
|
||||
public static DEFAULT: bigint;
|
||||
public static FLAGS: PermissionFlags;
|
||||
public static resolve(permission?: PermissionResolvable): number;
|
||||
public static resolve(permission?: PermissionResolvable): bigint;
|
||||
}
|
||||
|
||||
export class Presence {
|
||||
@@ -1410,7 +1413,7 @@ declare module 'discord.js' {
|
||||
|
||||
export class Speaking extends BitField<SpeakingString> {
|
||||
public static FLAGS: Record<SpeakingString, number>;
|
||||
public static resolve(bit?: BitFieldResolvable<SpeakingString>): number;
|
||||
public static resolve(bit?: BitFieldResolvable<SpeakingString, number>): number;
|
||||
}
|
||||
|
||||
export class StoreChannel extends GuildChannel {
|
||||
@@ -1468,7 +1471,7 @@ declare module 'discord.js' {
|
||||
|
||||
export class SystemChannelFlags extends BitField<SystemChannelFlagsString> {
|
||||
public static FLAGS: Record<SystemChannelFlagsString, number>;
|
||||
public static resolve(bit?: BitFieldResolvable<SystemChannelFlagsString>): number;
|
||||
public static resolve(bit?: BitFieldResolvable<SystemChannelFlagsString, number>): number;
|
||||
}
|
||||
|
||||
export class Team extends Base {
|
||||
@@ -1548,7 +1551,7 @@ declare module 'discord.js' {
|
||||
|
||||
export class UserFlags extends BitField<UserFlagsString> {
|
||||
public static FLAGS: Record<UserFlagsString, number>;
|
||||
public static resolve(bit?: BitFieldResolvable<UserFlagsString>): number;
|
||||
public static resolve(bit?: BitFieldResolvable<UserFlagsString, number>): number;
|
||||
}
|
||||
|
||||
export class Util {
|
||||
@@ -1655,7 +1658,7 @@ declare module 'discord.js' {
|
||||
public voiceManager: ClientVoiceManager;
|
||||
public disconnect(): void;
|
||||
public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher;
|
||||
public setSpeaking(value: BitFieldResolvable<SpeakingString>): void;
|
||||
public setSpeaking(value: BitFieldResolvable<SpeakingString, number>): void;
|
||||
|
||||
public on(event: 'authenticated' | 'closing' | 'newSession' | 'ready' | 'reconnecting', listener: () => void): this;
|
||||
public on(event: 'debug', listener: (message: string) => void): this;
|
||||
@@ -1756,8 +1759,9 @@ declare module 'discord.js' {
|
||||
}
|
||||
|
||||
export class WebhookClient extends WebhookMixin(BaseClient) {
|
||||
constructor(id: string, token: string, options?: ClientOptions);
|
||||
constructor(id: string, token: string, options?: WebhookClientOptions);
|
||||
public client: this;
|
||||
public options: WebhookClientOptions;
|
||||
public token: string;
|
||||
}
|
||||
|
||||
@@ -2157,6 +2161,7 @@ declare module 'discord.js' {
|
||||
UNKNOWN_GUILD_TEMPLATE: 10057;
|
||||
BOT_PROHIBITED_ENDPOINT: 20001;
|
||||
BOT_ONLY_ENDPOINT: 20002;
|
||||
ANNOUNCEMENT_EDIT_LIMIT_EXCEEDED: 20022;
|
||||
CHANNEL_HIT_WRITE_RATELIMIT: 20028;
|
||||
MAXIMUM_GUILDS: 30001;
|
||||
MAXIMUM_FRIENDS: 30002;
|
||||
@@ -2323,17 +2328,17 @@ declare module 'discord.js' {
|
||||
|
||||
type Base64String = string;
|
||||
|
||||
type BitFieldResolvable<T extends string> =
|
||||
| RecursiveReadonlyArray<T | number | Readonly<BitField<T>>>
|
||||
type BitFieldResolvable<T extends string, N extends number | bigint> =
|
||||
| RecursiveReadonlyArray<T | N | Readonly<BitField<T, N>>>
|
||||
| T
|
||||
| number
|
||||
| Readonly<BitField<T>>;
|
||||
| N
|
||||
| Readonly<BitField<T, N>>;
|
||||
|
||||
type BufferResolvable = Buffer | string;
|
||||
|
||||
interface ChannelCreationOverwrites {
|
||||
allow?: PermissionResolvable | number;
|
||||
deny?: PermissionResolvable | number;
|
||||
allow?: PermissionResolvable;
|
||||
deny?: PermissionResolvable;
|
||||
id: RoleResolvable | UserResolvable;
|
||||
}
|
||||
|
||||
@@ -2366,8 +2371,8 @@ declare module 'discord.js' {
|
||||
type ChannelResolvable = Channel | Snowflake;
|
||||
|
||||
interface ClientEvents {
|
||||
channelCreate: [channel: Channel];
|
||||
channelDelete: [channel: Channel | PartialDMChannel];
|
||||
channelCreate: [channel: GuildChannel];
|
||||
channelDelete: [channel: DMChannel | GuildChannel];
|
||||
channelPinsUpdate: [channel: Channel | PartialDMChannel, date: Date];
|
||||
channelUpdate: [oldChannel: Channel, newChannel: Channel];
|
||||
debug: [message: string];
|
||||
@@ -2436,6 +2441,7 @@ declare module 'discord.js' {
|
||||
restSweepInterval?: number;
|
||||
retryLimit?: number;
|
||||
presence?: PresenceData;
|
||||
intents: BitFieldResolvable<IntentsString, number>;
|
||||
ws?: WebSocketOptions;
|
||||
http?: HTTPOptions;
|
||||
}
|
||||
@@ -2448,6 +2454,11 @@ declare module 'discord.js' {
|
||||
desktop?: ClientPresenceStatus;
|
||||
}
|
||||
|
||||
interface ClientUserEditData {
|
||||
username?: string;
|
||||
avatar?: BufferResolvable | Base64Resolvable;
|
||||
}
|
||||
|
||||
interface CloseEvent {
|
||||
wasClean: boolean;
|
||||
code: number;
|
||||
@@ -2571,10 +2582,6 @@ declare module 'discord.js' {
|
||||
User: typeof User;
|
||||
}
|
||||
|
||||
interface FetchIntegrationsOptions {
|
||||
includeApplications?: boolean;
|
||||
}
|
||||
|
||||
interface FetchMemberOptions {
|
||||
user: UserResolvable;
|
||||
cache?: boolean;
|
||||
@@ -2871,7 +2878,7 @@ declare module 'discord.js' {
|
||||
content?: StringResolvable;
|
||||
embed?: MessageEmbed | MessageEmbedOptions | null;
|
||||
code?: string | boolean;
|
||||
flags?: BitFieldResolvable<MessageFlagsString>;
|
||||
flags?: BitFieldResolvable<MessageFlagsString, number>;
|
||||
allowedMentions?: MessageMentionOptions;
|
||||
}
|
||||
|
||||
@@ -2999,13 +3006,13 @@ declare module 'discord.js' {
|
||||
|
||||
type OverwriteType = 'member' | 'role';
|
||||
|
||||
interface PermissionFlags extends Record<PermissionString, number> {}
|
||||
interface PermissionFlags extends Record<PermissionString, bigint> {}
|
||||
|
||||
interface PermissionObject extends Record<PermissionString, boolean> {}
|
||||
|
||||
interface PermissionOverwriteOption extends Partial<Record<PermissionString, boolean | null>> {}
|
||||
|
||||
type PermissionResolvable = BitFieldResolvable<PermissionString>;
|
||||
type PermissionResolvable = BitFieldResolvable<PermissionString, bigint>;
|
||||
|
||||
type PermissionString =
|
||||
| 'CREATE_INSTANT_INVITE'
|
||||
@@ -3193,9 +3200,9 @@ declare module 'discord.js' {
|
||||
|
||||
interface RawOverwriteData {
|
||||
id: Snowflake;
|
||||
allow: number;
|
||||
deny: number;
|
||||
type: OverwriteType;
|
||||
allow: string;
|
||||
deny: string;
|
||||
type: number;
|
||||
}
|
||||
|
||||
interface ReactionCollectorOptions extends CollectorOptions {
|
||||
@@ -3262,7 +3269,7 @@ declare module 'discord.js' {
|
||||
|
||||
type SystemChannelFlagsString = 'WELCOME_MESSAGE_DISABLED' | 'BOOST_MESSAGE_DISABLED';
|
||||
|
||||
type SystemChannelFlagsResolvable = BitFieldResolvable<SystemChannelFlagsString>;
|
||||
type SystemChannelFlagsResolvable = BitFieldResolvable<SystemChannelFlagsString, number>;
|
||||
|
||||
type SystemMessageType = Exclude<MessageType, 'DEFAULT' | 'REPLY'>;
|
||||
|
||||
@@ -3297,6 +3304,11 @@ declare module 'discord.js' {
|
||||
|
||||
type VoiceStatus = number;
|
||||
|
||||
type WebhookClientOptions = Pick<
|
||||
ClientOptions,
|
||||
'allowedMentions' | 'restTimeOffset' | 'restRequestTimeout' | 'retryLimit' | 'http'
|
||||
>;
|
||||
|
||||
interface WebhookEditData {
|
||||
name?: string;
|
||||
avatar?: BufferResolvable;
|
||||
@@ -3331,7 +3343,6 @@ declare module 'discord.js' {
|
||||
interface WebSocketOptions {
|
||||
large_threshold?: number;
|
||||
compress?: boolean;
|
||||
intents?: BitFieldResolvable<IntentsString> | number;
|
||||
properties?: WebSocketProperties;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/// <reference path="index.d.ts" />
|
||||
|
||||
import { Client, Message, MessageAttachment, MessageEmbed } from 'discord.js';
|
||||
import { Client, Intents, Message, MessageAttachment, MessageEmbed } from 'discord.js';
|
||||
|
||||
const client: Client = new Client();
|
||||
const client: Client = new Client({
|
||||
intents: Intents.NON_PRIVILEGED,
|
||||
});
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log(`Client is logged in as ${client.user!.tag} and ready!`);
|
||||
|
||||
Reference in New Issue
Block a user