D-rex is a discord framework built on the harmony framework with ease of use and simplisity in mind
// deno run --allow-net --allow-env --allow-read bot.ts
import 'https://deno.land/x/dotenv/load.ts';
// import { app, type } from '../mod.ts';
import { app, type } from 'https://deno.land/x/drex/mod.ts';
// creates client with prefixes ~ and ^
const client = app(['~', '^']);
// changes prefix to ~
client.prefixes = ['~'];
// runs on every message sent
client.hook(message => {
message.reply('hello there');
});
// runs every time someone sends ~ping <user> or ^ping <user>
client.command({
name: 'ping',
aliases: ['p'],
params: [
{
name: 'user',
type: type.Member,
},
],
handler: async (msg, args) => {
msg.reply(
`pong! ${(await client.member(args.user, msg.guild))?.toString()}`
);
},
});
client.listen(Deno.env.get('TOKEN'));app(prefixes);| Parameter | Type | Description |
|---|---|---|
prefixes |
string[] |
Required. List of prefixes for the bot |
client.command({name, [aliases], [params], handler})| Parameter | Type | Description |
|---|---|---|
name |
string |
Required. Name of the commad |
handler |
func |
Required. Function to run on command activated |
aliases |
string[] |
List of aliases for the command |
params |
Param[] |
List of param objects to require |
runs on every command
client.hook(hook);| Parameter | Type | Description |
|---|---|---|
hook |
func |
Required. Function that gets the message object being sent |
runs on every command
client.listen(apiToken);| Parameter | Type | Description |
|---|---|---|
apiToken |
string |
Required. Api token |
- Decorators support
- class based clients
- Porting to a custom client libary
- Building a support discord server
For support, email okirshen@gmail.com.