M
M
matveyyyyyyyy2020-10-06 15:50:57
Node.js
matveyyyyyyyy, 2020-10-06 15:50:57

Problem with writing js bot using discord.js. Can you help?

Good afternoon. I'm learning how to create a discord bot. Faced a small problem. Previously, I surfed the Internet and came across an article with suggested materials for dummies. Everything is fine, but I decided to try my own, and entered a dead end ...

What I want: Teach the bot to respond to private messages on the discord. For example, if you text him "hello", he replies "darou". Below is the code I used. Gives an error that there is no "message". Help solve the problem, please.

const config = require('./config.json'); // Подключаем файл с параметрами и информацией
const Discord = require('discord.js'); // Подключаем библиотеку discord.js
const prefix = config.prefix; // «Вытаскиваем» префикс

// Команды //

function test(robot, mess, args) {
  mess.channel.send('**  Вот список команд:**')
}

var comms_list = [{
  name: "список",
  out: test,
  about: "Тестовая команда"
}]; 


if (message.channel.type === "dm") { // если тип канала === ЛС
  if (message.content === "привет") {
    message.channel.send("дароу")
  }
  ...
} 




// Name - название команды, на которую будет реагировать бот
// Out - название функции с командой
// About - описание команды 

module.exports.comms = comms_list;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-10-06
@matveyyyyyyyy

you must add this if statement to the body of the function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question