mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 14:21:41 +02:00
Kingdom Hearts Wiki Command
This commit is contained in:
@@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with
|
|||||||
The bot is no longer available for invite. You can self-host the bot, or use her
|
The bot is no longer available for invite. You can self-host the bot, or use her
|
||||||
on the [home server](https://discord.gg/sbMe32W).
|
on the [home server](https://discord.gg/sbMe32W).
|
||||||
|
|
||||||
## Commands (301)
|
## Commands (302)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **eval:** Executes JavaScript code.
|
* **eval:** Executes JavaScript code.
|
||||||
@@ -137,6 +137,7 @@ on the [home server](https://discord.gg/sbMe32W).
|
|||||||
* **imgur:** Searches Imgur for your query.
|
* **imgur:** Searches Imgur for your query.
|
||||||
* **itunes:** Searches iTunes for your query.
|
* **itunes:** Searches iTunes for your query.
|
||||||
* **jisho:** Defines a word, but with Japanese.
|
* **jisho:** Defines a word, but with Japanese.
|
||||||
|
* **kh-wiki**: Searches the Kingdom Hearts Wiki for your query.
|
||||||
* **kickstarter:** Searches Kickstarter for your query.
|
* **kickstarter:** Searches Kickstarter for your query.
|
||||||
* **league-of-legends-champion:** Responds with information on a League of Legends champion.
|
* **league-of-legends-champion:** Responds with information on a League of Legends champion.
|
||||||
* **map:** Responds with a map of a specific location.
|
* **map:** Responds with a map of a specific location.
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const { shorten } = require('../../util/Util');
|
||||||
|
|
||||||
|
module.exports = class KhWikiCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'kh-wiki',
|
||||||
|
aliases: ['kingdom-hearts-wiki', 'kh-wiki-article', 'kingdom-hearts-wiki-article'],
|
||||||
|
group: 'search',
|
||||||
|
memberName: 'kh-wiki',
|
||||||
|
description: 'Searches the Kingdom Hearts Wiki for your query.',
|
||||||
|
clientPermissions: ['EMBED_LINKS'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'query',
|
||||||
|
prompt: 'What article would you like to search for?',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { query }) {
|
||||||
|
try {
|
||||||
|
const { body } = await request
|
||||||
|
.get('https://www.khwiki.com/api.php')
|
||||||
|
.query({
|
||||||
|
action: 'query',
|
||||||
|
prop: 'extracts|pageimages',
|
||||||
|
format: 'json',
|
||||||
|
titles: query,
|
||||||
|
exintro: '',
|
||||||
|
explaintext: '',
|
||||||
|
pithumbsize: 150,
|
||||||
|
redirects: '',
|
||||||
|
formatversion: 2
|
||||||
|
});
|
||||||
|
const data = body.query.pages[0];
|
||||||
|
if (data.missing) return msg.say('Could not find any results.');
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor(0x0679BC)
|
||||||
|
.setTitle(data.title)
|
||||||
|
.setAuthor('Kingdom Hearts Wiki', 'https://i.imgur.com/OZhrA41.jpg', 'https://www.khwiki.com/')
|
||||||
|
.setThumbnail(data.thumbnail ? data.thumbnail.source : null)
|
||||||
|
.setURL(`https://www.khwiki.com/${encodeURIComponent(query).replace(/\)/g, '%29')}`)
|
||||||
|
.setDescription(shorten(data.extract.replace(/.+\n\n/, '').replace(/\n/g, '\n\n')));
|
||||||
|
return msg.embed(embed);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "90.3.7",
|
"version": "90.4.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user