2020-05-17 15:07:39 +02:00
|
|
|
const { Command } = require('../../../../interfaces/');
|
|
|
|
|
|
|
|
//Apparently hit ratelimits pretty damn quick and doesn't expire often.
|
|
|
|
class LookupCommand extends Command {
|
|
|
|
|
|
|
|
constructor(client) {
|
|
|
|
|
|
|
|
super(client, {
|
|
|
|
name: 'lookup',
|
|
|
|
module: 'utility',
|
2020-07-04 12:23:10 +02:00
|
|
|
usage: "<discord-invite>",
|
2020-05-17 15:07:39 +02:00
|
|
|
showUsage: true,
|
|
|
|
examples: [
|
|
|
|
"SvJgtEj",
|
|
|
|
"discord.gg/SvJgtEj"
|
|
|
|
],
|
2020-08-08 00:21:28 +02:00
|
|
|
restricted: true //For now
|
2020-05-18 01:13:24 +02:00
|
|
|
// throttling: {
|
|
|
|
// usages: 1,
|
|
|
|
// duration: 30
|
|
|
|
// }
|
2020-05-17 15:07:39 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
this.client = client;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
async execute(message, { params }) {
|
|
|
|
|
2020-07-04 12:23:10 +02:00
|
|
|
let invite = null;
|
|
|
|
try {
|
2020-08-08 00:21:28 +02:00
|
|
|
invite = await this.client.fetchInvite(params);
|
2020-07-04 12:23:10 +02:00
|
|
|
} catch(e) {
|
|
|
|
return message.respond(message.format('C_LOOKUP_FAILEDMATCH'), {
|
|
|
|
emoji: 'failure'
|
2020-05-18 01:13:24 +02:00
|
|
|
});
|
2020-07-04 12:23:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
console.log(invite);
|
2020-05-17 15:07:39 +02:00
|
|
|
|
2020-08-08 00:21:28 +02:00
|
|
|
const fields = [];
|
2020-05-17 15:07:39 +02:00
|
|
|
|
2020-05-18 01:13:24 +02:00
|
|
|
if(invite.inviter) {
|
2020-05-17 15:07:39 +02:00
|
|
|
fields.push({
|
|
|
|
name: "Inviter",
|
2020-08-08 00:21:28 +02:00
|
|
|
value: `${invite.inviter.username}#${invite.inviter.discriminator} \`(${invite.inviter.id})\``,
|
2020-05-17 15:07:39 +02:00
|
|
|
inline: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-04 12:23:10 +02:00
|
|
|
if(invite.memberCount) {
|
|
|
|
fields.push({
|
|
|
|
name: "Member Count",
|
|
|
|
value: `${invite.memberCount} members`,
|
|
|
|
inline: true
|
2020-08-08 00:21:28 +02:00
|
|
|
});
|
2020-07-04 12:23:10 +02:00
|
|
|
}
|
|
|
|
|
2020-05-18 01:13:24 +02:00
|
|
|
if(invite.channel) {
|
2020-05-17 15:07:39 +02:00
|
|
|
fields.push({
|
|
|
|
name: "Default Channel",
|
2020-05-18 01:13:24 +02:00
|
|
|
value: `#${invite.channel.name} \`(${invite.channel.id})\``,
|
2020-05-17 15:07:39 +02:00
|
|
|
inline: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-05-18 01:13:24 +02:00
|
|
|
if(invite?.guild?.features.length > 0) {
|
2020-05-17 15:07:39 +02:00
|
|
|
fields.push({
|
|
|
|
name: "Features",
|
2020-08-08 00:21:28 +02:00
|
|
|
value: invite.guild.features.map((f) => `\`${f}\``).join(', '),
|
|
|
|
inline: true
|
2020-05-17 15:07:39 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const embed = {
|
|
|
|
author: {
|
2020-05-18 01:13:24 +02:00
|
|
|
name: `${invite.guild.name} (${invite.guild.id})`,
|
2020-08-08 00:21:28 +02:00
|
|
|
icon_url: invite.guild.iconURL() //eslint-disable-line camelcase
|
2020-05-17 15:07:39 +02:00
|
|
|
},
|
|
|
|
thumbnail: {
|
2020-08-08 00:21:28 +02:00
|
|
|
url: invite.guild.splash ? invite.guild.splashURL() : invite.guild.iconURL()
|
2020-05-17 15:07:39 +02:00
|
|
|
},
|
2020-05-18 01:13:24 +02:00
|
|
|
description: invite.guild.description || null,
|
2020-05-17 15:07:39 +02:00
|
|
|
fields,
|
|
|
|
footer: {
|
2020-05-18 01:13:24 +02:00
|
|
|
text: ` https://discord.gg/${invite.code}`
|
2020-05-17 15:07:39 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return message.embed(embed);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = LookupCommand;
|