Skip to content

Instantly share code, notes, and snippets.

@gforcedev
Created May 13, 2021 16:55
Show Gist options
  • Save gforcedev/9afc1d7ccd4fe3cdf55f865f3c82bc7f to your computer and use it in GitHub Desktop.
Save gforcedev/9afc1d7ccd4fe3cdf55f865f3c82bc7f to your computer and use it in GitHub Desktop.
Get Ids from usernames with discord.js
getIds = () => {
const rsGuild = client.guilds.cache.get('<server-id>');
rsGuild.members.fetch()
.then(() => {
const lineReader = require('readline').createInterface({
input: require('fs').createReadStream('infile.txt')
});
lineReader.on('line', (line) => {
try {
console.log(rsGuild.members.cache.find(u => {
return u.user.username === line.match(/[^#]*/g)[0] && u.user.discriminator === line.match(/\d\d\d\d$/g)[0];
}).id);
} catch (e) {
console.log(line.match(/[^#]*/g)[0]);
}
});
})
.catch(console.error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment