Cannot read property 'send' of undefined in discord.js

只愿长相守 提交于 2019-12-13 03:24:47

问题


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



来源:https://stackoverflow.com/questions/50976677/cannot-read-property-send-of-undefined-in-discord-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!