joey dibbs
joey dibbs

Reputation: 131

Problem defining typingStart to a specific channel

I am trying to get my discord bot to send this message only if the user starts typing in the defined channel, and not other text channels. I don't get any errors, the bot just doesn't send a message. What am I doing wrong here? Can typingStart be defined to a specific channel?

const Join2_channel =  "972135774921247676"

bot.on("typingStart", (message , channel) => {
   if (channel.id === Join2_channel) {
      message.send('Type !join');
   }
});

Upvotes: 2

Views: 229

Answers (1)

Zsolt Meszaros
Zsolt Meszaros

Reputation: 23160

The typingStart event takes two parameters; channel (the channel the user started typing in) and user (that started typing), in this order.

In your current code you're checking if the user.id is 972135774921247676 and as that's a channel's snowflake, it won't match. You need to update your callback function:

bot.on("typingStart", (channel, user) => {
  if (channel.id === Join2_channel) {
      channel.send('Type !join');
   }
});

Upvotes: 1

Related Questions