【发布时间】:2019-06-30 13:04:00
【问题描述】:
我可能只是遗漏了一些简单的东西,但我以前从未遇到过此错误,而且我认为我对其进行的编辑不足以导致此问题,因为它是最后一个功能。下面的代码块一直在文件顶部给我这个错误:
(node:17592) UnhandledPromiseRejectionWarning: TypeError: client.catch is not a function
我已指定client = new Discord.Client();
我遇到的另一个问题是,在目标接受了由挑战者。它只是创建了一个名为“新角色”的角色。对这些问题有任何帮助吗?
if (message.channel.id === '541736552582086656') return challenged.send("Do you accept the challenge? Please reply with 'accept' or 'deny'.")
.then((newmsg) => {
newmsg.channel.awaitMessages(response => response.content, {
max: 1,
time: 150000,
errors: ['time'],
}).then((collected) => {
// Grabs the first (and only) message from the collection.
const reply = collected.first();
if (reply.content === 'accept'){
reply.channel.send(`You have ***accepted *** the challenge from ${challenger}. Please wait while your battlefield is made...`);
message.author.send(`${target} has accepted your challenge! Please wait while the channel is made for your brawl...`)
var server = message.guild;
var permsName = `${target} vs ${challenger}`;
var name = `${target} vs ${challenger}`;
message.guild.createRole({
data: {
name: permsName,
hoist: true,
color: "#00fffa",
permissions: [] }
}).then(role => {
target.addRole(data, permsName)
challenger.addRole(role, permsName)
// client.catch error occurring below
.catch(error => client.catch(error))
}).catch(error => client.catch(error)).then(
server.createChannel(name, "text")).then(
(channel) => {
channel.setParent("542070913177485323")
})
} else if (reply.content === 'deny') {
reply.channel.send("You have ***denied *** the challenge.")
} else {
reply.channel.send("Your response wasn't valid.");
}
})
})
}
module.exports.help = {
name: "challenge"
}
我已尝试查找问题,但到目前为止我没有看到任何对这两个问题有帮助的东西。它们可能是相关的,因为捕获是在添加角色部分之后?在此先感谢您的帮助!
【问题讨论】:
-
查看文档中给出的createRole example。至于
client.catch错误,是因为Discord客户端没有by the docs所说的catch函数(除非你自己为客户端声明了catch函数)。
标签: javascript node.js client roles discord.js