Created
March 20, 2018 03:08
-
-
Save jpatrickdill/6b1116d4f2d956ccff3b75b86cabb27e to your computer and use it in GitHub Desktop.
User bot that finds users with same discriminator.
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
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
63