Kes
Kes
DIAdiscord.js - Imagine an app
Created by Kes on 6/26/2023 in #djs-questions
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
11 replies
DIAdiscord.js - Imagine an app
Created by Kes on 6/10/2023 in #djs-questions
Calling a DM function from outside Discord.js
Heya, I was wondering if anyone has insight to how i can call for a DM event via a outside function, My bot is running in-junction with a Fastify server, that runs authentication for a database, and when handing out access to this, I want the bot to DM the user their randomly generated key. I would assume there's a way to go about doing this, obviously, but i don't know how i would go about doing this, do i register a event in the event handler or something similar? Or can I just make a function to do this?
3 replies