Add sources for Xiao artwork

This commit is contained in:
Dragon Fire
2024-03-30 13:45:38 -04:00
parent ec38daefa3
commit 7c7c774f4c
37 changed files with 14 additions and 1 deletions
+14 -1
View File
@@ -2,6 +2,7 @@ const Command = require('../../framework/Command');
const fs = require('fs');
const path = require('path');
const images = fs.readdirSync(path.join(__dirname, '..', '..', 'assets', 'images', 'xiao'));
const sourceRegex = /([A-Z ]+)-?([0-9A-Z]+)?(-[0-9]+)?(\.[A-Z])?/i;
module.exports = class XiaoCommand extends Command {
constructor(client) {
@@ -25,6 +26,18 @@ module.exports = class XiaoCommand extends Command {
run(msg) {
const image = images[Math.floor(Math.random() * images.length)];
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'xiao', image)] });
return msg.say(this.getSource(image), {
files: [path.join(__dirname, '..', '..', 'assets', 'images', 'xiao', image)]
});
}
getSource(img) {
const source = img.match(sourceRegex);
const site = source[1];
if (site === 'unknown') return 'Artist Unknown';
if (site === 'official') return 'Official Art';
if (site === 'deviant') return `Art by <https://www.deviantart.com/${source[2]}>`;
if (site === 'pixiv') return `Art Source: <https://www.pixiv.net/en/artworks/${source[2]}>`;
return `Art by ${site}`;
}
};