Get all users which have permission "Connect" on false in a specific voice channel
The goal is to create a list of all users which have permission "Connect" on false in a voice channel...
Still no idea?
Version djs:
//fetch guild members
await guild.members.fetch();
//have permission to connect on false
var banneds = guild.members.cache.filter(m => !m.permissionsIn(vocal).has(PermissionsBitField.Flags.Connect));
console.log(banneds); //output is Collection(0) [Map] {} instead of users banned...
//fetch guild members
await guild.members.fetch();
//have permission to connect on false
var banneds = guild.members.cache.filter(m => !m.permissionsIn(vocal).has(PermissionsBitField.Flags.Connect));
console.log(banneds); //output is Collection(0) [Map] {} instead of users banned...
[email protected]
Version node: v18.8.0
2 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Post the full error stack trace, not just the top part!
- Show your code!
- Explain what exactly your issue is.
- Not a discord.js issue? Check out #useful-servers.
- Issue solved? Press the button!Full Code
const { ChatInputCommandInteraction, SlashCommandBuilder, EmbedBuilder, Client, PermissionsBitField, ChannelType, GuildMember} = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("vstatus")
.setDescription("...")
.addChannelOption(option => option
.setName("vocal")
.setDescription("...")
.setRequired(false)
),
/**
*
* @param {ChatInputCommandInteraction} interaction
* @param {Client} client
*/
async execute(interaction, client) {
const { member, guild } = interaction;
const { channel } = await member.voice;
var vocal = interaction.options.getChannel("vocal") || channel;
const EmbedYouAreNotInVocal = new EmbedBuilder()
.setDescription("**Vous devez être dans un salon vocal ou préciser un vocal pour utiliser cette commande !**")
const EmbedNotAVocal = new EmbedBuilder()
.setDescription("**Le salon vocal mentionné n'est pas un salon vocal !**")
if (vocal.type !== ChannelType.GuildVoice) return interaction.reply({
embeds: [ EmbedNotAVocal ]
})
if (!vocal) {
interaction.reply({
embeds: [ EmbedYouAreNotInVocal ]
})
} else {
var channelPerm = await vocal.permissionsFor(guild.roles.everyone.id);
//fetch guild members
await guild.members.fetch();
//have permission to connect on false
var banneds = guild.members.cache.filter(m => !m.permissionsIn(vocal).has(PermissionsBitField.Flags.Connect));
console.log(banneds);// return "Collection(0) [Map] {}"
interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle(`**STATUS DU VOCAL "${vocal.name}"**`)
.setDescription(
`- \`bans\` : FutureList...\n`
)
]
});
}
}
}
const { ChatInputCommandInteraction, SlashCommandBuilder, EmbedBuilder, Client, PermissionsBitField, ChannelType, GuildMember} = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName("vstatus")
.setDescription("...")
.addChannelOption(option => option
.setName("vocal")
.setDescription("...")
.setRequired(false)
),
/**
*
* @param {ChatInputCommandInteraction} interaction
* @param {Client} client
*/
async execute(interaction, client) {
const { member, guild } = interaction;
const { channel } = await member.voice;
var vocal = interaction.options.getChannel("vocal") || channel;
const EmbedYouAreNotInVocal = new EmbedBuilder()
.setDescription("**Vous devez être dans un salon vocal ou préciser un vocal pour utiliser cette commande !**")
const EmbedNotAVocal = new EmbedBuilder()
.setDescription("**Le salon vocal mentionné n'est pas un salon vocal !**")
if (vocal.type !== ChannelType.GuildVoice) return interaction.reply({
embeds: [ EmbedNotAVocal ]
})
if (!vocal) {
interaction.reply({
embeds: [ EmbedYouAreNotInVocal ]
})
} else {
var channelPerm = await vocal.permissionsFor(guild.roles.everyone.id);
//fetch guild members
await guild.members.fetch();
//have permission to connect on false
var banneds = guild.members.cache.filter(m => !m.permissionsIn(vocal).has(PermissionsBitField.Flags.Connect));
console.log(banneds);// return "Collection(0) [Map] {}"
interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle(`**STATUS DU VOCAL "${vocal.name}"**`)
.setDescription(
`- \`bans\` : FutureList...\n`
)
]
});
}
}
}