Added Discord.JS Docs module

This commit is contained in:
Lexi Sother 2021-04-01 16:55:09 +02:00
parent 04e817908e
commit 5e51e3273f
No known key found for this signature in database
GPG Key ID: 355968D14144B739
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,11 @@
{
"main": "index.js",
"name": "Discord.JS Docs",
"description": "Queries the Discord.JS Documentation",
"tags": ["commands"],
"authors": ["465702500146610176"],
"version": "1.0.0"
}

61
D.JS-Docs/index.js Normal file
View File

@ -0,0 +1,61 @@
import { commands, internalMessage } from '@goosemod/patcher';
const get = (url, callback) => {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = () => {
var status = xhr.status;
if (status == 200) {
callback(null, xhr.response);
} else {
callback(status);
}
};
xhr.send();
};
export default {
goosemodHandlers: {
onImport: () => {
commands.add(
'echo',
"Prints out all of the message's text in an internal message.",
(args) => {
internalMessage(args.text[0].text);
console.log(args);
},
[
{
type: 3,
name: 'text',
description: 'Text to be printed in an internal message.',
required: true,
},
],
);
commands.add(
'docs',
'Sends documentation about the specified query.',
(args) => {
var queryString = args.query[0].text;
get(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${queryString}`, (err, data) => {
if (err != null) {
console.error(err);
} else {
data['type'] = 'rich';
internalMessage(data);
}
});
},
[{ type: 3, name: 'query', description: 'What to query the docs with.', required: true }],
);
},
onRemove: () => {
commands.remove('echo');
},
},
};