Hey there,
I’m trying to make a command, that invites a person to a football club. Because, I don’t want anyone to join that isn’t in the main server, I wanted to check if the user is in the discord.
I’ve tried countless solutions, but nothing worked. I don’t know why, but I hope that someone can help me with this problem.
Here’s the code (I highlighted where it will check)
const user = interaction.options.getMember('user');
const club = interaction.options.getRole('club');
const position = interaction.options.getString('position');
const guild = await interaction.client.guilds.fetch('1231641406083301458');
const mainguild = await interaction.client.guilds.fetch('1232018031736000613');
const member = await interaction.guild.members.fetch(user.id);
const mainmember = await mainguild.members.fetch(user.id);
const guildMember = await guild.members.cache.get(user.id);
try {
const guild = await interaction.client.guilds.fetch('1231641406083301458');
if (!member) {
const nothere = new EmbedBuilder()
.setColor('#fc0317')
.setDescription('User not found.')
await interaction.reply({embeds: [nothere], ephemeral: true })
}
else if (!guild) {
const noguild = new EmbedBuilder()
.setColor('#fc0317')
.setDescription('Guild not found.')
await interaction.reply({embeds: [noguild], ephemeral: true })
}
** else if (member.guild.id === guild.id) {
const nothere = new EmbedBuilder()
.setColor('#fc0317')
.setDescription('User not found on the IFF server.')
await interaction.reply({embeds: [nothere], ephemeral: true })
}**
else if (interaction.member === user) {
const nothere = new EmbedBuilder()
.setColor('#fc0317')
.setDescription(`You can't add yourself to the club!`)
await interaction.reply({embeds: [nothere], ephemeral: true })
}
Aswell, I’m pretty new to discord.js and not very experienced. If someone could show the solution and explain to me, I would be grateful.
Kind regards,
officialdatch
I expected that if the person isn’t in the discord specified here:
const guild = await interaction.client.guilds.fetch('1231641406083301458');
it will say, what says here:
const nothere = new EmbedBuilder() .setColor('#fc0317') .setDescription('User not found on the IFF server.') await interaction.reply({embeds: [nothere], ephemeral: true })
International Football Federat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.