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.
pnpm add @alan404/discordjsx
or if you are old:
npm i @alan404/discordjsx
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(
discordClient: Discord.Client,
component: React.ReactNode,
updateMessage: (message) => void,
)
-
<msg>
: Message -
<embed title="" color="">
: An embed -
<row>
: Action Row
Define a button:
<button id="a">
Hi
</button>
You can also add a callback!
<button onClick={...}>
Hi
</button>
please dont use this abomination in prod
todo: select menus