[英]Invalid number value
i work on a comunautary bot for discord and i have a probleme in my code我在 discord 的 comunautary bot 上工作,我的代码有问题
this is my code:这是我的代码:
for (let i = 0; i < body.players.length; i++) {
if ((body.players[i].votes >= myToken[0]['palier1'] ) && (body.players[i].votes < myToken[0]['palier2'] )) {
embed50.addFields(
{
name: body.players[i].playername + ' : ',
value: body.players[i].votes + ' votes ! ',
inline: true,
})
}else if((body.players[i].votes >= myToken[0]['palier2'] )) {
embed100.addFields(
{
name: body.players[i].playername + ' : ',
value: body.players[i].votes + ' votes ! ',
inline: true,
})
}
}
and this is my error:这是我的错误:
return comparator(input, number) ? Result.ok(input) : Result.err(new ExpectedConstraintError(name, "Invalid number value", input, expected));
^
ExpectedConstraintError: Invalid number value
at Object.run (/root/bot/node_modules/@sapphire/shapeshift/dist/index.js:727:72)
at /root/bot/node_modules/@sapphire/shapeshift/dist/index.js:113:66
at Array.reduce (<anonymous>)
at NumberValidator.parse (/root/bot/node_modules/@sapphire/shapeshift/dist/index.js:113:29)
at validateFieldLength (/root/bot/node_modules/@discordjs/builders/dist/index.js:146:24)
at EmbedBuilder.addFields (/root/bot/node_modules/@discordjs/builders/dist/index.js:190:5)
at Object.run (/root/bot/commands/topvote.js:111:18)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
constraint: 's.number.lessThanOrEqual',
given: 26,
expected: 'expected <= 25'
}
my first if is okay but the second block my code.....我的第一个 if 没问题,但第二个阻止了我的代码.....
The stacktrace you posted suggests that the error is coming from a function in the Discord.js library called validateFieldLength
.您发布的堆栈跟踪表明错误来自 Discord.js 库中名为validateFieldLength
的函数。
Looking at the source code for this function in Discord.js it appears the name of this function might be a bit confusing;查看 Discord.js 中此函数的源代码,似乎此函数的名称可能有点混乱; at first, I thought it was saying the name or value of a field was too long, but it appears that it's actually saying that you're adding too many fields to a single embed, you've added 26 and you're only allowed to add <= 25.起初,我以为是说字段的名称或值太长,但它似乎实际上是说您向单个嵌入添加了太多字段,您添加了 26 个并且只允许添加 <= 25。
Here is a link to the documentation that goes over the limits for embeds:https://discordjs.guide/popular-topics/embeds.html#embed-limits以下是超过嵌入限制的文档的链接:https ://discordjs.guide/popular-topics/embeds.html#embed-limits
I would suggest you track how many fields you've added so far and when you've hit 25 go ahead and create a new embed (keep an array of these) and attach the next batch to that one.我建议您跟踪到目前为止添加了多少个字段,当您达到 25 个时,继续创建一个新的嵌入(保留这些嵌入的数组)并将下一批附加到该嵌入。 Just note that you can only have up to 10 embeds in a single message so you'll have to stop at 250.请注意,您最多只能在一条消息中嵌入 10 个,因此您必须停在 250 个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.