Unknown member
DiscordAPIError[10007]: Unknown Member
Code:
if (subcommand === "zmień-prezesa") {
const channel_topic = interaction.channel.topic;
if (!channel_topic || channel_topic !== name) return interaction.reply({ content: "`[ ❌ ]` Ten kanał nie należy do podanego klubu!", ephemeral: true });
const club_data = database.get(`guilds.${name}`);
const old_owner = database.get(`users.${club_data.owner}`);
const new_owner = database.get(`users.${user.id}`);
if (!new_owner) {
database.set(`users.${user.id}`, {
club: "",
club_role: "",
pass_block: new Date().getTime(),
balance: 0,
});
return interaction.reply({ content: "`[ ✔️ ]` Pomyślnie utworzono konto użytkownika <@" + user.id + ">, użyj komendy ponownie!", ephemeral: true });
}
if (new_owner.club !== name) return interaction.reply({ content: "`[ ❌ ]` Podany użytkownik jest w innym klubie!", ephemeral: true });
if (!club_data) return interaction.reply({ content: "`[ ❌ ]` Nie znaleziono klubu!", ephemeral: true });
const m_guild = await interaction.client.guilds.cache.get(main_guild_id);
const c_guild = await interaction.client.guilds.cache.get(interaction.guild.id);
if (!m_guild || !c_guild) return interaction.reply({ content: "`[ ❌ ]` Nie udało się znaleźć serwera discord!", ephemeral: true });
const m_old_member = await m_guild.members.fetch(club_data.owner);
const c_old_member = await c_guild.members.fetch(club_data.owner);
const m_new_member = await m_guild.members.fetch(user.id);
const c_new_member = await c_guild.members.fetch(user.id);
if (!m_old_member || !c_old_member || !m_new_member || !c_new_member) return interaction.reply({ content: "`[ ❌ ]` Nie udało się znaleźć użytkownika!", ephemeral: true });
const m_rank_role = await m_guild.roles.cache.find(r => r.name === "• Zarząd Klubu | IFL");
const c_rank_role = await c_guild.roles.cache.find(r => r.name === "✬ Prezes Klubu | IFL");
const m_role = await m_guild.roles.cache.find(role => role.name === "• " + name + " | Kluby");
const c_role = await c_guild.roles.cache.find(role => role.name === name + " | Kluby");
if (!m_role || !c_role || !m_rank_role || !c_rank_role) return interaction.reply({ content: "`[ ❌ ]` Nie udało się znaleźć roli!", ephemeral: true });
await m_old_member.roles.remove(m_rank_role);
await c_old_member.roles.remove(c_rank_role);
await m_old_member.roles.remove(m_role);
await c_old_member.roles.remove(c_role);
await m_new_member.roles.add(m_rank_role);
await c_new_member.roles.add(c_rank_role);
await m_new_member.roles.add(m_role);
await c_new_member.roles.add(c_role);
const uu3 = await interaction.guild.members.fetch(club_data.owner);
let m_table = database.get(`guilds.${name}.members`);
m_table = m_table.filter(value => value !== uu3.user.username);
database.set(`guilds.${name}.members`, m_table);
database.push(`guilds.${name}.members`, user.username);
database.set(`guilds.${name}.owner`, user.id);
database.set(`users.${user.id}.club`, old_owner.club);
database.set(`users.${user.id}.club_role`, old_owner.club_role);
database.set(`users.${club_data.owner}.club`, "");
database.set(`users.${club_data.owner}.club_role`, "");
interaction.reply({ content: "`[ ✔️ ]` Pomyślnie zmieniłeś prezesa klubu **" + name + "** na <@" + user.id + ">!", ephemeral: true });
}
if (subcommand === "zmień-prezesa") {
const channel_topic = interaction.channel.topic;
if (!channel_topic || channel_topic !== name) return interaction.reply({ content: "`[ ❌ ]` Ten kanał nie należy do podanego klubu!", ephemeral: true });
const club_data = database.get(`guilds.${name}`);
const old_owner = database.get(`users.${club_data.owner}`);
const new_owner = database.get(`users.${user.id}`);
if (!new_owner) {
database.set(`users.${user.id}`, {
club: "",
club_role: "",
pass_block: new Date().getTime(),
balance: 0,
});
return interaction.reply({ content: "`[ ✔️ ]` Pomyślnie utworzono konto użytkownika <@" + user.id + ">, użyj komendy ponownie!", ephemeral: true });
}
if (new_owner.club !== name) return interaction.reply({ content: "`[ ❌ ]` Podany użytkownik jest w innym klubie!", ephemeral: true });
if (!club_data) return interaction.reply({ content: "`[ ❌ ]` Nie znaleziono klubu!", ephemeral: true });
const m_guild = await interaction.client.guilds.cache.get(main_guild_id);
const c_guild = await interaction.client.guilds.cache.get(interaction.guild.id);
if (!m_guild || !c_guild) return interaction.reply({ content: "`[ ❌ ]` Nie udało się znaleźć serwera discord!", ephemeral: true });
const m_old_member = await m_guild.members.fetch(club_data.owner);
const c_old_member = await c_guild.members.fetch(club_data.owner);
const m_new_member = await m_guild.members.fetch(user.id);
const c_new_member = await c_guild.members.fetch(user.id);
if (!m_old_member || !c_old_member || !m_new_member || !c_new_member) return interaction.reply({ content: "`[ ❌ ]` Nie udało się znaleźć użytkownika!", ephemeral: true });
const m_rank_role = await m_guild.roles.cache.find(r => r.name === "• Zarząd Klubu | IFL");
const c_rank_role = await c_guild.roles.cache.find(r => r.name === "✬ Prezes Klubu | IFL");
const m_role = await m_guild.roles.cache.find(role => role.name === "• " + name + " | Kluby");
const c_role = await c_guild.roles.cache.find(role => role.name === name + " | Kluby");
if (!m_role || !c_role || !m_rank_role || !c_rank_role) return interaction.reply({ content: "`[ ❌ ]` Nie udało się znaleźć roli!", ephemeral: true });
await m_old_member.roles.remove(m_rank_role);
await c_old_member.roles.remove(c_rank_role);
await m_old_member.roles.remove(m_role);
await c_old_member.roles.remove(c_role);
await m_new_member.roles.add(m_rank_role);
await c_new_member.roles.add(c_rank_role);
await m_new_member.roles.add(m_role);
await c_new_member.roles.add(c_role);
const uu3 = await interaction.guild.members.fetch(club_data.owner);
let m_table = database.get(`guilds.${name}.members`);
m_table = m_table.filter(value => value !== uu3.user.username);
database.set(`guilds.${name}.members`, m_table);
database.push(`guilds.${name}.members`, user.username);
database.set(`guilds.${name}.owner`, user.id);
database.set(`users.${user.id}.club`, old_owner.club);
database.set(`users.${user.id}.club_role`, old_owner.club_role);
database.set(`users.${club_data.owner}.club`, "");
database.set(`users.${club_data.owner}.club_role`, "");
interaction.reply({ content: "`[ ✔️ ]` Pomyślnie zmieniłeś prezesa klubu **" + name + "** na <@" + user.id + ">!", ephemeral: true });
}
9 Replies
- 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!looks like user.id is not a valid member's id
const user = interaction.options.getUser("user");
i getting this from options
is user specified
log the user
User {
id: '1040618285273722920',
bot: false,
system: false,
flags: UserFlagsBitField { bitfield: 0 },
username: 'tks_macius',
globalName: 'Emerytowany TKS_Maciuś',
discriminator: '0',
avatar: '59233df34dfc6c3049ce61bb4325a0c9',
banner: undefined,
accentColor: undefined,
avatarDecoration: null
}
User {
id: '1040618285273722920',
bot: false,
system: false,
flags: UserFlagsBitField { bitfield: 0 },
username: 'tks_macius',
globalName: 'Emerytowany TKS_Maciuś',
discriminator: '0',
avatar: '59233df34dfc6c3049ce61bb4325a0c9',
banner: undefined,
accentColor: undefined,
avatarDecoration: null
}
what's main_guild_id
const { main_guild_id } = require('../../data/config.json');
"main_guild_id": "1191749007731605656",
const user = interaction.options.getUser("user");
with this
?
the member fetch
okay
ty