2020-12-15 01:44:28 +00:00
|
|
|
/// @ts-nocheck
|
|
|
|
import {URL} from "url";
|
|
|
|
import FileManager from "../../core/storage";
|
|
|
|
import Command from "../../core/command";
|
2021-03-30 10:25:07 +00:00
|
|
|
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.",
|
2021-03-30 10:25:07 +00:00
|
|
|
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.",
|
2021-03-30 10:25:07 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|