ClientAdapter

extendsEmitter<AdapterEvents<M>>
implementsAdapterResult<C, M>

Description

Adapts a messaging interface so a Bot can understand it

Example

class Adapter extends ClientAdapter {
  protected register(options, hooks) {
    // Client refers to anything that exposes a messaging interface
    const client = new Client(options)

    client.on("message", hooks.message)
    client.on("ready", hooks.ready)
    client.on("resume", hooks.ready)
    client.on("disconnect", hooks.unready)
    client.on("error", hooks.error)

    return {
      client,
      methods: {
        start: async () => client.start(),
        getMessageContent: (message) => message
      }
    }
  }
}

const adapter = new Adapter(options)
const bot = new Bot({ adapter, ... })

Generics

M
Message
C
Client
CO
Client options

Constructor

new ClientAdapter(options)

Parameters

options:
CO

Properties

client:
C
methods:
unknown type

Methods

register(options, hooks)AdapterResult<C, M>
Parameters
options:
CO
hooks:
AdapterHooks<M>