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

Hey everyone, running into a weird error trying to create a channel with specific permissions.
const channel = await this.parentGuild.channels.create({
name: `${options.memberName}-cancellation`,
parent: this.CHANNEL_PARENT_ID,
permissionOverwrites: [
{ id: options.memberId, allow: PermissionFlagsBits.SendMessages }
]
})
const channel = await this.parentGuild.channels.create({
name: `${options.memberName}-cancellation`,
parent: this.CHANNEL_PARENT_ID,
permissionOverwrites: [
{ id: options.memberId, allow: PermissionFlagsBits.SendMessages }
]
})
The parentGuild object was fetched using client.guilds.fetch() (part of a class thats constructed at startup). options.memberId is also 100% a user snowflake, its being passed in via an api route but it's copied right from the discord client. I've also tried with id: "snowflake" to no avail. Can anyone figure out whats going on.
12 Replies
d.js toolkit
d.js toolkit8mo 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!
Matthew James
Matthew JamesOP8mo ago
[email protected] /Users/mj/Documents/uncommon-edu/integration-backend
├─┬ @discord-nestjs/[email protected]
│ └── [email protected] deduped
[email protected] /Users/mj/Documents/uncommon-edu/integration-backend
├─┬ @discord-nestjs/[email protected]
│ └── [email protected] deduped
node v21.7.3
Amgelo
Amgelo8mo ago
make sure options.memberId is a string and not a number
Matthew James
Matthew JamesOP8mo ago
its a string yes Full Stack Trace
string
[Nest] 79063 - 2024-05-07, 12:49:33 p.m. ERROR [ExceptionsHandler] Supplied parameter is not a User nor a Role.
TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
at Function.resolve (/Users/mj/Documents/uncommon-edu/integration-backend/node_modules/discord.js/src/structures/PermissionOverwrites.js:184:28)
at /Users/mj/Documents/uncommon-edu/integration-backend/node_modules/discord.js/src/managers/GuildChannelManager.js:169:89
at Array.map (<anonymous>)
at GuildChannelManager.create (/Users/mj/Documents/uncommon-edu/integration-backend/node_modules/discord.js/src/managers/GuildChannelManager.js:169:51)
at MetaService.openNewChannel (/Users/mj/Documents/uncommon-edu/integration-backend/src/meta/meta.service.ts:58:53)
at AppController.getPing (/Users/mj/Documents/uncommon-edu/integration-backend/src/app.controller.ts:16:28)
at /Users/mj/Documents/uncommon-edu/integration-backend/node_modules/@nestjs/core/router/router-execution-context.js:38:29
at InterceptorsConsumer.intercept (/Users/mj/Documents/uncommon-edu/integration-backend/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:11:20)
at /Users/mj/Documents/uncommon-edu/integration-backend/node_modules/@nestjs/core/router/router-execution-context.js:46:60
at /Users/mj/Documents/uncommon-edu/integration-backend/node_modules/@nestjs/core/router/router-proxy.js:9:23
string
[Nest] 79063 - 2024-05-07, 12:49:33 p.m. ERROR [ExceptionsHandler] Supplied parameter is not a User nor a Role.
TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
at Function.resolve (/Users/mj/Documents/uncommon-edu/integration-backend/node_modules/discord.js/src/structures/PermissionOverwrites.js:184:28)
at /Users/mj/Documents/uncommon-edu/integration-backend/node_modules/discord.js/src/managers/GuildChannelManager.js:169:89
at Array.map (<anonymous>)
at GuildChannelManager.create (/Users/mj/Documents/uncommon-edu/integration-backend/node_modules/discord.js/src/managers/GuildChannelManager.js:169:51)
at MetaService.openNewChannel (/Users/mj/Documents/uncommon-edu/integration-backend/src/meta/meta.service.ts:58:53)
at AppController.getPing (/Users/mj/Documents/uncommon-edu/integration-backend/src/app.controller.ts:16:28)
at /Users/mj/Documents/uncommon-edu/integration-backend/node_modules/@nestjs/core/router/router-execution-context.js:38:29
at InterceptorsConsumer.intercept (/Users/mj/Documents/uncommon-edu/integration-backend/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:11:20)
at /Users/mj/Documents/uncommon-edu/integration-backend/node_modules/@nestjs/core/router/router-execution-context.js:46:60
at /Users/mj/Documents/uncommon-edu/integration-backend/node_modules/@nestjs/core/router/router-proxy.js:9:23
Amgelo
Amgelo8mo ago
what does logging it says
Matthew James
Matthew JamesOP8mo ago
first line is console.log(typeof options.memberId)
duck
duck8mo ago
when using an id directly for an overwrite (particularly for uncached structures), you'll want to specify the type of the overwrite that being OverwriteType.Member in this case
Matthew James
Matthew JamesOP8mo ago
Fixed, thanks. Docs examples show a memberId being used without the optional type parameter (below), worth opening an issue for?
No description
duck
duck8mo ago
probably not, the example shows using the id for a cached structure
Matthew James
Matthew JamesOP8mo ago
Cached structure as in the cached guild?
duck
duck8mo ago
no, the cached author
Matthew James
Matthew JamesOP8mo ago
oh, right, okay That makes sense, thank you
Want results from more Discord servers?
Add your server