@discordoo/providers
v0.11.2
Published
Interfaces that must be implemented by custom providers for Discordoo (typescript only).
Downloads
52
Readme
Providers
Repository for interfaces that must be implemented by custom providers for Discordoo (typescript only).
How to use
npm i @discordoo/providers
Example with cache provider
import { CacheProvider } from '@discordoo/providers'
class CustomCacheProvider implements CacheProvider {
constructor(client/*, some, options, for, cache, provider*/) {}
}
import { createApp, DefaultClientStack } from 'discordoo'
import { CustomCacheProvider } from 'your-custom-cache-provider'
interface CustomClientStack extends DefaultClientStack {
cache: CustomCacheProvider
}
const client = createApp<CustomClientStack>('discord-bot-token')
.cacheProvider(CustomCacheProvider/*, some, options, for, cache, provider*/)
.build()
client.internals.cache.provider.somethingCustom()
Example with gateway provider and custom events
import { GatewayProvider } from '@discordoo/providers'
class CustomGatewayProvider implements GatewayProvider {}
interface Command {
oh: boolean
}
interface CustomClientEvents {
slashCommand: (command: Command) => unknown
}
import { createApp, DefaultClientStack } from 'discordoo'
import { CustomGatewayProvider, CustomClientEvents } from 'your-custom-gateway-provider'
interface CustomClientStack extends DefaultClientStack {
gateway: CustomGatewayProvider
events: CustomClientEvents // overrides default client events
}
const client = createApp<CustomClientStack>('discord-bot-token')
.gatewayProvider(CustomGatewayProvider)
.build()
client.on('slashCommand', command => { // automatically detects the Command type
let oh = command.oh
oh = 'true' // Error: Type 'string' is not assignable to type 'boolean'.
})