admin管理员组文章数量:1392007
I'm trying to make my bot to wait for a direct message in this case some name and write it back to same user in direct message in this case me.
I try to use message.author.awaitMessages
but console return:
TypeError: message.author.awaitResponse is not a function
message.author.send('Write your Name')
.then(function(){
message.channel.awaitMessages(response => message.content, {
max: 1,
time: 300000000,
errors: ['time'],
})
.then((collected) => {
message.author.send(`Your Name is: ${collected.first().content}`);
})
.catch(function(){
message.channel.send('You didnt write your name');
});
});
}
I'm trying to make my bot to wait for a direct message in this case some name and write it back to same user in direct message in this case me.
I try to use message.author.awaitMessages
but console return:
TypeError: message.author.awaitResponse is not a function
message.author.send('Write your Name')
.then(function(){
message.channel.awaitMessages(response => message.content, {
max: 1,
time: 300000000,
errors: ['time'],
})
.then((collected) => {
message.author.send(`Your Name is: ${collected.first().content}`);
})
.catch(function(){
message.channel.send('You didnt write your name');
});
});
}
Share
Improve this question
asked Dec 8, 2017 at 21:43
Philip ScotPhilip Scot
3012 gold badges3 silver badges12 bronze badges
1
-
While calling the message.author.send can you confirm that
message
is definately the variable and it's notmsg
? Discord.js hello world usesclient.on('message', msg) => {
. In your case i think you need to change themsg
here tomessage
– Dan Ruxton Commented Dec 30, 2017 at 16:23
3 Answers
Reset to default 1Try message.author.dmChannel.awaitMessages
Check more info in the documentation https://discord.js/#/docs/main/stable/class/User?scrollTo=dmChannel
The Message
class has the property author
, which is of the type User
class (as seen in the docs here), and the User
class does not have the function awaitResponse(...)
, which is why you are seeing that error. See documentation of the User class here.
I would remend using message.channel.awaitMessages
and checking the messages' .author
property if you are checking for responses from a specific person.
message.author
is from the User
class which does not contain the awaitResponse()
function. Use message.member
(returns a GuildMember
) instead of message.author
本文标签: javascriptAwait message from user in Direct Message Discord jsStack Overflow
版权声明:本文标题:javascript - Await message from user in Direct Message Discord js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744769751a2624266.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论