TravBot-v3/src/commands/fun/neko.ts

29 lines
989 B
TypeScript
Raw Normal View History

2020-12-15 01:44:28 +00:00
/// @ts-nocheck
import {URL} from "url";
import FileManager from "../../core/storage";
import Command from "../../core/command";
import {getContent} from "../../core/libd";
2020-12-15 01:44:28 +00:00
const endpoints = FileManager.read("endpoints");
export default new Command({
description: "Provides you with a random image with the selected argument.",
async run($) {
2020-12-15 01:44:28 +00:00
console.log(endpoints.sfw);
$.channel.send(
2020-12-15 07:56:09 +00:00
`Please provide an image type. Available arguments:\n\`[${Object.keys(endpoints.sfw).join(", ")}]\`.`
2020-12-15 01:44:28 +00:00
);
},
any: new Command({
description: "Image type to send.",
async run($) {
2020-12-15 07:56:09 +00:00
if (!($.args[0] in endpoints.sfw)) return $.channel.send("Couldn't find that endpoint!");
2020-12-15 01:44:28 +00:00
let baseURL = "https://nekos.life/api/v2";
let url = new URL(`${baseURL}${endpoints.sfw[$.args[0]]}`);
const content = await getContent(url.toString());
$.channel.send(content.url);
}
})
});