Bookcliff / discord-bot-gm

MIT License
0 stars 0 forks source link

NextBot: Serverless Discord Bot with Next.js

Serverless Discord bot using Discord's slash commands webhook and Next.js.

Demo GIF

Try it out

Discord Invite

Join https://discord.gg/NmXuqGgkb3 and use one of the available slash commands.

Or, add NextBot to your own server: https://discord.com/api/oauth2/authorize?client_id=837427503059435530&permissions=2147483648&scope=bot%20applications.commands

You can also send slash commands through DM the bot once you're in a mutual server with the bot!

An accompanying static web app also shows the registered commands: https://nextjs-discord-bot.vercel.app/

Technologies

Development

Requires a Node.js version that can run Next.js.

Setup

Follow the one-time setup as follows:

await createGlobalCommand({
  name: "randompic",
  description: "Get a random picture",
  options: [
    {
      name: "type",
      description: "What type of picture would you like?",
      type: 3,
      required: true,
      choices: [
        { name: "cat", value: "cat" },
        { name: "dog", value: "dog" },
        { name: "generic", value: "picsum" },
      ],
    },
  ],
})

await createGlobalCommand({
  name: "ping",
  description: "Ping pong! I'll respond with pong.",
})

You could also make the request via Postman, curl, etc. but I'm lazy

Local Development

Deploy on Vercel

Deploy with Vercel

After deploying, add <YOUR_VERCEL_URL>/api/interactions as the Interactions Endpoint URL in your Discord app.