Salis
Salis
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
Hey I solved it after trying for so long :) thanks now i understand :))
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
i put it all back before i mess it up even more but maybe you would want to place it in the right spot
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
const { PermissionsBitField , EmbedBuilder } = require('discord.js');
const { ticketRoles, vrouwenRol, primaryColor, succesColor } = require('../../config');

module.exports = {
id: 'accepteren',
permissions: [],
run: async (client, interaction) => {
const memberId = interaction.customId.split('-')[1];
const member = interaction.guild.members.cache.get(memberId);
const role = interaction.guild.roles.cache.get(vrouwenRol);

const hasTicketRole = member.roles.cache.some(userRole => ticketRoles.includes(userRole.id));

if (!hasTicketRole) {
if (!member.permissions.has(PermissionsBitField.Flags.KickMembers || PermissionsBitField.Flags.BanMembers)) {
await interaction.reply({ content: "Je hebt niet de vereiste rol om dit te doen.", ephemeral: true });
}
}


member.roles.add(vrouwenRol);

const embed = new EmbedBuilder()
.setDescription(`${member} heeft de ${role} ontvangen.`)
.setColor(succesColor);

interaction.reply({ embeds: [embed] });
},
};

// interaction.member.roles.cache.has(1209319748563636244) <<< this is what i want to restrict it to
const { PermissionsBitField , EmbedBuilder } = require('discord.js');
const { ticketRoles, vrouwenRol, primaryColor, succesColor } = require('../../config');

module.exports = {
id: 'accepteren',
permissions: [],
run: async (client, interaction) => {
const memberId = interaction.customId.split('-')[1];
const member = interaction.guild.members.cache.get(memberId);
const role = interaction.guild.roles.cache.get(vrouwenRol);

const hasTicketRole = member.roles.cache.some(userRole => ticketRoles.includes(userRole.id));

if (!hasTicketRole) {
if (!member.permissions.has(PermissionsBitField.Flags.KickMembers || PermissionsBitField.Flags.BanMembers)) {
await interaction.reply({ content: "Je hebt niet de vereiste rol om dit te doen.", ephemeral: true });
}
}


member.roles.add(vrouwenRol);

const embed = new EmbedBuilder()
.setDescription(`${member} heeft de ${role} ontvangen.`)
.setColor(succesColor);

interaction.reply({ embeds: [embed] });
},
};

// interaction.member.roles.cache.has(1209319748563636244) <<< this is what i want to restrict it to
@TAEMBO.md 😅
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
It says, "you do not have the specified role to do this"
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
im really not getting it to work..
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
So I did what you said, it is not giving the role indeed, instead it crashes haha.
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
No description
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
@TAEMBO.md sorry for the ping 😅
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
if you need any more handlers or events let me know
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
every slash command
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
Wth, i just noticed anyone can do ANYTHING
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
Here's also the code where it gives the role
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
const { PermissionsBitField , EmbedBuilder } = require('discord.js');
const { ticketRoles, vrouwenRol, primaryColor, succesColor } = require('../../config');

module.exports = {
id: 'accepteren',
permissions: [],
run: async (client, interaction) => {
const memberId = interaction.customId.split('-')[1];
const member = interaction.guild.members.cache.get(memberId);
const role = interaction.guild.roles.cache.get(vrouwenRol);

const hasTicketRole = member.roles.cache.some(userRole => ticketRoles.includes(userRole.id));

if (!hasTicketRole) {
if (!member.permissions.has(PermissionsBitField.Flags.KickMembers || PermissionsBitField.Flags.BanMembers)) {
await interaction.reply({ content: "Je hebt niet de vereiste rol om dit te doen.", ephemeral: true });
}
}



member.roles.add(vrouwenRol);

const embed = new EmbedBuilder()
.setDescription(`${member} heeft de ${role} ontvangen.`)
.setColor(succesColor);

interaction.reply({ embeds: [embed] });
},
};
const { PermissionsBitField , EmbedBuilder } = require('discord.js');
const { ticketRoles, vrouwenRol, primaryColor, succesColor } = require('../../config');

