简体   繁体   中英

Discord.js v14 Permissions | RangeError [BitFieldInvalid]: Invalid bitfield flag or number: STREAM

I using discord.js V14 to check if a voice channel has streaming permissions enabled.

I tried this but it's not working.

if (voiceChannel.permissionsFor(voiceChannel.guild.id).has("STREAM"))

It gives me the following error:

RangeError [BitFieldInvalid]: Invalid bitfield flag or number: STREAM.

btw, this code is working perfectly with the "Connect" permission.

Well, did you try using Stream instead of STREAM ? I can't see anything else if it's working using Connect .

In v14, you can't use STREAM or other strings, you should use the enums from PermissionFlagsBits :

const { PermissionFlagsBits } = require('discord.js')

// ...

if (voiceChannel.permissionsFor(voiceChannel.guild.id)
  .has(PermissionFlagsBits.Stream)
)

You can view all the available permissions here: PermissionFlagsBits

Related: Errors with enums in discord.js v14

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM