Reputation: 33
im programming a Discord bot and I would like to get Discord usernames from user IDs so I know who voted for my bot ive I've tried that using Google to find the answer but it doesn't really show me
Upvotes: 2
Views: 4372
Reputation: 1589
You need to collect the user from your client.
const Discord = require("discord.js");
const client = new Discord.Client();
//This return the username of the specified user ID.
const user = client.users.cache.get("USERID");
if (!user) return console.log("Couldn't find the user");
console.log(user.username)
Upvotes: 3