【发布时间】:2021-03-14 03:04:52
【问题描述】:
所以我为不和谐服务器制作了一个应用程序系统,在测试它时,机器人工作正常,直到应用程序的问题完成,它说应用程序已经发送,但它没有发送应用程序,我收到一个错误提示
(node:11408) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
这是我的代码错误在appsChannel.send(applicationembed);
const { Client, Message, MessageEmbed } = require('discord.js')
module.exports = {
name: "apply",
/**
* @param {Client} client
* @param {Message} message
* @param {string[]} args
*/
run: async (client, message, args) => {
const questions = [
"What is your IGN currently?",
"What is your discord Name and Tag?",
"Why do you want to join the guild?",
"What games stats are you applying with?",
"Is there anything else you want to tell us?"
];
let collectCounter = 0;
let endCounter = 0;
const filter = (m) => m.author.id === message.author.id;
const appStart = await message.author.send(questions[collectCounter++])
const channel = appStart.channel;
const collector = channel.createMessageCollector(filter);
collector.on("collect", () => {
if(collectCounter < questions.length) {
channel.send(questions[collectCounter++])
} else {
channel.send("You application has been sent!")
collector.stop("fulfilled")
}
})
const appsChannel = client.channels.cache.get('820355472635985991')
collector.on('end', (collected, reason) => {
if(reason === 'fulfilled') {
let index = 1;
const mappedResponses = collected.map((msg) => {
return `${index++}) ${questions[endCounter++]}\n-> ${msg.content}`;
})
.join('\n\n');
const applicationembed = new MessageEmbed()
.setAuthor(
message.author.tag,
message.author.displayAvatarURL({ dynamic: ture })
)
.setTitle('New Application!')
.setDescription(mappedResponses)
.setColor('RANDOM')
.setTimestamp()
appsChannel.send(applicationembed);
}
})
},
}
【问题讨论】:
标签: javascript node.js discord discord.js