mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 06:45:31 +02:00
MDN Command
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class MDNCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'mdn',
|
||||
aliases: ['mozilla-developer-network'],
|
||||
group: 'search',
|
||||
memberName: 'mdn',
|
||||
description: 'Searches MDN for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What article would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://developer.mozilla.org/en-US/search.json')
|
||||
.query({ q: query });
|
||||
if (!body.documents.length) return msg.say('Could not find any results.');
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x066FAD)
|
||||
.setAuthor('MDN', 'https://i.imgur.com/ClMfs9l.png')
|
||||
.setURL(body.documents[0].url)
|
||||
.setTitle(body.documents[0].title)
|
||||
.setDescription(body.documents[0].excerpt);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -7,6 +7,7 @@ module.exports = class OsuCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'osu',
|
||||
aliases: ['osu-user'],
|
||||
group: 'search',
|
||||
memberName: 'osu',
|
||||
description: 'Searches osu! usernames for your query.',
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "38.7.3",
|
||||
"version": "38.8.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user