TravBot-v3/src/commands/utility/docs.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

import {NamedCommand, RestCommand} from "onion-lasers";
2021-04-11 08:58:06 +00:00
import {URL} from "url";
import {getContent} from "../../lib";
export default new NamedCommand({
description: "Provides you with info from the Discord.JS docs.",
run: "You need to specify a term to query the docs with.",
any: new RestCommand({
description: "What to query the docs with.",
async run({send, author, args}) {
2021-04-11 08:58:06 +00:00
var queryString = args[0];
let url = new URL(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${queryString}`);
const content = await getContent(url.toString());
const msg = await send({embeds: [content]});
const react = await msg.react("❌");
const collector = msg.createReactionCollector({
filter: (reaction, user) => {
if (user.id === author.id && reaction.emoji.name === "❌") msg.delete();
return false;
},
time: 60000
});
collector.on("end", () => {
2021-04-12 18:46:20 +00:00
if (!msg.deleted) react.users.remove(msg.author);
});
2021-04-11 08:58:06 +00:00
}
})
});