import { AxiosInstance } from "axios"; import * as Rx from "rxjs"; import { PartialInvite } from "./caches/invites"; import * as CacheStore from "./caches/stores"; import { CacheStoreFactory, NonParentCacheStoreFactory } from "./caches/stores"; import * as GatewayClient from "./gateway/client"; import * as RL from "./rate-limits/rxjs"; import * as Store from "./rate-limits/store"; import * as RestClient from "./rest/client"; import { Application, Channel, Emoji, Guild, GuildMember, Message, Role, StageInstance } from "./types"; export { createHandler as createProxyHandler } from "./rest/proxy"; export interface RESTClient extends RestClient.Routes { /** * Observable of side effects. It is required that you subscribe to this for * the client to function. */ effects$: Rx.Observable; debug$: Rx.Observable; request: AxiosInstance["request"]; get: AxiosInstance["get"]; post: AxiosInstance["post"]; patch: AxiosInstance["patch"]; put: AxiosInstance["put"]; delete: AxiosInstance["delete"]; } export declare function createRestClient(opts: RestClient.Options): RESTClient; export declare const createProxyClient: (baseURL: string) => RESTClient; export interface Options { /** The discord bot token */ token: string; /** * You can supply a custom `RateLimitStore.Store` interface here to change how * rate limit counters and bucket information are stored. * * Defaults to a memory store implementation. */ rateLimitStore?: Store.Store; /** Gateway configuration */ gateway?: Omit; /** REST API configuration */ rest?: Omit; } export declare function create({ token, rateLimitStore, rest: restOptions, gateway: gatewayOptions, }: Options): Client; export type Client = RESTClient & ClientExtras; export interface ClientExtras { gateway: GatewayClient.Client; /** Observable of all the dispatch events */ dispatch$: GatewayClient.Client["dispatch$"]; /** Helper function to listen to an individual dispatch event */ fromDispatch: GatewayClient.Client["fromDispatch"]; /** Helper function to listen to an individual dispatch event */ latestDispatch: GatewayClient.Client["latestDispatch"]; /** * Helper function to listen to an individual dispatch event, along with * the shard */ fromDispatchWithShard: GatewayClient.Client["fromDispatchWithShard"]; /** Cache of the latest application */ applicationCache: NonParentCacheStoreFactory; /** Cache of the latest direct messages for each guild */ directMessagesCache: NonParentCacheStoreFactory; /** Cache of the latest guilds */ guildsCache: NonParentCacheStoreFactory; /** Cache of the latest roles for each guild */ rolesCache: CacheStoreFactory; /** Cache of the latest channels for each guild */ channelsCache: CacheStoreFactory; /** Cache of the latest members for each guild */ membersCache: CacheStoreFactory; /** Cache of the latest messages for each guild */ messagesCache: CacheStoreFactory; /** Cache of the latest emojis for each guild */ emojisCache: CacheStoreFactory; /** Cache of the latest invites for each guild */ invitesCache: CacheStoreFactory; /** Cache of the latest stageInstances for each guild */ stageInstancesCache: CacheStoreFactory; /** Create your own cache store from a watcher observable */ cacheFromWatch: typeof CacheStore.fromWatch; /** Create your own cache store with parent ids from a watcher observable */ nonParentCacheFromWatch: typeof CacheStore.fromWatchNonParent; /** Add cache helpers to a cache store */ addCacheHelpers: typeof CacheStore.addHelpers; /** Add cache helpers to a non parent cache store */ addNonParentCacheHelpers: typeof CacheStore.addNonParentHelpers; /** * RxJS operator that appends cached data to the stream. E.g. * * ```typescript * client.dispatch$("GUILD_MEMBER_ADD").pipe( * client.withCaches({ * roles: rolesCache, * })(({ message }) => message.guild_id), * ); * ``` */ withCaches: typeof CacheStore.withCaches; /** * Use this operator in combination with withCaches. * It will filter out any direct messages etc. * * ``` * client.dispatch$(Events.GuildMemberAdd).pipe( * client.withCaches({ * roles: rolesCache, * })(({ message }) => message.guild_id), * client.onlyWithCacheResults(), * ); * ``` */ onlyWithCacheResults: typeof CacheStore.onlyWithCacheResults; /** * RxJS rate limit operator, which is backed by the store. */ rateLimit: RL.RateLimitOp; /** * Subscribe to this observable to enable debug logging */ debug$: Rx.Observable; }