Not Work

module.exports = {
name: 'add_client',
description: 'Give client role to the member',
options: [
{
name: 'user',
type: 6,
description: 'The user you want give him client role',
required: true,
},
],
run: async (client, interaction) => {
try {
const user = await client.users.fetch(interaction.options.getMember('user'));
const member1 = await interaction.guild.members.fetch(user);

if (!interaction.member.roles.cache.has(interaction.guild.roles.cache.find(role => role.name === 'd'))) {
return interaction.reply({ content: 'انت لست مصمم لا يمكنك استخدام هذا الأمر', ephemeral: true });
} else{
let role1 = interaction.guild.roles.cache.find(role => role.id === '1200195571839930409')
member1.roles.add(role1)
}

} catch (error) {
console.error(error);
interaction.reply({ content: 'حدث خطأ أثناء معالجة الطلب.', ephemeral: true });
}
},
};
module.exports = {
name: 'add_client',
description: 'Give client role to the member',
options: [
{
name: 'user',
type: 6,
description: 'The user you want give him client role',
required: true,
},
],
run: async (client, interaction) => {
try {
const user = await client.users.fetch(interaction.options.getMember('user'));
const member1 = await interaction.guild.members.fetch(user);

if (!interaction.member.roles.cache.has(interaction.guild.roles.cache.find(role => role.name === 'd'))) {
return interaction.reply({ content: 'انت لست مصمم لا يمكنك استخدام هذا الأمر', ephemeral: true });
} else{
let role1 = interaction.guild.roles.cache.find(role => role.id === '1200195571839930409')
member1.roles.add(role1)
}

} catch (error) {
console.error(error);
interaction.reply({ content: 'حدث خطأ أثناء معالجة الطلب.', ephemeral: true });
}
},
};
20 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna11mo ago
and what doesnt work and thats absolutely the most horrid way to fetch the member .getMember returns a member no need to fetch the user nor the member
Fr³oN || تم النقل الي {6h3h}
i has d role but it gives me you not designer i want if the member use /add_client has role role (d) give the member in options role m but it give me return interaction.reply({ content: 'انت لست مصمم لا يمكنك استخدام هذا الأمر', ephemeral: true }); and i have d role
treble/luna
treble/luna11mo ago
you're checking the member running the command if they have the role not the member you want to add the role to
Fr³oN || تم النقل الي {6h3h}
yes interaction.member ? is it false ?
treble/luna
treble/luna11mo ago
what its a GuildMember not a boolean
Fr³oN || تم النقل الي {6h3h}
no no you don't know what i want to do
if (!interaction.member.roles.cache.has(interaction.guild.roles.cache.find(role => role.name === 'd'))) {
return interaction.reply({ content: 'انت لست مصمم لا يمكنك استخدام هذا الأمر', ephemeral: true });
}
if (!interaction.member.roles.cache.has(interaction.guild.roles.cache.find(role => role.name === 'd'))) {
return interaction.reply({ content: 'انت لست مصمم لا يمكنك استخدام هذا الأمر', ephemeral: true });
}
i typesd /add_client if i have role d the bot give the role m to the user in options do you understand pro ? @arcticwolvinny ❄ 🌈
treble/luna
treble/luna11mo ago
no need to ping and you're not making much sense check if the role exists at all store your whole guild.roles.cache.find in a variable and log it
Fr³oN || تم النقل الي {6h3h}
ok i will try the same
let role2 = interaction.guild.roles.cache.find(role => role.id === '1200195509135085749');

if (!interaction.member.roles.cache.has(role2)) {
return interaction.reply({ content: 'انت لست مصمم لا يمكنك استخدام هذا الأمر', ephemeral: true });
}
let role2 = interaction.guild.roles.cache.find(role => role.id === '1200195509135085749');

if (!interaction.member.roles.cache.has(role2)) {
return interaction.reply({ content: 'انت لست مصمم لا يمكنك استخدام هذا الأمر', ephemeral: true });
}
it gives me انت لست مصمم لا يمكنك استخدام هذا الأمر
treble/luna
treble/luna11mo ago
and have you logged the role
treble/luna
treble/luna11mo ago
and what did it return
Fr³oN || تم النقل الي {6h3h}
. and no erros in console
treble/luna
treble/luna11mo ago
i highly doubt that log returned that i dont see you logging it either
Fr³oN || تم النقل الي {6h3h}
it told me you don't have the role but i have it
d.js docs
d.js docs11mo ago
mdn console: log() static method The console.log() static method outputs a message to the console. The message may be a single string (with optional substitution values), or it may be any one or more JavaScript objects.
treble/luna
treble/luna11mo ago
log. it.
Fr³oN || تم النقل الي {6h3h}
i think the way to chek if interaction.member has the role is wrong
interaction.guild.roles.cache.find(role => role.id === '1200195509135085749')
interaction.guild.roles.cache.find(role => role.id === '1200195509135085749')
treble/luna
treble/luna11mo ago
that can be simplified but unless you actually do what i ask you to do i cant help you
Fr³oN || تم النقل الي {6h3h}
ok i will try onther way
Want results from more Discord servers?
Add your server