Skip to content

PyroTechniac/core

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
This branch is 9 commits ahead, 184 commits behind dirigeants:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@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

import { Client, ClientEvents, Message } from '@klasa/core';
import * as config from './config.json';

const client = new Client()
	.on(ClientEvents.MessageCreate, async (message: Message): Promise<void> => {
		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

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

About

Discord API library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%