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.
18 Replies
d.js toolkit
d.js toolkit14mo 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/luna14mo ago
is the role you are trying to add lower than the role of the bot
The_Gam3r_King
The_Gam3r_King14mo ago
Yes
The_Gam3r_King
The_Gam3r_King14mo ago
The_Gam3r_King
The_Gam3r_King14mo ago
The roles Can I send in here the code that creates the category and the roles?
The_Gam3r_King
The_Gam3r_King14mo 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_King14mo ago
The MODPermsDeny
The_Gam3r_King
The_Gam3r_King14mo 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/luna14mo ago
can you try removing the modeprmsdeny and see if that does anything
The_Gam3r_King
The_Gam3r_King14mo ago
Ok, I will try that in a sec
The_Gam3r_King
The_Gam3r_King14mo ago
Did not solve
The_Gam3r_King
The_Gam3r_King14mo ago
removed the MODPermsDeny, still did not show up on Discord
The_Gam3r_King
The_Gam3r_King14mo ago
Yet, it still logs correctly to the console
The_Gam3r_King
The_Gam3r_King14mo 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? Something tells me that I will have a headache fixing the code 🙃
The_Gam3r_King
The_Gam3r_King14mo ago
So, downloaded the ES Linter, now is this the type of rule I need to activate? https://eslint.org/docs/latest/rules/require-atomic-updates
require-atomic-updates - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
The_Gam3r_King
The_Gam3r_King14mo ago
https://eslint.org/docs/latest/rules/require-await or this? I'm not sure which rule forces me to await promisses
require-await - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
The_Gam3r_King
The_Gam3r_King14mo ago
To use Typescript, what do I need to do? Change all files from .js to .ts?