TypeError [InvalidType]: Supplied parameter is not a User nor a Role.

VoiceStateUpdate Event.
for (let userId of trustedUsers) {
let user = newChannel.guild.members.cache.get(userId);
if (user) {
permissionOverwrites.push({
id: userId,
allow: [
PermissionFlagsBits.Connect,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.SendMessages
]
});
} else {
try {
user = await newChannel.guild.members.fetch(userId);
if (user) {
permissionOverwrites.push({
id: userId,
allow: [
PermissionFlagsBits.Connect,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.SendMessages
]
});
}
} catch (error) {
console.log(`Invalid user ID in trustedUsers: ${userId}`);
}
}
}

const channel = await newChannel?.guild?.channels.create({
name: roomName,
parent: privateRoomsCategoryId,
type: ChannelType.GuildVoice,
userLimit: userLimit,
permissionOverwrites: permissionOverwrites
}).catch((e) => {console.log(e)})
for (let userId of trustedUsers) {
let user = newChannel.guild.members.cache.get(userId);
if (user) {
permissionOverwrites.push({
id: userId,
allow: [
PermissionFlagsBits.Connect,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.SendMessages
]
});
} else {
try {
user = await newChannel.guild.members.fetch(userId);
if (user) {
permissionOverwrites.push({
id: userId,
allow: [
PermissionFlagsBits.Connect,
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.SendMessages
]
});
}
} catch (error) {
console.log(`Invalid user ID in trustedUsers: ${userId}`);
}
}
}

const channel = await newChannel?.guild?.channels.create({
name: roomName,
parent: privateRoomsCategoryId,
type: ChannelType.GuildVoice,
userLimit: userLimit,
permissionOverwrites: permissionOverwrites
}).catch((e) => {console.log(e)})
3 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
vlad vollar
vlad vollarOP7mo ago
TypeError [InvalidType]: Supplied parameter is not a User nor a Role. at PermissionOverwrites.resolve (C:\Users\WORK\Desktop\asagi-assistant-develop\node_modules\discord.js\src\structures\PermissionOverwrites.js:184:28) at C:\Users\WORK\Desktop\asagi-assistant-develop\node_modules\discord.js\src\managers\GuildChannelManager.js:169:89 at Array.map (<anonymous>) at GuildChannelManager.create (C:\Users\WORK\Desktop\asagi-assistant-develop\node_modules\discord.js\src\managers\GuildChannelManager.js:169:51) at handleCreateRoom (file:///C:/Users/WORK/Desktop/asagi-assistant-develop/src/events/handles/privateRooms/handleCreateRoom.js:387:71) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Client.<anonymous> (file:///C:/Users/WORK/Desktop/asagi-assistant-develop/src/events/voice/onVoiceStateUpdate.js:38:9) { code: 'InvalidType' } console.log(trustedUsers) [ '1125484017593090239' ] console.log(permissionOverwrites) [ { id: '440407587037642783', allow: [ 1048576n, 1024n, 2048n ] }, { id: '1129790184699985971', deny: [] }, { id: '1125484017593090239', allow: [ 1048576n, 1024n, 2048n ] }, { id: null, deny: [ 1048576n, 1024n, 2048n ] } ] The user is on the server.
Kevinnnn
Kevinnnn7mo ago
your last permission overwrite has null as the id, hence why its erroring one of your entries in the array is null
Want results from more Discord servers?
Add your server