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