mirror of https://github.com/thaldrin/thaldrin.git
unify animal image commands to use a single function
This commit is contained in:
parent
f445bdf987
commit
39b8e045d5
|
@ -1,4 +1,5 @@
|
|||
config.ts
|
||||
node_modules/
|
||||
build/
|
||||
logs/
|
||||
logs/
|
||||
.vscode
|
||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
|||
import Command from '../../handler/structures/Command';
|
||||
import { Context } from '../../utils/types';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import request from '../../utils/animals';
|
||||
|
||||
export = class Birb extends Command {
|
||||
constructor() {
|
||||
|
@ -14,8 +15,7 @@ export = class Birb extends Command {
|
|||
}
|
||||
|
||||
async command(ctx: Context) {
|
||||
let image = await yiff.shibe("birds", 1)
|
||||
let provider = "shibe.online"
|
||||
let { image, provider } = await request('bird')
|
||||
if (ctx.settings.embeds) {
|
||||
let Cat = new MessageEmbed()
|
||||
.setImage(image[0])
|
||||
|
|
|
@ -2,20 +2,21 @@ import yiff from '../../utils/yiff';
|
|||
import Command from '../../handler/structures/Command';
|
||||
import { Context } from '../../utils/types';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import request from '../../utils/animals';
|
||||
|
||||
export = class Birb extends Command {
|
||||
export = class Cat extends Command {
|
||||
constructor() {
|
||||
super({
|
||||
name: "birb",
|
||||
description: "Show a Birb",
|
||||
aliases: ["bird", 'birds'],
|
||||
name: "cat",
|
||||
description: "Show a Cat",
|
||||
aliases: ["mow", 'meow'],
|
||||
cooldown: 2,
|
||||
})
|
||||
}
|
||||
|
||||
async command(ctx: Context) {
|
||||
let image = await yiff.shibe("birds", 1)
|
||||
let provider = "shibe.online"
|
||||
let { image, provider } = await request('shibe')
|
||||
|
||||
if (ctx.settings.embeds) {
|
||||
let Birb = new MessageEmbed()
|
||||
.setImage(image[0])
|
||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
|||
import Command from '../../handler/structures/Command';
|
||||
import { Context } from '../../utils/types';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import request from '../../utils/animals';
|
||||
|
||||
export = class Fox extends Command {
|
||||
constructor() {
|
||||
|
@ -14,8 +15,8 @@ export = class Fox extends Command {
|
|||
}
|
||||
|
||||
async command(ctx: Context) {
|
||||
let image = await yiff.thaldrin("foxes")
|
||||
let provider = "thaldr.in"
|
||||
let { image, provider } = await request('fox')
|
||||
|
||||
|
||||
if (ctx.settings.embeds) {
|
||||
let Fox = new MessageEmbed()
|
||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
|||
import Command from '../../handler/structures/Command';
|
||||
import { Context } from '../../utils/types';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import request from '../../utils/animals';
|
||||
|
||||
export = class Hyena extends Command {
|
||||
constructor() {
|
||||
|
@ -14,8 +15,8 @@ export = class Hyena extends Command {
|
|||
}
|
||||
|
||||
async command(ctx: Context) {
|
||||
let image = await yiff.thaldrin("yeens")
|
||||
let provider = "thaldr.in"
|
||||
let { image, provider } = await request('hyena')
|
||||
|
||||
|
||||
if (ctx.settings.embeds) {
|
||||
let Hyena = new MessageEmbed()
|
||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
|||
import Command from '../../handler/structures/Command';
|
||||
import { Context } from '../../utils/types';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import request from '../../utils/animals';
|
||||
|
||||
export = class Shibe extends Command {
|
||||
constructor() {
|
||||
|
@ -14,8 +15,9 @@ export = class Shibe extends Command {
|
|||
}
|
||||
|
||||
async command(ctx: Context) {
|
||||
let image = await yiff.shibe("shibes", 1)
|
||||
let provider = "shibe.online"
|
||||
|
||||
let { image, provider } = await request('shibe')
|
||||
|
||||
if (ctx.settings.embeds) {
|
||||
let Shibe = new MessageEmbed()
|
||||
.setImage(image[0])
|
||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
|||
import Command from '../../handler/structures/Command';
|
||||
import { Context } from '../../utils/types';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import request from '../../utils/animals';
|
||||
|
||||
export = class Wolf extends Command {
|
||||
constructor() {
|
||||
|
@ -14,8 +15,8 @@ export = class Wolf extends Command {
|
|||
}
|
||||
|
||||
async command(ctx: Context) {
|
||||
let image = await yiff.thaldrin("wolves")
|
||||
let provider = "thaldr.in"
|
||||
let { image, provider } = await request('wolf')
|
||||
|
||||
if (ctx.settings.embeds) {
|
||||
let Wolf = new MessageEmbed()
|
||||
.setImage(image.url)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import yiff from "./yiff";
|
||||
|
||||
type animal = "bird" | "cat" | "fox" | "hyena" | "shibe" | "wolf";
|
||||
|
||||
export default async function request(animal: animal) {
|
||||
switch (animal) {
|
||||
case "shibe":
|
||||
return { image: await yiff.shibe("shibes", 1), provider: "shibe.online" };
|
||||
case "bird":
|
||||
return { image: await yiff.shibe("birds", 1), provider: "shibe.online" };
|
||||
case "cat":
|
||||
return { image: await yiff.shibe("cats", 1), provider: "shibe.online" };
|
||||
case "fox":
|
||||
return { image: await yiff.thaldrin("foxes"), provider: "thaldr.in" };
|
||||
case "hyena":
|
||||
return { image: await yiff.thaldrin("yeens"), provider: "thaldr.in" };
|
||||
case "wolf":
|
||||
return { image: await yiff.thaldrin("wolves"), provider: "thaldr.in" };
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue