0.0.1-dev.1658762778627.91cef25 • Published 4 years ago

reaccord v0.0.1-dev.1658762778627.91cef25

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

A simple, and clean framework to build discord apps declaratively using React + JSX and Discord.js.

Explore the docs...

Basic Usage

import { Client, GatewayIntentBits, ChatInputCommand } from "reaccord"

// Instantiate gateway client
const client = new Client({
    token: "your-discord-token",
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
    devGuildId: "dev-guild-id",
    clientId: "client-id",
})

// Create a simple `ping` command
const ping = new ChatInputCommand("ping", "Ping").render(() => (
    <content>Pong</content>
))

// Register the command
client.registerCommand(ping)

// Connect client
client.connect((client) =>
    console.log(`🚀 Client connected as ${client.user?.username}!`),
)

Result

A few more examples

Echo command with a required string parameter

const echo = new ChatInputCommand("echo", "Echoes msg")
    .stringParam("input", "Message to be echoed", { required: true })
    .render(({ input }) => <content>{input}</content>)

client.registerCommand(echo)

Result

Add command with two optional number parameters

const add = new ChatInputCommand("add", "Add two numbers")
    .numberParam("a", "First number")
    .numberParam("b", "Second number")
    .render(({ a = 0, b = 0 }) => (
        <embed>
            <title>Result: {a + b}</title>
            <desc>
                {a} + {b}
            </desc>
        </embed>
    ))

client.registerCommand(add)

Result

0.0.0-dev

4 years ago

0.0.1-dev

4 years ago