-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
112 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ackcord.katsstuff.net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
layout: docs | ||
title: Data objects | ||
--- | ||
|
||
# {{page.title}} | ||
|
||
Being a library for Discord is not always easy, especially for all the data | ||
objects AckCord has to handle. Keeping everything as case classes might seem | ||
simple at first, but also means an upfront cost of decoding the JSON, and the | ||
chance that the decoder is just wrong. It also makes it harder to evolve the | ||
library in a binary compatible way. | ||
|
||
To get around these issues, AckCord instead keeps the JSON around, decoding each | ||
field as needed. This does mean that if AckCord has the wrong types for a field, | ||
accessing it will throw an exception. It also means that you as the user can | ||
easily work around this issue until AckCord releases a new fixed version. | ||
|
||
## Selecting fields manually | ||
AckCord's data class field accessors generally call the function | ||
`DiscordObject#selectDynamic`. If a field is missing, or has the wrong type, | ||
nothing stops you as a user from calling this function yourself with the correct | ||
field name and type. | ||
|
||
## Retyping data | ||
Calling `asInstanceOf` on a data object is often an error. Instead, what you | ||
might want is `retype`. `asInstanceOf` casts the data object to a different | ||
class, failing if the data object is not an instance of that class. `retype` | ||
meanwhile reinterprets the data object as a different type. | ||
|
||
There are many uses of retyping data. The most common is that an object is | ||
all fields of `X`, in addition to fields `a`, `b` and `c`. This can be | ||
represented as a data object with accessors `a`, `b`, and `c`, and another | ||
accessor `x` which retypes the object to `X`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
layout: docs | ||
title: Requests | ||
--- | ||
|
||
# {{page.title}} | ||
|
||
Requests are how most bot actions are done. Stuff like sending messages, | ||
creating channels and managing users. AckCord represents every request as an | ||
object you construct. To run these requests, you need a `Requests` object, which | ||
is backed by sttp. The easiest way to get a `Requests` is using the one found | ||
through `BotSettings#requests`. The get the request object, you call a function | ||
to create it on an object defined in `ackcord.requests`. Which object it is in | ||
depends on what page in the discord docs the request appears on. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
layout: docs | ||
title: Snowflake types | ||
--- | ||
|
||
# {{page.title}} | ||
Unlike other Discord libraries, AckCord doesn't have one specific snowflake type, | ||
instead it uses a type `Snowflake[A]` to refer to something of type `A`. | ||
Most of these types also have aliases, like `UserId` being an alias | ||
for `Snowflake[User]`. | ||
|
||
## Converting to snowflake | ||
To convert a long or string(prefer string) to a snowflake, use the apply method | ||
on the companion object. For example: `UserId(0L)` | ||
|
||
You can also use this to "cast" one snowflake type to another. | ||
For example: `RoleId(guildId)`. | ||
|
||
## Raw snowflakes | ||
In some cases it's not possible to give a concrete type to the snowflake. | ||
In those cases `RawSnowflake` is used instead, an alias for `SnowflakeType[Any]`. | ||
In most cases you'll have to cast this to what you need yourself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
layout: home | ||
title: "AckCord" | ||
--- | ||
|
||
{% assign versions = site.data.versions %} | ||
|
||
# AckCord | ||
*You do what you want, exactly how you want it.* | ||
|
||
AckCord is a Scala Discord library, powered by sttp. AckCord's focus is on | ||
letting you choose the level of abstraction you want, without sacrificing speed. | ||
Want to work with the raw events from the gateway? Works for that. Maybe you | ||
don't want to bother with any of the underlying implementation and technicalities. | ||
Works for that too. Only interested in the REST requests? Pull in that module | ||
and ignore the rest. AckCord is fast, modular, and clean, focusing on | ||
letting you write good code. | ||
|
||
Add AckCord to your project by adding these statements to your `build.sbt` file. | ||
```scala | ||
libraryDependencies += "net.katsstuff" %% "ackcord" % "{{versions.ackcord}}" | ||
``` | ||
|
||
# More information | ||
For more information, either see the the examples or the ScalaDoc. | ||
|
||
Or you can just join the Discord server (we got cookies). | ||
|
||
[](https://discord.gg/5UH627u) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
options: | ||
- title: AckCord's data objects | ||
url: docs/data_objects.html | ||
|
||
- title: Requests | ||
url: docs/requests.html | ||
|
||
- title: Snowflake types | ||
url: docs/snowflakes.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ackcord: "2.0.0.0-M1" |