module.exports = {
id: 'accepteren',
permissions: [],
run: async (client, interaction) => {
const memberId = interaction.customId.split('-')[1];
const member = interaction.guild.members.cache.get(memberId);
const role = interaction.guild.roles.cache.get(vrouwenRol);

const hasTicketRole = member.roles.cache.some(userRole => ticketRoles.includes(userRole.id));

if (!hasTicketRole) {
if (!member.permissions.has(PermissionsBitField.Flags.KickMembers || PermissionsBitField.Flags.BanMembers)) {
await interaction.reply({ content: "Je hebt niet de vereiste rol om dit te doen.", ephemeral: true });
}
}



member.roles.add(vrouwenRol);

const embed = new EmbedBuilder()
.setDescription(`${member} heeft de ${role} ontvangen.`)
.setColor(succesColor);

interaction.reply({ embeds: [embed] });
},
};
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
Here you go
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
Any ideas?
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
I want the accept button to require a specific role, so it doesn't complete the output of giving the role.
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
const { EmbedBuilder, PermissionsBitField, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
const client = require('..');

client.on('interactionCreate', async interaction => {
if (!interaction.isButton()) return;
let button;
console.log(interaction.customId)


if (interaction.customId.startsWith('accepteren')) {
button = client.buttons.get('accepteren');
} else if (interaction.customId.startsWith('roles')) {
button = client.buttons.get('roles');
} else if (interaction.customId.startsWith('unban')) {
button = client.buttons.get('unban');
} else {
button = client.buttons.get(interaction.customId);
}








if (!button) return;

try {
if (button.permissions) {
if (!interaction.memberPermissions.has(PermissionsBitField.resolve(button.permissions || []))) {
const perms = new EmbedBuilder()
.setDescription(`🚫 ${interaction.user}, You don't have \`${button.permissions}\` permissions to interact this button!`)
.setColor('Red')
return interaction.reply({ embeds: [perms], ephemeral: true })
}
}
return await button.run(client, interaction);
} catch (error) {
interaction.reply({ content: 'Er is een fout opgetreden!', ephemeral: true });
console.log(error);
}

interaction.reply({ content: 'Button is niet beschikbaar!', ephemeral: true })
});
const { EmbedBuilder, PermissionsBitField, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
const client = require('..');

client.on('interactionCreate', async interaction => {
if (!interaction.isButton()) return;
let button;
console.log(interaction.customId)


if (interaction.customId.startsWith('accepteren')) {
button = client.buttons.get('accepteren');
} else if (interaction.customId.startsWith('roles')) {
button = client.buttons.get('roles');
} else if (interaction.customId.startsWith('unban')) {
button = client.buttons.get('unban');
} else {
button = client.buttons.get(interaction.customId);
}








if (!button) return;

try {
if (button.permissions) {
if (!interaction.memberPermissions.has(PermissionsBitField.resolve(button.permissions || []))) {
const perms = new EmbedBuilder()
.setDescription(`🚫 ${interaction.user}, You don't have \`${button.permissions}\` permissions to interact this button!`)
.setColor('Red')
return interaction.reply({ embeds: [perms], ephemeral: true })
}
}
return await button.run(client, interaction);
} catch (error) {
interaction.reply({ content: 'Er is een fout opgetreden!', ephemeral: true });
console.log(error);
}

interaction.reply({ content: 'Button is niet beschikbaar!', ephemeral: true })
});
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
Hmm a quick explanation for this is, I want to make it so only one specific role can make use of the accept button but it says "you have no permissions" but still assigns the role when the member themself press accept, code will follow now.
24 replies
DIAdiscord.js - Imagine an app
Created by Salis on 4/6/2024 in #djs-questions
Requiring a specific role for a specific button.
Im so sorry its my first time creating a bot i got very far but now like
24 replies