Create a file for a discord bot

Hey everyone,

I trying to dev a discord bot, but I don’t know where to write my code, I mean I want to create a file call “DiscordBot.js” and then listen events from my discord server

I have already write the code in the bootstrap.js and it works, but I don’t know if this is a good practice :

config>functions>bootstrap.js :

const Discord = require('discord.js.old');
const client = new Discord.Client();

module.exports = async () => {
  client.once('ready', () =>{

the console write well hello

You can make your own file anywhere you want then import it :slight_smile: bootstrap.js is to fire when the server starts up.

Any reason why you want it in strapi itself?

hey Eventyret, thanks for your awnser, so this is not a bad practice to use my discord logic inside the bootstrap file ?

and I need to use it with strapi because I need user permission services from strapi, the goal of my bot is to first of all link the strapi user with the discord user Id and then kick the user when his premium subscription is over, I have to link 3 API aha

It’s bad practice to write your logic inside bootstrap.
You want to make a separate file anywhere, then export functions or methods. And use them inside bootstrap.js You can also use events.
Like create an endpoint that when receiving a post request will trigger your functions etc :slight_smile: