0.4.2 • Published 3 years ago

skycord v0.4.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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 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.

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();
0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago