Ropyle
Ropyle
DIAdiscord.js - Imagine an app
Created by Ropyle on 12/23/2023 in #djs-questions
Event, guildMemberRemove is emitted when someone got banned
No description
4 replies
DIAdiscord.js - Imagine an app
Created by Ropyle on 9/2/2023 in #djs-questions
Doesn't DiscordAPI reflect the latest role position?
I made a test guild for my bots. The guild has this roles scoreboard(?) - Owner - Mod - Member Guild has these members: - Me - My bot - Tom I gave Tom "Member" role (its position is "1") while I have "Owner" role (its position is "3") This is a code the bot has:
//...
client.on('messageCreate', async message => {
if(message.content !== 'test') return;

const myGuild = await client.guilds.fetch('GuildID');
// "fetch" a guild
try { await myGuild.members.fetch(message.author.id) } catch (e){ return message.channel.send("Author is not a member of my guild."); };
// If message author is not a member of the guild
try { await myGuild.members.fetch('UserID') } catch(e) { return message.channel.send('UserID is not a member of my guild.'); };
// If the user is not a member of the guild
const authorMember = await myGuild.members.fetch(message.author.id),
// "fetch" message author
authorRank = await authorMember.roles.highest.position,
// Author's role position
targetMember = await myGuild.members.fetch('UserID'),
// "fetch" the user
targetRank = await targetMember.roles.highest.position;
// The user's role position

console.log(`Author's role position: ${authorRank}\nThe Member's role position: ${targetRank}`);
})
//...
//...
client.on('messageCreate', async message => {
if(message.content !== 'test') return;

const myGuild = await client.guilds.fetch('GuildID');
// "fetch" a guild
try { await myGuild.members.fetch(message.author.id) } catch (e){ return message.channel.send("Author is not a member of my guild."); };
// If message author is not a member of the guild
try { await myGuild.members.fetch('UserID') } catch(e) { return message.channel.send('UserID is not a member of my guild.'); };
// If the user is not a member of the guild
const authorMember = await myGuild.members.fetch(message.author.id),
// "fetch" message author
authorRank = await authorMember.roles.highest.position,
// Author's role position
targetMember = await myGuild.members.fetch('UserID'),
// "fetch" the user
targetRank = await targetMember.roles.highest.position;
// The user's role position

console.log(`Author's role position: ${authorRank}\nThe Member's role position: ${targetRank}`);
})
//...
GuildID is my guild UserID is Tom's ID. Then, in my anothor guild, (my bot belongs to) I sent "test". Console:
Author's role position: 3
The Member's role position: 1
Author's role position: 3
The Member's role position: 1
It is very a result I had expected. Then, I gave Tom "Mod" role (its position is "2") I send "test" in the anothor guild again. Console:
Author's role position: 3
The Member's role position: 1
Author's role position: 3
The Member's role position: 1
The result was not changed. I can't understand.
12 replies