javascript - 当角色仍然可用时,Discord 会显示 @deleted-role
问题描述
当我用 discord.js 编写的不和谐机器人显示一个角色时,我遇到了这个问题@deleted-role
,角色本身仍然可用,但机器人说已删除角色。我试图用另一个角色来测试它,这里是图像和代码:
if (message.content.includes("test"))
return message.channel.send("<@&" + 855179067388461076 + "> why is that ");
结果
角色
你们能帮我解决这个问题吗?
解决方案
问题是您使用整数 ( 855179067388461076
) 作为雪花。它应该是一个字符串。由于这个数字大于 53 位 ( MAX_SAFE_INTEGER
),JavaScript 很难解释它。它只能安全地表示 -(2 53 - 1) 和 2 53 - 1 之间的整数。
最大安全整数 | 9007199254740992 |
你的整数 | 855179067388461076 |
你的整数变成 | 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
推荐阅读
- pyspark - 如何将每个元素存储到字典并使用pyspark计算字典值?
- python - 更新弹性搜索字段的问题
- python - 如何在 matplotlib 的绘图画布内放置可变长度刻度标签?
- r - R有效的基于性能的方法来填充矩阵而不使用嵌套for循环
- java - Optional / 使用 Optional 并返回另一个 Optional
- laravel - 在 laravel 中使用紧凑值重定向
- c# - 将 Excel 文件数据导入 WPF 中的 Datagrid
- c++ - 在 Windows 中查找推荐的显示器分辨率
- react-final-form - 重置表单而不会丢失 submitSucceeded
- django - Django 2.1.1 'set' 对象不可逆'set' 对象是