Cannot read property 'send' of undefined i

2019-09-02 05:51发布

问题:

So im trying to code a discord bot that sends the name and id of every message in every channel to the Admin channel, but it says it cant read the property of send? Any Ideas?(Im more or less new to javascript,but i understand the basics of discord.js)

    bot.on('message',(message) =>{
bot.channels.get(459435599850504212).send(message.author.tag + ' ' + message.author.id)})

I know it would answer itself in a loop,but i just want to fix the send.

回答1:

The channel id should be in quotes.

bot.channels.get('459435599850504212')

Seeing as ids for Discord.js aren't integers, if you are getting/finding data make sure you wrap it in quotes