0.11.2 • Published 7 months ago

@discordoo/providers v0.11.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months 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

10 months ago

0.11.2

7 months ago

0.11.0

2 years ago

0.10.0

2 years ago

0.10.1

2 years ago

0.10.2

2 years ago

0.9.9

2 years ago

0.9.10

2 years ago

0.9.11

2 years ago

0.9.4

3 years ago

0.7.9

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.8.2

3 years ago

0.7.6

3 years ago

0.7.8

3 years ago

0.7.7

3 years ago

0.7.4-c

3 years ago

0.7.4-b

3 years ago

0.7.4

3 years ago