Z
Z
Zodtv2019-06-06 20:37:10
JavaScript
Zodtv, 2019-06-06 20:37:10

How to stop discord.js message listener in node server?

How can I force the application to stop "listening" to user's discord messages under certain conditions?
To avoid misunderstandings, below is the listener initialization code

var Discord = require('discord.js');
const client = new Discord.Client();
client.on('message', async message =>{ //Тот самый злосчастный listener
//Некоторый код
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-06-06
@Zodtv

if Discord.Client inherits from EventEmitter then

const handler = async message => {
  // ...
};
client.on('message', handler);
client.removeEventListener('message', handler);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question