What's the best approach for running a discord bot within a wasp app?
here's an example
// Require the necessary discord.js classesconst { Client, Events, GatewayIntentBits } = require('discord.js');const { token } = require('./config.json');// Create a new client instanceconst client = new Client({ intents: [GatewayIntentBits.Guilds] });// When the client is ready, run this code (only once).// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.// It makes some properties non-nullable.client.once(Events.ClientReady, readyClient => { console.log(`Ready! Logged in as ${readyClient.user.tag}`);});// Log in to Discord with your client's tokenclient.login(token);
// Require the necessary discord.js classesconst { Client, Events, GatewayIntentBits } = require('discord.js');const { token } = require('./config.json');// Create a new client instanceconst client = new Client({ intents: [GatewayIntentBits.Guilds] });// When the client is ready, run this code (only once).// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.// It makes some properties non-nullable.client.once(Events.ClientReady, readyClient => { console.log(`Ready! Logged in as ${readyClient.user.tag}`);});// Log in to Discord with your client's tokenclient.login(token);
Basically the concept of having a long lived service running within the wasp app that can respond to events as they come in (like discord slash commands or activity in a channel)
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
W
Wasp
Rails-like framework for React, Node.js and Prisma. Build your app in a day and deploy it with a single CLI command.