用私人消息discord.js中用户的回复替换mysql数据库中的值

时间:2018-07-02 12:17:53

标签: javascript mysql node.js discord.js

因此,我有一个机器人在不和谐服务器上的公共频道中发起对话后,在私人聊天中向用户询问一些问题。我希望在私人聊天中得到用户的答复,以更新我的mysql数据库中的某个字段。

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((newmsg) => { //Now newmsg is the message you sent
    newmsg.channel.awaitMessages(response => response.content, {
      max: 1,
      time: 10000,
      errors: ['time'],
    }).then((collected) => {
      newmsg.channel.send(`Your Name is: ${collected.first().content}`)
        var sql = (`UPDATE profile SET name = ${collected.first().content} WHERE id = ${newmsg.author.id}`);
    }).catch(() => {
      newmsg.channel.send('Please submit a name for your character. To restart Profile creation, please type "!profilecreate" command in Profile Creation channel on the server.');
    });
  });
}

除将行提交到数据库外,其他所有操作均有效。它看起来甚至根本没有尝试运行该行,因为当我知道应该有该语法错误时,我还没有收到语法错误。我是一般的编码新手,更不用说JS了。

0 个答案:

没有答案