mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 05:54:33 +02:00
Add Dragon Fire to company
This commit is contained in:
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
|||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { CLEARBIT_KEY } = process.env;
|
const { CLEARBIT_KEY } = process.env;
|
||||||
|
const dragonFireAliases = ['dragonfire535', 'dragon fire'];
|
||||||
|
|
||||||
module.exports = class CompanyCommand extends Command {
|
module.exports = class CompanyCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -31,12 +32,8 @@ module.exports = class CompanyCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { query }) {
|
async run(msg, { query }) {
|
||||||
try {
|
try {
|
||||||
const { body } = await request
|
const data = await this.fetchCompany(query);
|
||||||
.get(`https://autocomplete.clearbit.com/v1/companies/suggest`)
|
if (!data) return msg.say('Could not find any results.');
|
||||||
.query({ query })
|
|
||||||
.set({ Authorization: `Bearer ${CLEARBIT_KEY}` });
|
|
||||||
if (!body.length) return msg.say('Could not find any results.');
|
|
||||||
const data = body[0];
|
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setTitle(data.name)
|
.setTitle(data.name)
|
||||||
.setImage(data.logo)
|
.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!`);
|
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
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "112.18.0",
|
"version": "112.18.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user