Add Dragon Fire to company

This commit is contained in:
Dragon Fire
2020-03-27 12:22:43 -04:00
parent 6581912013
commit 36229b9846
2 changed files with 19 additions and 7 deletions
+18 -6
View File
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const request = require('node-superfetch');
const { CLEARBIT_KEY } = process.env;
const dragonFireAliases = ['dragonfire535', 'dragon fire'];
module.exports = class CompanyCommand extends Command {
constructor(client) {
@@ -31,12 +32,8 @@ module.exports = class CompanyCommand extends Command {
async run(msg, { query }) {
try {
const { body } = await request
.get(`https://autocomplete.clearbit.com/v1/companies/suggest`)
.query({ query })
.set({ Authorization: `Bearer ${CLEARBIT_KEY}` });
if (!body.length) return msg.say('Could not find any results.');
const data = body[0];
const data = await this.fetchCompany(query);
if (!data) return msg.say('Could not find any results.');
const embed = new MessageEmbed()
.setTitle(data.name)
.setImage(data.logo)
@@ -48,4 +45,19 @@ module.exports = class CompanyCommand extends Command {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async fetchCompany(query) {
if (dragonFireAliases.includes(query.toLowerCase())) {
return {
name: 'Dragon Fire',
logo: 'https://i.imgur.com/G5BP0kB.png'
};
}
const { body } = await request
.get(`https://autocomplete.clearbit.com/v1/companies/suggest`)
.query({ query })
.set({ Authorization: `Bearer ${CLEARBIT_KEY}` });
if (!body.length) return null;
return body[0];
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "112.18.0",
"version": "112.18.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {