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
|
config.ts
|
||||||
node_modules/
|
node_modules/
|
||||||
build/
|
build/
|
||||||
logs/
|
logs/
|
||||||
|
.vscode
|
||||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
||||||
import Command from '../../handler/structures/Command';
|
import Command from '../../handler/structures/Command';
|
||||||
import { Context } from '../../utils/types';
|
import { Context } from '../../utils/types';
|
||||||
import { MessageEmbed } from 'discord.js';
|
import { MessageEmbed } from 'discord.js';
|
||||||
|
import request from '../../utils/animals';
|
||||||
|
|
||||||
export = class Birb extends Command {
|
export = class Birb extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -14,8 +15,7 @@ export = class Birb extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async command(ctx: Context) {
|
async command(ctx: Context) {
|
||||||
let image = await yiff.shibe("birds", 1)
|
let { image, provider } = await request('bird')
|
||||||
let provider = "shibe.online"
|
|
||||||
if (ctx.settings.embeds) {
|
if (ctx.settings.embeds) {
|
||||||
let Cat = new MessageEmbed()
|
let Cat = new MessageEmbed()
|
||||||
.setImage(image[0])
|
.setImage(image[0])
|
||||||
|
|
|
@ -2,20 +2,21 @@ import yiff from '../../utils/yiff';
|
||||||
import Command from '../../handler/structures/Command';
|
import Command from '../../handler/structures/Command';
|
||||||
import { Context } from '../../utils/types';
|
import { Context } from '../../utils/types';
|
||||||
import { MessageEmbed } from 'discord.js';
|
import { MessageEmbed } from 'discord.js';
|
||||||
|
import request from '../../utils/animals';
|
||||||
|
|
||||||
export = class Birb extends Command {
|
export = class Cat extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
name: "birb",
|
name: "cat",
|
||||||
description: "Show a Birb",
|
description: "Show a Cat",
|
||||||
aliases: ["bird", 'birds'],
|
aliases: ["mow", 'meow'],
|
||||||
cooldown: 2,
|
cooldown: 2,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async command(ctx: Context) {
|
async command(ctx: Context) {
|
||||||
let image = await yiff.shibe("birds", 1)
|
let { image, provider } = await request('shibe')
|
||||||
let provider = "shibe.online"
|
|
||||||
if (ctx.settings.embeds) {
|
if (ctx.settings.embeds) {
|
||||||
let Birb = new MessageEmbed()
|
let Birb = new MessageEmbed()
|
||||||
.setImage(image[0])
|
.setImage(image[0])
|
||||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
||||||
import Command from '../../handler/structures/Command';
|
import Command from '../../handler/structures/Command';
|
||||||
import { Context } from '../../utils/types';
|
import { Context } from '../../utils/types';
|
||||||
import { MessageEmbed } from 'discord.js';
|
import { MessageEmbed } from 'discord.js';
|
||||||
|
import request from '../../utils/animals';
|
||||||
|
|
||||||
export = class Fox extends Command {
|
export = class Fox extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -14,8 +15,8 @@ export = class Fox extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async command(ctx: Context) {
|
async command(ctx: Context) {
|
||||||
let image = await yiff.thaldrin("foxes")
|
let { image, provider } = await request('fox')
|
||||||
let provider = "thaldr.in"
|
|
||||||
|
|
||||||
if (ctx.settings.embeds) {
|
if (ctx.settings.embeds) {
|
||||||
let Fox = new MessageEmbed()
|
let Fox = new MessageEmbed()
|
||||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
||||||
import Command from '../../handler/structures/Command';
|
import Command from '../../handler/structures/Command';
|
||||||
import { Context } from '../../utils/types';
|
import { Context } from '../../utils/types';
|
||||||
import { MessageEmbed } from 'discord.js';
|
import { MessageEmbed } from 'discord.js';
|
||||||
|
import request from '../../utils/animals';
|
||||||
|
|
||||||
export = class Hyena extends Command {
|
export = class Hyena extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -14,8 +15,8 @@ export = class Hyena extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async command(ctx: Context) {
|
async command(ctx: Context) {
|
||||||
let image = await yiff.thaldrin("yeens")
|
let { image, provider } = await request('hyena')
|
||||||
let provider = "thaldr.in"
|
|
||||||
|
|
||||||
if (ctx.settings.embeds) {
|
if (ctx.settings.embeds) {
|
||||||
let Hyena = new MessageEmbed()
|
let Hyena = new MessageEmbed()
|
||||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
||||||
import Command from '../../handler/structures/Command';
|
import Command from '../../handler/structures/Command';
|
||||||
import { Context } from '../../utils/types';
|
import { Context } from '../../utils/types';
|
||||||
import { MessageEmbed } from 'discord.js';
|
import { MessageEmbed } from 'discord.js';
|
||||||
|
import request from '../../utils/animals';
|
||||||
|
|
||||||
export = class Shibe extends Command {
|
export = class Shibe extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -14,8 +15,9 @@ export = class Shibe extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async command(ctx: Context) {
|
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) {
|
if (ctx.settings.embeds) {
|
||||||
let Shibe = new MessageEmbed()
|
let Shibe = new MessageEmbed()
|
||||||
.setImage(image[0])
|
.setImage(image[0])
|
||||||
|
|
|
@ -2,6 +2,7 @@ import yiff from '../../utils/yiff';
|
||||||
import Command from '../../handler/structures/Command';
|
import Command from '../../handler/structures/Command';
|
||||||
import { Context } from '../../utils/types';
|
import { Context } from '../../utils/types';
|
||||||
import { MessageEmbed } from 'discord.js';
|
import { MessageEmbed } from 'discord.js';
|
||||||
|
import request from '../../utils/animals';
|
||||||
|
|
||||||
export = class Wolf extends Command {
|
export = class Wolf extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -14,8 +15,8 @@ export = class Wolf extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async command(ctx: Context) {
|
async command(ctx: Context) {
|
||||||
let image = await yiff.thaldrin("wolves")
|
let { image, provider } = await request('wolf')
|
||||||
let provider = "thaldr.in"
|
|
||||||
if (ctx.settings.embeds) {
|
if (ctx.settings.embeds) {
|
||||||
let Wolf = new MessageEmbed()
|
let Wolf = new MessageEmbed()
|
||||||
.setImage(image.url)
|
.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