Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skycord/skycord
https://github.com/skycord/skycord
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/skycord/skycord
- Owner: skycord
- License: mit
- Created: 2021-05-06T13:07:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-25T18:53:31.000Z (over 3 years ago)
- Last Synced: 2024-05-16T11:22:41.091Z (8 months ago)
- Language: TypeScript
- Size: 176 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- discord-api-libs - skycord - (Libraries / TypeScript)
README
# Skycord
A low-level Discord API wrapper written in TypeScript.## Installation
To install the library, all you need to do is run the corresponding command.
- For npm: `npm install --save skycord`
- For yarn: `yarn add skycord`## Examples
### Example Ping-pong Bot (TypeScript)
Note: This example is using TypeScript, so the [discord-api-types](https://github.com/discordjs/discord-api-types) package is used as typings for the events. If you want to run this example without modifications, you need to install the `discord-api-types` package.
```ts
import { Client, LocalRestClient, RestRoutes } from 'skycord';
import { GatewayMessageCreateDispatchData } from 'discord-api-types';const client = new Client({
token: 'your bot token here',
});// Initialize the rest client (must be done before the gateway client)
client.initializeNewRestClient(LocalRestClient);// Initialize the gateway client
client.initializeNewGatewayClient();// On message received
client.gateway.on('MESSAGE_CREATE', async (messageCreate: GatewayMessageCreateDispatchData) => {
// If the message is "!ping"
if (messageCreate.content === '!ping') {
// Send a message containing "Pong!"
await client.rest.request(RestRoutes.CHANNEL_MESSAGES(messageCreate.channel_id), {
method: 'post',
data: {
content: 'Pong!',
},
});
}
});// Connect to the gateway
client.gateway.connect();
```