I have a discord server, i used tatsu bot to allow points members of my server based on how active they are. For that tatsu provides an api : https://dev.tatsu.gg/api/guilds#get-guild-member-points. But for that we need to get the member's discord id. How can i get the discord id of a member using javascript??
Asked
Active
Viewed 22 times
1 Answers
1
You can try the following:
const Discord = require('discord.js');
const client = new Discord.Client();
const TOKEN = 'YOUR_BOT_TOKEN';
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on('message', (message) => {
if (message.content.startsWith('!getid')) {
const member = message.mentions.members.first(); // Get the first mentioned member
if (member) {
message.channel.send(`The Discord ID of ${member.user.username} is: ${member.id}`);
} else {
message.channel.send('Please mention a member to get their ID.');
}
}
});
client.login(your_token);

GFT
- 63
- 7
-
1Remember to provide intents for reading message content, as well as toggling in intent in the Discord developer portal – Elitezen Sep 01 '23 at 19:42