mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Tiff and Eve Command
This commit is contained in:
@@ -115,7 +115,7 @@ Only if you want to use the DECTalk command.
|
||||
18. Start Xiao up!
|
||||
|
||||
## Commands
|
||||
Total: 515
|
||||
Total: 516
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -292,6 +292,7 @@ Total: 515
|
||||
* **npm:** Responds with information on an NPM package.
|
||||
* **periodic-table:** Finds an element on the periodic table.
|
||||
* **rule:** Responds with a rule of the internet.
|
||||
* **tiff-and-eve:** Responds with a Tiff and Eve comic, either today's, a random one, or a specific one.
|
||||
* **urban:** Defines a word, but with Urban Dictionary.
|
||||
* **wikipedia:** Searches Wikipedia for your query.
|
||||
* **xkcd:** Responds with an XKCD comic, either today's, a random one, or a specific one.
|
||||
@@ -926,6 +927,8 @@ Total: 515
|
||||
* **periodic-table:**
|
||||
- [Bowserinator](https://github.com/Bowserinator/) ([Periodic Table Data](https://github.com/Bowserinator/Periodic-Table-JSON))
|
||||
- [Google](https://www.google.com/) ([Noto Font](https://fonts.google.com/noto))
|
||||
* **tiff-and-eve:**
|
||||
- [Fran Sundblad](https://www.fransundblad.com/) ([Original Comic](https://www.fransundblad.com/tiff-and-eve/))
|
||||
* **urban:**
|
||||
- [Urban Dictionary](https://www.urbandictionary.com/) ([API](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation))
|
||||
* **wikipedia:**
|
||||
|
||||
@@ -126,5 +126,9 @@
|
||||
"Friends long absent are coming back to you.",
|
||||
"You will be showered with good luck.",
|
||||
"Good news will come to you from far away.",
|
||||
"There is a prospect of a thrilling time ahead for you."
|
||||
"There is a prospect of a thrilling time ahead for you.",
|
||||
"Your dreams are the guiding lights in the darkness.",
|
||||
"The future is not predetermined, but your actions determine your destiny.",
|
||||
"Your finances will be a stepping stone to financial success.",
|
||||
"Follow the path of self-discovery; it leads to authenticity."
|
||||
]
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { EmbedBuilder, PermissionFlagsBits } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
const { decode: decodeHTML } = require('html-entities');
|
||||
const { oneLine } = require('common-tags');
|
||||
const types = ['random', 'today'];
|
||||
|
||||
module.exports = class TiffAndEveCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tiff-and-eve',
|
||||
aliases: ['tiff-eve', 'tiff', 'tae'],
|
||||
group: 'search',
|
||||
description: 'Responds with a Tiff and Eve comic, either today\'s, a random one, or a specific one.',
|
||||
clientPermissions: [PermissionFlagsBits.EmbedLinks],
|
||||
credit: [
|
||||
{
|
||||
name: 'Fran Sundblad',
|
||||
url: 'https://www.fransundblad.com/',
|
||||
reason: 'Original Comic',
|
||||
reasonURL: 'https://www.fransundblad.com/tiff-and-eve/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
type: 'string',
|
||||
default: 'today',
|
||||
validate: query => {
|
||||
if (types.includes(query.toLowerCase())) return true;
|
||||
const num = Number.parseInt(query, 10);
|
||||
if (!Number.isNaN(num) && num > 1) return true;
|
||||
return `Invalid query, please enter either today, random, or a specific comic number.`;
|
||||
},
|
||||
parse: query => query.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
const { text: currentText } = await request.get('https://www.fransundblad.com/tiff-and-eve/');
|
||||
const $current = cheerio.load(currentText);
|
||||
const current = Number.parseInt($current('h6.colibri-word-wrap').first().text().trim().match(/(\d+)/)[1], 10);
|
||||
if (query === 'today') {
|
||||
const title = decodeHTML($current('h1.colibri-word-wrap').first().text().trim());
|
||||
const image = $current('img.attachment-full.size-full').first().attr('src');
|
||||
const alt = oneLine(decodeHTML($current('div.colibri-post-excerpt').first().text().trim()));
|
||||
const date = $current('div.metadata-item').eq(1).text().trim();
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${date} - ${title}`)
|
||||
.setColor(0x9797FF)
|
||||
.setURL(`https://www.fransundblad.com/tiff-and-eve/${current}/`)
|
||||
.setImage(image)
|
||||
.setFooter({ text: alt });
|
||||
return msg.embed(embed);
|
||||
}
|
||||
if (query === 'random') {
|
||||
const random = Math.floor(Math.random() * (current + 1));
|
||||
const { text } = await request.get(`https://www.fransundblad.com/tiff-and-eve/${random}/`);
|
||||
const $ = cheerio.load(text);
|
||||
const title = decodeHTML($('h1.colibri-word-wrap').first().text().trim());
|
||||
const image = $('img.attachment-full.size-full').first().attr('src');
|
||||
const alt = oneLine(decodeHTML($('div.colibri-post-excerpt').first().text().trim()));
|
||||
const date = $('div.metadata-item').eq(1).text().trim();
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${date} - ${title}`)
|
||||
.setColor(0x9797FF)
|
||||
.setURL(`https://www.fransundblad.com/tiff-and-eve/${random}/`)
|
||||
.setImage(image)
|
||||
.setFooter({ text: alt });
|
||||
return msg.embed(embed);
|
||||
}
|
||||
const choice = Number.parseInt(query, 10);
|
||||
if (current < choice) return msg.say('Could not find any results.');
|
||||
const { text } = await request.get(`https://www.fransundblad.com/tiff-and-eve/${choice}/`);
|
||||
const $ = cheerio.load(text);
|
||||
const title = decodeHTML($('h1.colibri-word-wrap').first().text().trim());
|
||||
const image = $('img.attachment-full.size-full').first().attr('src');
|
||||
const alt = oneLine(decodeHTML($('div.colibri-post-excerpt').first().text().trim()));
|
||||
const date = $('div.metadata-item').eq(1).text().trim();
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${date} - ${title}`)
|
||||
.setColor(0x9797FF)
|
||||
.setURL(`https://www.fransundblad.com/tiff-and-eve/${choice}/`)
|
||||
.setImage(image)
|
||||
.setFooter({ text: alt });
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "159.2.0",
|
||||
"version": "159.3.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
@@ -31,11 +31,11 @@
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.10.0",
|
||||
"@discordjs/voice": "^0.19.0",
|
||||
"@dotenvx/dotenvx": "^1.51.0",
|
||||
"@dotenvx/dotenvx": "^1.51.2",
|
||||
"@mediapipe/face_detection": "^0.4.1646425229",
|
||||
"@napi-rs/canvas": "^0.1.81",
|
||||
"@napi-rs/canvas": "^0.1.86",
|
||||
"@skyra/gifenc": "^1.0.1",
|
||||
"@snazzah/davey": "^0.1.7",
|
||||
"@snazzah/davey": "^0.1.9",
|
||||
"@tensorflow-models/face-detection": "^1.0.3",
|
||||
"@tensorflow/tfjs-node": "^4.22.0",
|
||||
"@twemoji/parser": "^17.0.1",
|
||||
@@ -48,7 +48,7 @@
|
||||
"connect4-ai": "^0.1.3",
|
||||
"custom-translate": "^2.2.9",
|
||||
"didyoumean2": "^7.0.4",
|
||||
"discord.js": "^14.24.2",
|
||||
"discord.js": "^14.25.1",
|
||||
"emoji-regex": "^10.6.0",
|
||||
"everything-json": "^1.2.1",
|
||||
"fen-validator": "^2.0.1",
|
||||
@@ -61,7 +61,7 @@
|
||||
"jszip": "^3.10.1",
|
||||
"kuroshiro": "^1.2.0",
|
||||
"kuroshiro-analyzer-kuromoji": "^1.1.0",
|
||||
"mathjs": "^15.0.0",
|
||||
"mathjs": "^15.1.0",
|
||||
"minimist": "^1.2.8",
|
||||
"moment": "^2.30.1",
|
||||
"moment-duration-format": "^2.3.2",
|
||||
@@ -72,7 +72,7 @@
|
||||
"ntcjs": "^1.1.3",
|
||||
"parse-domain": "^8.2.2",
|
||||
"pokersolver": "^2.1.4",
|
||||
"qr": "^0.5.2",
|
||||
"qr": "^0.5.3",
|
||||
"random-js": "^2.1.0",
|
||||
"sagiri": "^4.3.0",
|
||||
"semver": "^7.7.3",
|
||||
@@ -84,19 +84,19 @@
|
||||
"user-agents": "^1.1.669",
|
||||
"valid-url": "^1.0.9",
|
||||
"wavefile": "^11.0.0",
|
||||
"winston": "^3.18.3",
|
||||
"winston": "^3.19.0",
|
||||
"wuzzy": "^0.1.8",
|
||||
"zip-to-timezone": "^1.2.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"bufferutil": "^4.0.9",
|
||||
"sodium-native": "^5.0.9",
|
||||
"utf-8-validate": "^6.0.5",
|
||||
"bufferutil": "^4.1.0",
|
||||
"sodium-native": "^5.0.10",
|
||||
"utf-8-validate": "^6.0.6",
|
||||
"zlib-sync": "^0.1.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.0",
|
||||
"eslint": "^9.39.0",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-amber": "^2.0.5",
|
||||
"eslint-plugin-jsonc": "^2.21.0",
|
||||
"globals": "^16.5.0"
|
||||
|
||||
Reference in New Issue
Block a user