Reputation: 37
I recently started working on a discord.js bot, and I came across a very weird issue, that I couldn't fix, or figure out what to do. I wanted to create a voice channel with custom permissions, so I used this function (or I don't know what its called I'm new to js):
message.guild.channels.create(`Room of ${message.member.displayName}`, {type: 'voice'}, {
permissionOverwrites: [{
id: message.guild.defaultRole,
allow: 'VIEW_CHANNEL'
}]
});
I noticed this: If I place the {type: 'voice'}
before the permissionOverwrites
, it works normally (except the permissions don't work at all), but if I place it after the permissionOverwrites
the permissions work normally, but the type won't work.
I get no console error, or anything.
Upvotes: 0
Views: 76
Reputation: 7303
As per the discord.js docs for channel creation, the method create()
takes only two arguments: The channel name and the channel options.
Which means you have to put all your options into a single object:
message.guild.channels.create(`Room of ${message.member.displayName}`, {
type: 'voice',
permissionOverwrites: [{
id: message.guild.defaultRole,
allow: 'VIEW_CHANNEL'
}]
});
So the reason for the behavior you encountered is simply that your third argument for create()
is completely ignored, no matter what you put there.
Upvotes: 2