@discordoo/providers
TypeScript icon, indicating that this package has built-in type declarations

0.11.2 • Public • Published

Discord bots. Simplified and boosted · Docs · Contribute

Online


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'.
})

Readme

Keywords

none

Package Sidebar

Install

npm i @discordoo/providers

Weekly Downloads

10

Version

0.11.2

License

MIT

Unpacked Size

82.9 kB

Total Files

102

Last publish

Collaborators

  • mirdukkk