Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s5bug/discocat
Mirror of https://gitlab.com/dscala/discocat
https://github.com/s5bug/discocat
Last synced: 1 day 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 (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-02T03:18:21.000Z (almost 5 years ago)
- Last Synced: 2024-11-10T16:12:41.071Z (about 2 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://img.shields.io/codacy/grade/8a52090e000f44d0b99f8fcdf80b6cff.svg?style=flat-square)](https://www.codacy.com/app/srn/discocat?utm_source=github.com&utm_medium=referral&utm_content=sorenbug/discocat&utm_campaign=Badge_Grade)
[![](https://img.shields.io/sonar/https/sonarcloud.io/sorenbug_discocat/violations.svg?format=long&style=flat-square)](https://sonarcloud.io/dashboard?id=sorenbug_discocat)
[![](https://img.shields.io/librariesio/github/sorenbug/discocat.svg?style=flat-square)](https://libraries.io/github/sorenbug/discocat)
[![](https://img.shields.io/github/license/sorenbug/discocat.svg?style=flat-square)](https://www.gnu.org/licenses/lgpl-3.0.en.html)
[![](https://img.shields.io/discord/390751088829005826.svg?style=flat-square)](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
```