A discord.js v13 bot set up for replit
const { Client, Message, MessageEmbed } = require('discord.js')
const client = new Client({
partials: ["MESSAGE", "CHANNEL", "REACTION"],
intents: 32767,
});
const config = require('./config.json')
const prefix = config.prefix
const token = config.token
client.on("ready", () => {
console.log(`${client.user.tag} is ready!`)
client.user.setActivity(`${prefix}help ~ test`)
});
client.login(token)
Create a config.json file for the prefix.
Add a new environment secret for the bot token.
Execute this script on the shell to install node.js v16:
npm init -y && npm i --save-dev node@16 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH
Create a .replit
file to execute node from the shell instead of the console.
run = "npm start"
Now, add a code to package.json
file
"scripts": {
"start": "node ."
}
If you had packages like discord.js v12 or sqlite before,please reinstall them.
npm uninstall discord.js && npm i discord.js
You can run the code now!