Discord bots. Simplified and boosted · Docs · Contribute
Repository for interfaces that must be implemented by custom providers for Discordoo (typescript only).
npm i @discordoo/providers
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()
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'.
})