Skip to content

Latest commit

History

918 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

dfx

Discord

A Discord library built on top of effect

  • Supports both the gateway and webhooks
  • Simple yet powerful abstractions to build Discord bots

Example

import{NodeHttpClient,NodeRuntime,NodeSocket}from"@effect/platform-node"import{DiscordConfig,Ix}from"dfx"import{DiscordIxLive,InteractionsRegistry}from"dfx/gateway"import{Config,Effect,Layer}from"effect"// Create a layer for the discord servicesconstDiscordLayer=DiscordIxLive.pipe(Layer.provide([DiscordConfig.layerConfig({token: Config.redacted("DISCORD_BOT_TOKEN"),}),NodeHttpClient.layerUndici,NodeSocket.layerWebSocketConstructor,]),)// Create hello serviceconstHelloLayer=Layer.effectDiscard(Effect.gen(function*(){constregistry=yield*InteractionsRegistry// Create hello command that responds with "Hello!"consthello=Ix.global({name: "hello",description: "A basic command",},Effect.succeed({type: 4,data: {content: "Hello!",},}),)// register the command(s) and handle errorsyield*registry.register(Ix.builder.add(hello).catchAllCause(Effect.logError),)}),).pipe(// provide discord layerLayer.provide(DiscordLayer),)// Construct the main layerconstMainLive=Layer.mergeAll(// add your other services hereHelloLayer,)// run itNodeRuntime.runMain(Layer.launch(MainLive))

About

A Discord library for effect-ts

Resources

Stars

139 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages