Role not appearing in category after adding it to permissionOverwrites.

I'm creating this just so that I can separate my issue from the others in the #djs-help-v14. To summarize, my bot creates a role in a function in another file, sends the id to the file that creates the category, and when I create the category, I add it the role to permissionOverwrites, but for some reason, when the category is created in Discord, it does not have the role set in permissions.
15 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.
treble/luna
treble/luna2y ago
is the role you are trying to add lower than the role of the bot
The_Gam3r_King
The_Gam3r_KingOP2y ago
Yes
The_Gam3r_King
The_Gam3r_KingOP2y ago
The_Gam3r_King
The_Gam3r_KingOP2y ago
The roles Can I send in here the code that creates the category and the roles?
The_Gam3r_King
The_Gam3r_KingOP2y ago
const { PermissionFlagsBits } = require("discord.js");
const { MODPermsAllow } = require("./Permissions/Permissions");

function createRoles(interaction) {
interaction.guild.roles
.edit(interaction.guild.roles.everyone.id, {
permissions: [],
})
.catch(console.error);
interaction.guild.roles
.create({
name: "ADM",
color: "#010000",
permissions: [PermissionFlagsBits.Administrator],
})
.catch(console.error);
interaction.guild.roles
.create({
name: "🤖BOT🤖",
color: "#00e3ff",
permissions: [PermissionFlagsBits.Administrator],
})
.catch(console.error);
interaction.guild.roles
.create({
name: "MOD",
color: "#ff0000",
permissions: MODPermsAllow,
})
.catch(console.error);
interaction.guild.roles
.create({
name: "🏆Events & Games🎮",
color: "#007502",
permissions: [],
})
.catch(console.error);
interaction.guild.roles
.create({
name: "🌸Animes, Movies & Series🎬",
color: "#f303d0",
permissions: [],
})
.catch(console.error);
}

function getRoleIDs(interaction) {
const roleEveryoneID = interaction.guild.roles.everyone.id;
const roleADMID = interaction.guild.roles.cache.find(
(role) => role.name === "ADM"
).id;
const roleBOTID = interaction.guild.roles.cache.find(
(role) => role.name === "🤖BOT🤖"
).id;
const roleMODID = interaction.guild.roles.cache.find(
(role) => role.name === "MOD"
).id;
const roleGamesID = interaction.guild.roles.cache.find(
(role) => role.name === "🏆Events & Games🎮"
).id;
const roleMoviesID = interaction.guild.roles.cache.find(
(role) => role.name === "🌸Animes, Movies & Series🎬"
).id;

return {
roleEveryoneID,
roleADMID,
roleBOTID,
roleMODID,
roleGamesID,
roleMoviesID,
};
}

module.exports = { createRoles, getRoleIDs };
const { PermissionFlagsBits } = require("discord.js");
const { MODPermsAllow } = require("./Permissions/Permissions");

function createRoles(interaction) {
interaction.guild.roles
.edit(interaction.guild.roles.everyone.id, {
permissions: [],
})
.catch(console.error);
interaction.guild.roles
.create({
name: "ADM",
color: "#010000",
permissions: [PermissionFlagsBits.Administrator],
})
.catch(console.error);
interaction.guild.roles
.create({
name: "🤖BOT🤖",
color: "#00e3ff",
permissions: [PermissionFlagsBits.Administrator],
})
.catch(console.error);
interaction.guild.roles
.create({
name: "MOD",
color: "#ff0000",
permissions: MODPermsAllow,
})
.catch(console.error);
interaction.guild.roles
.create({
name: "🏆Events & Games🎮",
color: "#007502",
permissions: [],
})
.catch(console.error);
interaction.guild.roles
.create({
name: "🌸Animes, Movies & Series🎬",
color: "#f303d0",
permissions: [],
})
.catch(console.error);
}

function getRoleIDs(interaction) {
const roleEveryoneID = interaction.guild.roles.everyone.id;
const roleADMID = interaction.guild.roles.cache.find(
(role) => role.name === "ADM"
).id;
const roleBOTID = interaction.guild.roles.cache.find(
(role) => role.name === "🤖BOT🤖"
).id;
const roleMODID = interaction.guild.roles.cache.find(
(role) => role.name === "MOD"
).id;
const roleGamesID = interaction.guild.roles.cache.find(
(role) => role.name === "🏆Events & Games🎮"
).id;
const roleMoviesID = interaction.guild.roles.cache.find(
(role) => role.name === "🌸Animes, Movies & Series🎬"
).id;

return {
roleEveryoneID,
roleADMID,
roleBOTID,
roleMODID,
roleGamesID,
roleMoviesID,
};
}

module.exports = { createRoles, getRoleIDs };
The_Gam3r_King
The_Gam3r_KingOP2y ago
The MODPermsDeny
The_Gam3r_King
The_Gam3r_KingOP2y ago
And this is the code that calls the two functions
const { createCategories } = require("../../createFuntions/createCategories");
const { createRoles } = require("../../createFuntions/createRoles");

module.exports = {
data: {
name: `choosefile`,
},
async execute(interaction, client) {
await interaction.reply({
content: `Done!`,
});

await interaction.guild
.edit({
defaultMessageNotifications: 1,
explicitContentFilter: 2,
verificationLevel: 2,
features: [],
})
.then((updatedGuild) => {
console.log("Current guild features: ", updatedGuild.features);
interaction.guild.roles.cache.forEach((role) => {
if (!(role.name == "University BOT" || role.name == "@everyone")) {
role.delete().catch(console.error);
}
});
interaction.guild.channels.cache.forEach((channel) => {
// Looping through the guild channels.
channel.delete().catch(console.error);
});

createRoles(interaction);
createCategories(interaction);
})
.catch(console.error);
},
};
const { createCategories } = require("../../createFuntions/createCategories");
const { createRoles } = require("../../createFuntions/createRoles");

module.exports = {
data: {
name: `choosefile`,
},
async execute(interaction, client) {
await interaction.reply({
content: `Done!`,
});

await interaction.guild
.edit({
defaultMessageNotifications: 1,
explicitContentFilter: 2,
verificationLevel: 2,
features: [],
})
.then((updatedGuild) => {
console.log("Current guild features: ", updatedGuild.features);
interaction.guild.roles.cache.forEach((role) => {
if (!(role.name == "University BOT" || role.name == "@everyone")) {
role.delete().catch(console.error);
}
});
interaction.guild.channels.cache.forEach((channel) => {
// Looping through the guild channels.
channel.delete().catch(console.error);
});

createRoles(interaction);
createCategories(interaction);
})
.catch(console.error);
},
};
this file is called when button in interaction is pressed
treble/luna
treble/luna2y ago
can you try removing the modeprmsdeny and see if that does anything
The_Gam3r_King
The_Gam3r_KingOP2y ago
Ok, I will try that in a sec
The_Gam3r_King
The_Gam3r_KingOP2y ago
Did not solve
The_Gam3r_King
The_Gam3r_KingOP2y ago
removed the MODPermsDeny, still did not show up on Discord
The_Gam3r_King
The_Gam3r_KingOP2y ago
Yet, it still logs correctly to the console
The_Gam3r_King
The_Gam3r_KingOP2y ago
Makes sense. Even though I'm not new to coding, I'm new to this type of "bulk coding" Don't know if what I just said makes sense XD How would I fix it then?
Want results from more Discord servers?
Add your server