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 toolkit2y 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
KesOP2y ago
PS C:...> node -v v19.8.1 PS C:...> npm list discord.js [email protected] C:... └── [email protected]
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Kes
KesOP2y 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 User2y ago
Message Not Public
Sign In & Join Server To View
Kes
KesOP2y ago
Well i thought so to, but vscode has auto save on, lmao
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Kes
KesOP2y ago
Yeah thank you though! You guys really are magical haha!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server