billzabob / dissonance

A Discord framework for Scala

Version Matrix

Dissonance

A Discord framework for Scala

// available for 2.12, 2.13
libraryDependencies += "com.github.billzabob" %% "dissonance" % "version"

Example

import cats.effect._
import dissonance.data._
import dissonance.data.events._
import dissonance.Discord

object Main extends IOApp {
  override def run(args: List[String]): IO[ExitCode] =
    Discord.make(args.head).use { discord =>
      discord
        .subscribe(Shard.singleton, Intent.GuildMessages)
        .evalMap {
          case MessageCreate(BasicMessage(_, "ping", _, channelId)) =>
            discord.client.sendMessage("pong", channelId).void
          case _ => IO.unit
        }
        .compile
        .drain
        .as(ExitCode.Success)
    }
}