javascript - 不同的用户 ID [discord.js]
问题描述
所以我在一个不和谐的机器人中工作,我想在一个命令中添加不同的用户 ID,但现在它不起作用。代码如下所示:
if (message.author.id !== '513773028606476308', '749446086493470751') return message.channel.send("no")
解决方案
我假设您希望一个命令只为具有特定 ID 的用户运行。因此,该if
语句将在某种处理该特定命令的函数中。您的答案是将 if 语句更改为
if (!['513773028606476308', '749446086493470751'].includes(message.author.id)){return message.channel.send("no")}
但是,最好的解决方案是首先拥有这些特殊 ID 的数组,例如
let allowed=['513773028606476308', '749446086493470751']
if (!allowed.includes(message.author.id)){return message.channel.send("no")}
推荐阅读
- python-3.x - Django 使用 oneToManyField 或 ForeignKey,我应该使用哪一个?
- report - 如何将 jsonb 数据类型转换为 psql 中的其他数据类型以用于亚马逊 quicksight
- javascript - 设置方式
在 MaterialUI 中使用样式输入 - datepicker - 从今天开始在赛普拉斯测试中设置日期选择器一年
- microsoft-graph-teams - Microsoft Teams - 通过 Graph API 将图片发布到频道
- c - 如何在没有多个掩码的情况下使用更多值进行位操作?
- swiftui - JSON 内容中的变量作为计数器的值
- python - LabelEncoding 之后的 OneHotEncoding
- asp.net-core-webapi - Serilog 创建日志文件但不写入其中
- r - 在 r 中的 ggstratsplot 中使用 for 循环函数