pkgs/rest/README.md (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# @purrkit/rest
fully typesafe discord rest client
```ts
import { RESTClient } from "../src";
const client = RESTClient({ token: "..." });
const user = await client.users.me.get();
if (user.ok) {
console.log(user.data.username); // (property) data: UserPIIResponse
} else {
console.error(user.data.message); // (property) data: RatelimitedResponse | ErrorResponse
}
const guild = await client.guilds("1359315933797285948").channels.get();
if (guild.status === 200) {
console.log(guild.data); // (property) data: (GuildChannelResponse | PrivateChannelResponse | PrivateGroupChannelResponse | ThreadResponse)[] | null
} else if (guild.status === 429) {
console.log(guild.data.retry_after); // (property) data: RatelimitedResponse
} else if (!guild.ok) {
console.log(guild.data.message); // (property) data: ErrorResponse
}
```
## copying
this project is licensed under the european union public license (eupl) v1.2.
you can find the full license text either [here][LISC] or on the official
[eupl website][EU], which also contains translations of the license in various
languages.
<!-- links -->
[LISC]: ./LICENSE
[EU]: https://interoperable-europe.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|