0.0.1-dev.1713308713958.96eb876 • Published 2 years ago

reaccord v0.0.1-dev.1713308713958.96eb876

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

Reaccord is a framework for creating discord bots with react.
It is built on top of the discord.js library and is designed to be easy to use.

Explore the docs...


Turn your react code into fully featured discord bots now!

Let's build a simple counter

What we will be building:

You can view the complete source code here.

Define your App's behavior, as you would do in a regular React webapp.

const Counter = ({ start = 0 }) => {
  const [count, setCount] = useState(start)

  return (
    <>
      {count}
      <Button onClick={() => setCount(count + 1)}>+</Button>
    </>
  )
}

Create end-user command.

const counterCommand = createSlashCommand("counter", "A simple counter")
  .intParam("start", "Number to start counting from")
  .render(({ start }) => <Counter start={start} />)

Instantiate the gateway client, and register the command.

const client = createClient({
  token: "bot-token",
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
  devGuildId: "dev-guild-id",
  clientId: "bot-client-id",
  commands: [counterCommand],
})

Connect the client to discord's gateway

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

Congratulations, now you can go ahead and try your brand new command!


0.0.0-dev

4 years ago

0.0.1-dev

4 years ago