【发布时间】:2018-12-09 11:47:54
【问题描述】:
因此,这几乎可以按预期工作。我让机器人私信给在服务器正确通道中使用正确命令的用户。我没有让配置文件创建消息阻塞服务器,而是让机器人私下创建配置文件。我知道/认为问题出在 message.channel.awaitMessages 上,因为它只能在执行命令的服务器上的原始频道中看到回复。
我不确定我应该用什么替换 message.channel.awaitMessages 以便它接收私人消息对话中的回复,而不是服务器上的原始配置文件创建通道。
我还没有测试过 sql 消息。我还没有测试过我所拥有的,但我很确定它不会起作用。我希望将用户在私人消息中给出的回复插入(也许更新?)到我已经设置并正常工作的 mysql 数据库中。用户 ID 和用户名已放入此表中,此时与配置文件相关的其余问题为空。当他们回答这些问题时,可以填写/更新这些字段。欢迎任何想法/建议!
module.exports.run = async (bot, message, args) => {
if(message.channel.id === '460633878244229120') return message.author.send(`Greetings, ${message.author.username}! FIRST QUESTION, **What is the name of your Brawler or Character?**`)
.then(function(){
message.channel.awaitMessages(response => message.content, {
max: 1,
time: 5000,
errors: ['time'],
})
.then((collected) => {
message.author.send(`Your Name is: ${collected.first().content}`);
var sql = (`UPDATE profile SET name = '${message.content}' WHERE id = ${message.author.id}`);
})
.catch(function(){
message.author.send('Please submit a name for your character. To restart Profile creation, please type "!profilecreate" command in Profile Creation channel on the server.');
});
});
}
提前感谢您的宝贵时间!
【问题讨论】:
标签: javascript database async-await private discord.js