87 lines
2.2 KiB
JavaScript
87 lines
2.2 KiB
JavaScript
const fetch = require('node-fetch');
|
|
|
|
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',
|
|
usage: "<invite-code>",
|
|
showUsage: true,
|
|
parameterType: 'PLAIN',
|
|
examples: [
|
|
"SvJgtEj",
|
|
"discord.gg/SvJgtEj"
|
|
],
|
|
restricted: true, //For now
|
|
// throttling: {
|
|
// usages: 1,
|
|
// duration: 30
|
|
// }
|
|
});
|
|
|
|
this.client = client;
|
|
|
|
|
|
}
|
|
|
|
async execute(message, { params }) {
|
|
|
|
|
|
const invite = await this.client.fetchInvite(params)
|
|
.catch((error) => {
|
|
console.error(error);
|
|
});
|
|
|
|
let fields = [];
|
|
|
|
if(invite.inviter) {
|
|
fields.push({
|
|
name: "Inviter",
|
|
value: `${invite.inviter.username}#${invite.inviter.discriminator} \`(${invite.inviter.id})\``,
|
|
inline: true
|
|
});
|
|
}
|
|
|
|
if(invite.channel) {
|
|
fields.push({
|
|
name: "Default Channel",
|
|
value: `#${invite.channel.name} \`(${invite.channel.id})\``,
|
|
inline: true
|
|
});
|
|
}
|
|
|
|
if(invite?.guild?.features.length > 0) {
|
|
fields.push({
|
|
name: "Features",
|
|
value: invite.guild.features.map(f=>`\`${f}\``).join(', '),
|
|
inline: true,
|
|
});
|
|
}
|
|
|
|
const embed = {
|
|
author: {
|
|
name: `${invite.guild.name} (${invite.guild.id})`,
|
|
icon_url: invite.guild.iconURL()
|
|
},
|
|
thumbnail: {
|
|
url: invite.guild.splash ? invite.guild.splashURL() : null
|
|
},
|
|
description: invite.guild.description || null,
|
|
fields,
|
|
footer: {
|
|
text: ` https://discord.gg/${invite.code}`
|
|
}
|
|
};
|
|
|
|
return message.embed(embed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = LookupCommand; |