UNPKG

darkcord

Version:

A NodeJS Package to interact with Discord API

166 lines 4.84 kB
/// <reference types="node" /> import { CacheManager } from "../cache/CacheManager"; import { ClientUser } from "../resources/User"; import { BaseClientOptions, ClientEvents, ClientOptions, InteractionClientEvents, InteractionClientOptions } from "../types/index"; import { ApplicationFlags, GatewayIntentBits, GatewayPresenceUpdateData } from "discord-api-types/v10"; import EventEmitter from "node:events"; import { WebServer } from "@darkcord/interactions"; import { Rest } from "@darkcord/rest"; import { ChannelDataManager } from "../manager/ChannelDataManager"; import { DataCache } from "../manager/DataManager"; import { EmojiDataManager } from "../manager/EmojiDataManager"; import { GuildDataManager } from "../manager/GuildDataManager"; import { ClientRoles } from "../manager/RoleDataManager"; import { UserDataManager } from "../manager/UserDataManager"; import { ThreadChannel } from "../resources/Channel"; import { PluginManager } from "../utils/PluginManager"; import { ClientApplication } from "../resources/Application"; import { WebSocket } from "./WebSocket"; export declare interface BaseClient<E extends Record<string, any>> { on<T extends keyof E>(event: T, listener: (...args: E[T]) => any): this; on(event: keyof E, listener: (...args: any[]) => any): this; once<T extends keyof E>(event: T, listener: (...args: E[T]) => any): this; once(event: keyof E, listener: (...args: any[]) => any): this; emit<T extends keyof E>(event: T, ...args: E[T]): boolean; emit(event: keyof E, ...args: any[]): boolean; } export declare class BaseClient<E> extends EventEmitter { /** Client rest to make requests */ rest: Rest; /** * Client options */ options: BaseClientOptions; /** * Application of this client */ application: ClientApplication | null; /** * Client has ready */ isReady: boolean; /** * Time that the bot was ready */ readyAt: number; constructor(options?: BaseClientOptions); /** * Decorator to listen event * @param event the event for target * @returns */ listen(event: keyof E): (target: any, name: any) => void; connect(): void; } export declare class InteractionClient extends BaseClient<InteractionClientEvents> { publicKey: string; webserver: WebServer; options: InteractionClientOptions; cache: CacheManager; user: ClientUser | null; /** * Channels cache */ channels: ChannelDataManager; /** * Client guilds */ guilds: GuildDataManager; /** * Client roles */ roles: ClientRoles; /** * Client emojis */ emojis: EmojiDataManager; /** * Client threads */ threads: DataCache<ThreadChannel>; /** * Client users */ users: UserDataManager; constructor(publicKey: string, options?: InteractionClientOptions); connect(): Promise<void>; } export declare class Client extends BaseClient<ClientEvents> { /** * Client token */ token: string; options: Required<Omit<ClientOptions, "gateway"> & { gateway: Omit<Required<ClientOptions["gateway"]>, "intents"> & { intents: GatewayIntentBits; }; }>; /** * Client application id */ applicationId: string; /** * Client application flags */ applicationFlags: ApplicationFlags; /** * The client cache */ cache: CacheManager; /** * Client websocket manager for shards */ websocket: WebSocket; /** * Client user */ user: ClientUser | null; /** * Plugin manager for library plugins */ pluginManager: PluginManager; /** * Channels cache */ channels: ChannelDataManager; /** * Client guilds */ guilds: GuildDataManager; /** * Client roles */ roles: ClientRoles; /** * Client emojis */ emojis: EmojiDataManager; /** * Client threads */ threads: DataCache<ThreadChannel>; /** * Client users */ users: UserDataManager; constructor(token: string, options: ClientOptions); connect(): Promise<void>; disconnect(): void; /** * Sets the status of the client user. * @param data Status payload * @returns */ setStatus(data: Partial<GatewayPresenceUpdateData>): Partial<GatewayPresenceUpdateData>; /** * Sets the status of the client user in specified shard. * @param data Status payload * @returns */ setShardStatus(shardId: string | number, data: Partial<GatewayPresenceUpdateData>): { shardId: string | number; status: Partial<GatewayPresenceUpdateData>; }; get shards(): import("../index").Cache<GatewayShard>; } //# sourceMappingURL=Client.d.ts.map