client.catch不是功能和作用不断进行的,而不是名字我指定的“新角色”?
我可能只是简单的东西,但我从来没有收到这个错误,我不认为我编辑它足够的,因为它是最后一个功能性会导致此问题。下面的代码块一直给我在文件上这个错误:
(node:17592) UnhandledPromiseRejectionWarning: TypeError: client.catch is not a function
我已指定client = new Discord.Client();
我遇到的另一个问题是,我想获得正由机器人制造是两个玩家/用户(挑战者VS目标格式)的名称,该目标已经接受了挑战者带来的挑战后的作用。它只是让一个名为“新角色”,而不是角色。与这些问题之一任何帮助吗?
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"
}
我试图查找问题,我没有看到任何东西,到目前为止有任何问题,已经帮助。由于美中不足的是添加角色部分后,他们可能有关系吗?先谢谢您的帮助!
回答如下:好奇,如果有你为这个机器人复制的模板?该Discord.Client
对象没有任何catch
方法,因此调用client.catch()
是行不通的。
为了澄清,这是好的:
challenger.addRole(role, permsName)
.catch(error => /* do something with this error */);
你可以用错误怎么办?你可以打印到控制台,我想:
challenger.addRole(role, permsName)
.catch(error => console.error(error));
但是,你不能叫client.catch(error)
,因为这不是一个真正的方法 - 你可以检查出的文档的客户对象here。
关于角色名,你只是有一个小错误:你不想来包装你的选择在{ data: }
对象,你的选择对象是数据。只是通过他们直接,就像这样:
message.guild.createRole({
name: permsName,
hoist: true,
color: "#00fffa",
permissions: []
}).then(role => {
希望帮助!