mirror of
https://github.com/NovaGM/Modules.git
synced 2024-08-14 22:47:01 +00:00
Added Discord.JS Docs module
This commit is contained in:
parent
04e817908e
commit
5e51e3273f
2 changed files with 72 additions and 0 deletions
11
D.JS-Docs/goosemodModule.json
Normal file
11
D.JS-Docs/goosemodModule.json
Normal 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
61
D.JS-Docs/index.js
Normal 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');
|
||||
},
|
||||
},
|
||||
};
|
Loading…
Reference in a new issue