circle-of-trust
Version:
Get info about a user's circle.
73 lines (67 loc) • 3.48 kB
JavaScript
const djs = require('discord.js');
const bot = new djs.Client();
const cot = require('./index.js');
const approvedGuilds = [
"429823323585773568",
"430740118047817749",
"399274745427656705",
]
bot.on('ready', async () => {
for (let item of approvedGuilds) {
await bot.guilds.get(item).fetchMembers();
}
});
bot.on('message', async message => {
if (message.content.startsWith(">circle ") && approvedGuilds.includes(message.guild.id)) {
try {
const findUser = message.content.split(" ")[1];
const data = await cot(findUser);
const discordUser = message.guild.members.filterArray(member => {
const nickname = member.nickname ? member.nickname.endsWith(data.owner) : false;
return nickname || member.user.username.endsWith(data.owner);
});
message.reply("Here is the circle:", {embed: {
color: data.betrayed ? 0xE50000 : 0x0083c7,
url: data.link,
title: data.name,
description: [
`This room has ${data.members} <:Circle:430466540442222612>.`,
data.betrayed ? "This circle got betrayed! :cry:" : "Nice! This circle is still going strong.",
discordUser.length > 0 ? `The owner of this circle is most likely ${discordUser[0]}.` : "I don't know who on Discord owns it.",
data.owner === "haykam821" ? "This a pretty rad circle for only the most elite to get into." : ""
].join("\n"),
author: {
name: `u/${data.owner}`,
url: `https://www.reddit.com/user/${data.owner}/`,
},
timestamp: data.creation_date,
}});
} catch (error) {
console.log(message.mentions)
if (message.mentions.users.array().length > 0) {
message.reply("Use the Redditor's unprefixed username, not a Discord mention.");
} else {
message.reply("Oops. Something went wrong! Try again, your input may not be valid or they don't have a circle.");
}
}
} else if (message.content.startsWith(">info")) {
await message.reply([
"Use `>circle (an unprefixed Reddit username)` such as `>circle haykam821` to get info about that circle.",
"It may be a little slow, but it should respond within 10 seconds!",
approvedGuilds.includes(message.guild.id) ? `This server has been approved to use the bot.` : "Sadly, this server has not been approved to use the bot yet. Use `>contact (a note for haykam)` to get it approved.",
"Invite me to your server: <https://discordapp.com/api/oauth2/authorize?client_id=430461416508489741&permissions=2048&scope=bot>."
].join("\n"));
} else if (message.content.startsWith(">contact ")) {
const actualContent = message.content.replace(">contact ", "");
await bot.users.get("412782876304867329").send([
`**New Contact!**`,
`In: ${message.guild.name} (\`${message.guild.id}\`)`,
`Sender: ${message.author.username} (\`${message.author.id}\`)`,
`\`\`\`md`,
actualContent,
`\`\`\``,
].join("\n"));
await message.reply("Sent to the owner!");
}
})
bot.login("NDMwNDYxNDE2NTA4NDg5NzQx.DaQiNA.O9K6NfHurvxxvlhVqDYacg1hBrI");