Created
May 13, 2021 16:55
-
-
Save gforcedev/9afc1d7ccd4fe3cdf55f865f3c82bc7f to your computer and use it in GitHub Desktop.
Get Ids from usernames with discord.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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