Assistance getting role by ID

Im trying to get a role via ID, however, whenever i pass that roleID to permissions override in channel.create, it throws a error saying its neither a role nor a User, can i not give channel permissions this way? Code snippet:
guild.channels
.create({
name: ticketID,
type: ChannelType.GuildText,
topic: `Type: ${Type} | ID: ${ticketID} | Urgent: ${Urgent} | Created: ${currentDate} | Status: Open | Started by: ${interaction.user.username}`,
parent: category,
permissionOverwrites: [
{
id: interaction.user.id, // <- works fine
allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ReadMessageHistory],
},
{
id: interaction.guild.roles.cache.get("1122921112532156488"),
allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ReadMessageHistory],
}
guild.channels
.create({
name: ticketID,
type: ChannelType.GuildText,
topic: `Type: ${Type} | ID: ${ticketID} | Urgent: ${Urgent} | Created: ${currentDate} | Status: Open | Started by: ${interaction.user.username}`,
parent: category,
permissionOverwrites: [
{
id: interaction.user.id, // <- works fine
allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ReadMessageHistory],
},
{
id: interaction.guild.roles.cache.get("1122921112532156488"),
allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ReadMessageHistory],
}
Error
Error creating channel: TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
at PermissionOverwrites.resolve (...\Discord\node_modules\discord.js\src\structures\PermissionOverwrites.js:184:28)
at ...\Discord\node_modules\discord.js\src\managers\GuildChannelManager.js:168:81
at Array.map (<anonymous>)
at GuildChannelManager.create (...\Discord\node_modules\discord.js\src\managers\GuildChannelManager.js:168:51)
at Object.execute (.../Discord/Interactions/Commands/hello.js:114:4)
at Object.execute (.../Discord/Events/Client/interactionCreate.js:39:30)
at Client.<anonymous> (.../Discord/Utilities/eventHandler.js:33:23)
at Client.emit (node:events:512:28)
at InteractionCreateAction.handle (...\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (...\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36) {
code: 'InvalidType'
}
Error creating channel: TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
at PermissionOverwrites.resolve (...\Discord\node_modules\discord.js\src\structures\PermissionOverwrites.js:184:28)
at ...\Discord\node_modules\discord.js\src\managers\GuildChannelManager.js:168:81
at Array.map (<anonymous>)
at GuildChannelManager.create (...\Discord\node_modules\discord.js\src\managers\GuildChannelManager.js:168:51)
at Object.execute (.../Discord/Interactions/Commands/hello.js:114:4)
at Object.execute (.../Discord/Events/Client/interactionCreate.js:39:30)
at Client.<anonymous> (.../Discord/Utilities/eventHandler.js:33:23)
at Client.emit (node:events:512:28)
at InteractionCreateAction.handle (...\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (...\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36) {
code: 'InvalidType'
}
Full Code: hastebin.com/share/tifugigeno.javascript
9 Replies
d.js toolkit
d.js toolkit12mo ago
• 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.
Kes
Kes12mo ago
PS C:...> node -v v19.8.1 PS C:...> npm list discord.js redacted@0.0.1 C:... └── discord.js@14.11.0
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Kes
Kes12mo ago
Uh nvm i guess? I changed litterly nothing but added the log for that, and now it works perfectly fine, for some reason..?
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Kes
Kes12mo ago
Well i thought so to, but vscode has auto save on, lmao
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Kes
Kes12mo ago
Yeah thank you though! You guys really are magical haha!
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View