Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dirigeants/core
Discord API library
https://github.com/dirigeants/core
Last synced: 22 days ago
JSON representation
Discord API library
- Host: GitHub
- URL: https://github.com/dirigeants/core
- Owner: dirigeants
- License: mit
- Archived: true
- Created: 2018-10-19T22:35:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T07:18:47.000Z (almost 2 years ago)
- Last Synced: 2024-07-31T20:44:34.161Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 17.4 MB
- Stars: 28
- Watchers: 3
- Forks: 9
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- discord-api-libs - core - Discord API library (Libraries / TypeScript)
README
# @klasa/core
This is an early alpha discord library which will be the future core of the Klasa Bot framework. This implements a high-level stateful interface over @klasa/rest and @klasa/ws. You are bound to come across missing or broken code/types using this alpha library. (I even found some unintended types while writing this!) Please make issues and pull requests to further the development.Simple ping client in typescript
```typescript
import { Client, ClientEvents, Message } from '@klasa/core';
import * as config from './config.json';const client = new Client()
.on(ClientEvents.MessageCreate, async (message: Message): Promise => {
if (message.author.bot) return;
if (message.content.toLowerCase().startsWith('ping')) {
const [response] = await message.channel.send(mb => mb.setContent('ping?'));
await response.edit(mb => mb.setContent(`Pong! Took: ${response.createdTimestamp - message.createdTimestamp}ms`));
}
});client.token = config.token;
client.connect();
```Simple ping client in javascript
```javascript
const { Client } = require('@klasa/core');
const { token } = require('./config.json');const client = new Client()
.on('messageCreate', async (message) => {
if (message.author.bot) return;
if (message.content.toLowerCase().startsWith('ping')) {
const [response] = await message.channel.send(mb => mb.setContent('ping?'));
return response.edit(mb => mb.setContent(`Pong! Took: ${response.createdTimestamp - message.createdTimestamp}ms`));
}
});client.token = token;
client.connect();
```