javascript - 用私人消息 discord.js 中用户的回复替换 mysql 数据库中的值
问题描述
因此,我有一个机器人在不和谐服务器上的公共频道中发起对话后,在私人聊天中询问用户一些问题。我希望在私人聊天中得到用户的回复,以更新我的 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了。
解决方案
推荐阅读
- regex - 匹配单词边界末尾的星 * 字符 \b
- javascript - 如何在javascript中为任何给定时区调整特定日期的DST值
- c++ - 在 C++ 中为 char 数组数据类型添加了额外字符
- java - 如何使用 java 13 设置 spring-boot 应用程序
- html - 如何响应地定位引导按钮?
- python-3.x - 如何提取帐户的第一条推文?
- python - 从网站查询3年的数据但只能看到三个月
- python - Django-Storages ('`data` 必须是字节,已接收',
) 保存模型字段时 - python-3.x - 如何跟踪用户输入的分数?
- cuda - 其他块的线程是否可以访问内核中使用 malloc 分配的内存?