Skip to content

Instantly share code, notes, and snippets.

@jpatrickdill
Created March 20, 2018 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpatrickdill/6b1116d4f2d956ccff3b75b86cabb27e to your computer and use it in GitHub Desktop.
Save jpatrickdill/6b1116d4f2d956ccff3b75b86cabb27e to your computer and use it in GitHub Desktop.
User bot that finds users with same discriminator.
const Discord = require("discord.js");
const client = new Discord.Client();
client.on("ready", () => {
console.log("ready");
});
client.on("message", message => {
if ((message.author === client.user) && (message.content.substring(0, 2) === "%%")) {
console.log(message.content);
let msg = message.content.substring(2).split(" ");
let cmd = msg[0];
let args = msg.slice(1);
if (cmd === "discrim") {
// find users with specific discriminator
let matches = [];
let users = client.users.array() // online users in same server as client
for (let user of users) {
if (user.discriminator === args[0]) { // check for matching discrim
matches.push(user.username+"#"+args[0]); // full tag
}
}
console.log(matches);
if (matches.length === 0) {
message.channel.send("No matches found.");
} else {
let reply = "```" + matches.join("\n") + "```";
reply += " Sample size: " + users.length; // number of users checked
message.channel.send(reply); // send user list
}
}
}
});
let TOKEN = "your user token here"
client.login(TOKEN);
@liquidwater0
Copy link

63

@N-Ved
Copy link

N-Ved commented Nov 12, 2021

63

poopy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment