【发布时间】:2020-11-13 07:51:34
【问题描述】:
因此,此代码向用户发送 DM,向用户询问一些问题,然后我的目标是将应用程序发送回特定频道,不知道该怎么做,任何帮助我知道您必须使用频道 ID,但不确定如何编译所有答案,然后将它们发送回特定频道?
let userApplications = {}
bot.on("message", function(message) {
if (message.author.equals(bot.user)) return;
let authorId = message.author.id;
if (message.content === "%apply") {
console.log(`Apply begin for authorId ${authorId}`);
// User is not already in a registration process
if (!(authorId in userApplications)) {
userApplications[authorId] = { "step" : 1}
message.author.send("```We need to ask some questions so we can know a litte bit about yourself```");
message.author.send("```Application Started - Type '#Cancel' to cancel the application```");
message.author.send("```Question 1: In-Game Name?```");
}
} else {
if (message.channel.type === "dm" && authorId in userApplications) {
let authorApplication = userApplications[authorId];
if (authorApplication.step == 1 ) {
authorApplication.answer1 = message.content;
message.author.send("```Question 2: Age?```");
authorApplication.step ++;
}
else if (authorApplication.step == 2) {
authorApplication.answer2 = message.content;
message.author.send("```Question 3: Timezone? NA, AU, EU, NZ, or Other? (If other, describe your timezone)```");
authorApplication.step ++;
}
else if (authorApplication.step == 3) {
authorApplication.answer3 = message.content;
message.author.send("```Question 4: Do you have schematica?```");
authorApplication.step ++;
}
else if (authorApplication.step == 4) {
authorApplication.answer4 = message.content;
message.author.send("```Thanks for your registration. Type %apply to register again```");
//before deleting, you can send the answers to a specific channel by ID
bot.channels.cache.get("616852008837709844")
.send(`${message.author.tag}\n${authorApplication.answer1}\n${authorApplication.answer2}\n${authorApplication.answer3}\n${authorApplication.answer4});
delete userApplications[authorId];
}
}
}
});
}
module.exports.help = {
name: "app"
}```
【问题讨论】:
-
你想把答案发回用户最初写
%apply的频道吗?还是转到特定频道供您观看?
标签: node.js discord.js