0.11.2 • Published 2 years ago

@discordoo/providers v0.11.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

2 years ago

0.11.2

2 years ago

0.11.0

3 years ago

0.10.0

3 years ago

0.10.1

3 years ago

0.10.2

3 years ago

0.9.9

4 years ago

0.9.10

3 years ago

0.9.11

3 years ago

0.9.4

4 years ago

0.7.9

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.8.2

4 years ago

0.7.6

4 years ago

0.7.8

4 years ago

0.7.7

4 years ago

0.7.4-c

4 years ago

0.7.4-b

4 years ago

0.7.4

4 years ago