FridayNightFunkinBoyfriendBot/commands/wiki.js

47 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-12-17 14:55:27 -05:00
const wiki = require('wikipedia') //
const CommandError = require('../CommandModules/command_error')
2023-12-17 14:55:27 -05:00
module.exports = {
name: 'wiki',
description:['wikipedia'],
2023-12-20 11:54:03 -05:00
trustLevel: 0,
2023-12-17 14:55:27 -05:00
aliases:['wikipedia'],
async execute (context) {
const source = context.source
const args = context.arguments
const bot = context.bot
const ChatMessage = require('prismarine-chat')(bot.options.version)
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
const cmd = {
2023-12-17 14:55:27 -05:00
translate: '[%s] ',
bold: false,
color: 'white',
with: [
{ color: 'dark_green', text: 'Wiki Cmd'},
]
}
try {
const page = await wiki.page(args.join(' '))
// const summary = await page.images()
const summary2 = await page.intro()
//const definitions = await urban.define(args.join(' '))
/// console.log(summary)
// source.sendFeedback({ text: JSON.stringify(summary), color: 'green' })
2024-01-27 11:15:45 -05:00
if (!bot.options.Core.enabled){
bot.chat(ChatMessage.fromNotch(await sleep(500)
?? [cmd, { text:summary2, color: 'gray' }]).toMotd().replaceAll('§', '&'))
}else{
2023-12-17 14:55:27 -05:00
source.sendFeedback([cmd,{ text:`${summary2}`, color: 'green' }])
}
2023-12-17 14:55:27 -05:00
} catch (e) {
2024-01-27 11:15:45 -05:00
if(!bot.options.Core.enabled){
bot.chat(ChatMessage.fromNotch([cmd, { text: `${e.toString()}`, color: 'red' }]).toMotd().replaceAll('§', '&'))
}else{
2023-12-17 14:55:27 -05:00
source.sendFeedback([cmd, { text: `${e}`, color: 'red' }])
}
}
}
}