2022-08-14 05:51:45 -04:00
|
|
|
/* eslint-disable max-len */
|
|
|
|
const wiki = require('wikipedia');
|
|
|
|
const util = require('util');
|
|
|
|
const {MessageEmbed} = require('discord.js');
|
|
|
|
module.exports = {
|
|
|
|
name: 'wikipedia',
|
|
|
|
alias: ['wiki'],
|
2022-08-19 02:49:37 -04:00
|
|
|
description: 'Working Wikipedia!',
|
2022-11-13 02:41:59 -05:00
|
|
|
usage: '<page>',
|
2022-08-14 05:51:45 -04:00
|
|
|
trusted: 0,
|
2022-11-16 20:49:50 -05:00
|
|
|
execute: async function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
2022-08-14 05:51:45 -04:00
|
|
|
try {
|
|
|
|
const page = await wiki.page(args.join(' '));
|
|
|
|
const summary = await page.summary();
|
2022-11-16 06:41:30 -05:00
|
|
|
bot.tellraw(selector, {text: summary.extract, color: 'green'});
|
2022-08-14 05:51:45 -04:00
|
|
|
} catch (e) {
|
2022-11-16 06:41:30 -05:00
|
|
|
bot.tellraw(selector, {text: e.toString(), color: 'red'});
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
|
|
|
try {
|
|
|
|
const page = await wiki.page(args.join(' '));
|
|
|
|
const summary = await page.summary();
|
|
|
|
const Embed = new MessageEmbed()
|
|
|
|
.setColor('#FFFF00')
|
|
|
|
.setTitle('Output')
|
|
|
|
.setDescription(summary.extract);
|
|
|
|
channeldc.send({embeds: [Embed]});
|
|
|
|
} catch (e) {
|
|
|
|
const Embed = new MessageEmbed()
|
|
|
|
.setColor('#FF0000')
|
|
|
|
.setTitle('Error')
|
|
|
|
.setDescription(`\`\`\`${util.inspect(e)}\`\`\``);
|
|
|
|
channeldc.send({embeds: [Embed]});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|