the problem with the bot gives an error!

Question:
What should I change in the code so that the discord bot starts working?

Current behavior:
Nothing happens. Gives an error message.

Desired behavior
I want him to randomly name one of 2 words.

Repl link:
https://replit.com/@SMokki381YT/Wirus-kott#server.js

const Discord = require("discord.js")
//const fetch = require("node-fetch")
const keepAlive = require("./server")

const bot = new Discord.Client()
const id ="!";

bot.on("ready", () => {
  console.log(`Бот от Wirus kott запущен с ником ${bot.user.tag}!`)
})

bot.on("message", msg => {
  if (msg.author.bot || !msg.content.slice(id)) return;
  const args = msg.content.slice(id.length).split(/ +/);
  const cmd = args.shift().toLowrCase();

if (cmd === "wirus" || cmd === "вирус") {
  var random = Math.floor(Math.random()*2)+1
  msg.channel.send("Вирус отправился в путь..")
  switch(random) {
    case 1:
      msg.channel.send("Вирус добрался до точки назначения!")
      break;
      case 2:
      msg.channel.send("Вирус добрался исчез на пол пути!")
      break;
  }
}

keepAlive()
bot.login(process.env.TOKEN)

server
const express = require("express")
const server = express()

server.all("/", (req, res) => {
  res.send("Бот запускается")
})

function keepAlive() {
  server.listen(3000, () => {
    console.log("Сервер готов")
  })
}

module.exporrts = keerAlive

Hello @SMokki381YT and welcome to the community!

There are several errors, I’ll try enlist them.

There’s no condition to check if the message starts with the command prefix ('!') before processing the command.

Typo here: module.exporrts .
Typo here: .toLowrCase()
Typo here: keerAlive

Also, keepAlive() should not be inside the bot.on('message') event. It should be called independently.

3 Likes

If you haven’t grasped JavaScript, first see before you begin.