【问题标题】:Discord displays @deleted-role while the role is still avalible当角色仍然可用时,Discord 会显示 @deleted-role
【发布时间】:2021-09-14 17:23:53
【问题描述】:

当我使用 discord.js 编写的不和谐机器人显示角色为@deleted-role 时,我遇到了这个问题,该角色本身仍然可用,但机器人说已删除角色。我试图用另一个角色来测试它,这里是图像和代码:

if (message.content.includes("test"))
  return message.channel.send("<@&" + 855179067388461076 + "> why is that ");

结果

角色

你们能帮我解决这个问题吗?

【问题讨论】:

  • 如果你在 discord 中输入 &lt;@&amp;855179067388461076&gt; 会起作用吗?

标签: javascript node.js discord discord.js


【解决方案1】:

问题是您使用整数 (855179067388461076) 作为雪花。它应该是一个字符串。由于这个数字大于 53 位 (MAX_SAFE_INTEGER),JavaScript 难以解释它。它只能安全​​地表示 -(253 - 1) 和 253 - 1 之间的整数。

Max safe integer 9007199254740992
Your integer 855179067388461076
Your integer becomes 855179067388461000

并且没有 ID 为855179067388461000 的角色。要解决这个问题,请确保您只使用字符串作为雪花:

message.channel.send("<@&" + "855179067388461076" + "> why is that")

// OR
const roleId = "855179067388461076"
message.channel.send("<@&" + roleId + "> why is that")

console.log('<@&' + 855179067388461076 + '> why is that ')
// => <@&855179067388461000> why is that 

【讨论】:

    猜你喜欢
    • 2023-03-19
    • 2021-04-28
    • 2021-04-15
    • 2021-08-26
    • 1970-01-01
    • 2010-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多