@alan404/discordjsx
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@alan404/discordjsx

Allows you to use React/JSX in your discord.js projects

Examples in examples folder

Normal react hooks DO work, such as useState and useEffect.

Installation

pnpm add @alan404/discordjsx

or if you are old:

npm i @alan404/discordjsx

Usage

import { createJSXRenderer } from "@alan404/discordjsx"; 

createJSXRenderer(client, <Test />, async (msg) => {
    // send msg by either of these methods:
    await interaction.editReply(msg);
    await message.channel.send(msg);
    // etc.
});

createJSXRenderer

createJSXRenderer(
    discordClient: Discord.Client,
    component: React.ReactNode,
    updateMessage: (message) => void,
)

Elements

  • <msg>: Message
  • <embed title="" color="">: An embed
  • <row>: Action Row

Buttons!

Define a button:

<button id="a">
    Hi
</button>

You can also add a callback!

<button onClick={...}>
    Hi
</button>

Notes

please dont use this abomination in prod

todo: select menus

Readme

Keywords

Package Sidebar

Install

npm i @alan404/discordjsx

Weekly Downloads

4

Version

0.1.0

License

LICENSE

Unpacked Size

56.3 kB

Total Files

10

Last publish

Collaborators

  • alan404