https://github.com/s5bug/discocat
Mirror of https://gitlab.com/dscala/discocat
https://github.com/s5bug/discocat
Last synced: 5 months ago
JSON representation
Mirror of https://gitlab.com/dscala/discocat
- Host: GitHub
- URL: https://github.com/s5bug/discocat
- Owner: s5bug
- License: other
- Created: 2019-05-06T03:59:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-02T03:18:21.000Z (over 5 years ago)
- Last Synced: 2025-01-07T22:51:35.284Z (6 months ago)
- Language: Scala
- Size: 55.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://www.codacy.com/app/srn/discocat?utm_source=github.com&utm_medium=referral&utm_content=sorenbug/discocat&utm_campaign=Badge_Grade)
[](https://sonarcloud.io/dashboard?id=sorenbug_discocat)
[](https://libraries.io/github/sorenbug/discocat)
[](https://www.gnu.org/licenses/lgpl-3.0.en.html)
[](https://discord.gg/TQZ5Brw)# discocat
Discocat is a Scala library that provides access to Discord's API built around [cats](https://typelevel.org/cats/) and [fs2](https://fs2.io/). It is under the LGPL v3.
## What this license means for you
It means:
- When making changes to this library, they have to be made completely public.
- When making a bot, either:
- The bot's source must be made completely public.
- The bot must be able to display its usage of this library.
## ExamplesAll examples are written in terms of `IOApp` and `program[F[_]]`. These implicits are needed:
- `AsynchronousChannelGroup`
- `ConcurrentEffect[F]`
- `ContextShift[F]`
- `Timer[F]`### Ping
A simple `!ping` -> `Pong` bot:
```scala
for {
t <- Sync[F].delay(StdIn.readLine("Token? "))
c <- Client[F](t)
l <- c
.login(
EventHandler[F] {
case MessageCreate(_, m) =>
if (m.content == "!ping") {
c.request.post(s"channels/${m.channelId}/messages", Nil, Map("content" -> "Pong!")).drain
} else {
Stream.empty
}
}
:: Defaults.defaultEventHandler[F]
:: Nil
)
.compile
.drain
} yield l
```