Files
discordeno/website/docs/examples/node.md

1.2 KiB

sidebar_position, sidebar_label
sidebar_position sidebar_label
2 Using with Node.js

Using with Node.js

Discordeno supports Node.js by installing the @discordeno/bot package

Pre-Requirements

Before, going forward, please make sure to have finished everything on this list.

After you installed the @discordeno/bot package with npm, yarn, pnpm or bun you can start using it.

This is how you can use it to create a bot that logs into discord:

import 'dotenv/config'
import { createBot } from '@discordeno/bot'

const bot = createBot({
  token: process.env.token,
  desiredProperties: {
    user: {
      id: true,
    },
  },
  events: {
    ready: ({ shardId, user }) => console.log(`Shard ${shardId} ready, user id: ${user.id}`),
  },
})

await bot.start()

:::note For this example we will be using the env setup with dotenv :::

You are free to expand from this point with whatever code you want. Happy coding!