如何在我的Discord频道中查看BOT的发送消息许可?

发布于 2025-02-08 18:02:53 字数 263 浏览 2 评论 0原文

这是我的代码:

```
if (message.user.bot.permissions.has("SEND_MESSAGE")) {
        console.log("I can send message!!")} 
else {
        console.log("I can't send message!!")
}
```

for exp:我想在频道ID中检查bot权限:988087516844421170 我应该怎么办?

This is my code:

```
if (message.user.bot.permissions.has("SEND_MESSAGE")) {
        console.log("I can send message!!")} 
else {
        console.log("I can't send message!!")
}
```

For exp: I want to check bot permission in channel ID: 988087516844421170
What should I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帝王念 2025-02-15 18:02:53

要查看频道中的机器人许可,您应该使用 channel.permissionsfor() 在此代码中喜欢:

if(message.channel.permissionsFor("BOT_ID").toArray().includes("SEND_MESSAGES")) {
// code if has permission
} else {
// code if no
}

To check bot permission in channel you should use Channel.permissionsFor() like in this code:

if(message.channel.permissionsFor("BOT_ID").toArray().includes("SEND_MESSAGES")) {
// code if has permission
} else {
// code if no
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文