(.+)<\/h3>/)[1];
+ const year = text.match(/(.+)<\/h5>/)[1];
+ const description = text.match(/(.+)<\/p>/)[1];
+ const image = text.match(/
(.+)<\/a>/, '[$2]($1)'));
+ return msg.embed(embed);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
diff --git a/commands/image-edit/illegal.js b/commands/image-edit/illegal.js
index b8531941..0fb6fb14 100644
--- a/commands/image-edit/illegal.js
+++ b/commands/image-edit/illegal.js
@@ -1,6 +1,11 @@
-const Command = require('../../structures/Command');
-const request = require('node-superfetch');
-const { delay } = require('../../util/Util');
+const { Command } = require('discord.js-commando');
+const { createCanvas, loadImage, registerFont } = require('canvas');
+const { stripIndents } = require('common-tags');
+const path = require('path');
+const { shortenText } = require('../../util/Canvas');
+registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
+registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
+registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
module.exports = class IllegalCommand extends Command {
constructor(client) {
@@ -20,45 +25,32 @@ module.exports = class IllegalCommand extends Command {
key: 'text',
prompt: 'What should the text of the bill be?',
type: 'string',
- validate: text => {
- if (/^[a-zA-Z0-9 ]+$/g.test(text) && text.length < 11) return true;
- return 'Invalid text, please enter 10 or fewer basic unicode characters (A-Z, 0-9).';
- },
parse: text => text.toUpperCase()
+ },
+ {
+ key: 'verb',
+ prompt: 'Should the text use is, are, or am?',
+ type: 'string',
+ default: 'IS',
+ oneOf: ['is', 'are', 'am'],
+ parse: verb => verb.toUpperCase()
}
]
});
}
- async run(msg, { text }) {
- try {
- let gif = await this.fetchGIF(text);
- if (!gif) {
- await msg.say('Trump is busy signing the bill, please wait a moment...');
- await this.createGIF(text);
- gif = await this.fetchGIF(text);
- if (!gif) return msg.reply('Hmm... It seems Trump couldn\'t sign that bill...');
- }
- return msg.say({ files: [gif] });
- } catch (err) {
- return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
- }
- }
-
- async createGIF(text) {
- const { body } = await request
- .post('https://is-now-illegal.firebaseio.com/queue/tasks.json')
- .send({
- task: 'gif',
- word: text
- });
- await delay(5000);
- return body;
- }
-
- async fetchGIF(text) {
- const { body } = await request.get(`https://is-now-illegal.firebaseio.com/gifs/${text}.json`);
- if (!body) return null;
- return body.url;
+ async run(msg, { text, verb }) {
+ const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal.png'));
+ const canvas = createCanvas(base.width, base.height);
+ const ctx = canvas.getContext('2d');
+ ctx.drawImage(base, 0, 0);
+ ctx.rotate(7 * (Math.PI / 180));
+ ctx.font = '45px Noto';
+ ctx.fillText(stripIndents`
+ ${shortenText(ctx, text, 200)}
+ ${verb} NOW
+ ILLEGAL.
+ `, 750, 290);
+ return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] });
}
};
diff --git a/commands/number-edit/currency.js b/commands/number-edit/currency.js
index cbd96298..d33abcc9 100644
--- a/commands/number-edit/currency.js
+++ b/commands/number-edit/currency.js
@@ -43,7 +43,7 @@ module.exports = class CurrencyCommand extends Command {
if (!target) return msg.say('Invalid target.');
if (base.id === target.id) return msg.say(`Converting ${base.id} to ${target.id} is the same value, dummy.`);
const rate = await this.fetchRate(base, target);
- return msg.say(`${amount} ${base.id} is ${amount * rate} ${target.id}.`);
+ return msg.say(`${amount} ${base.id} is ${(amount * rate).toFixed(2)} ${target.id}.`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
diff --git a/commands/other/strawpoll.js b/commands/other/strawpoll.js
index 8437d6c4..fd3a9115 100644
--- a/commands/other/strawpoll.js
+++ b/commands/other/strawpoll.js
@@ -35,7 +35,11 @@ module.exports = class StrawpollCommand extends Command {
const { body } = await request
.post('https://www.strawpoll.me/api/v2/polls')
.set({ 'Content-Type': 'application/json' })
- .send({ title, options });
+ .send({
+ title,
+ options,
+ captcha: true
+ });
return msg.say(stripIndents`
${body.title}
http://www.strawpoll.me/${body.id}
diff --git a/commands/search/forecast.js b/commands/search/forecast.js
index eb1440b8..2623d06b 100644
--- a/commands/search/forecast.js
+++ b/commands/search/forecast.js
@@ -35,7 +35,7 @@ module.exports = class ForecastCommand extends Command {
const data = body.query.results.channel;
const embed = new MessageEmbed()
.setColor(0x0000FF)
- .setAuthor(data.title, 'https://i.imgur.com/B9MMbtB.png', 'https://www.yahoo.com/news/weather')
+ .setAuthor(data.title, 'https://i.imgur.com/IYF2Pfa.jpg', 'https://www.yahoo.com/news/weather')
.setURL(data.link)
.setTimestamp();
for (let i = 0; i < 7; i++) {
diff --git a/commands/search/neopets-item.js b/commands/search/neopets-item.js
index 2a14a929..bf29ceb0 100644
--- a/commands/search/neopets-item.js
+++ b/commands/search/neopets-item.js
@@ -48,7 +48,7 @@ module.exports = class NeopetsItemCommand extends Command {
});
const id = text.match(/\/item\/([0-9]+)/);
if (!id) return null;
- const price = text.match(/([0-9,]+) (NP|NC)/);
+ const price = text.match(/>([0-9,]+) (NP|NC));
const url = `https://items.jellyneo.net/item/${id[1]}/`;
const details = await request.get(url);
const detailsText = details.text;
diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js
index 679960e5..8a7c425a 100644
--- a/commands/search/wattpad.js
+++ b/commands/search/wattpad.js
@@ -42,7 +42,7 @@ module.exports = class WattpadCommand extends Command {
.setDescription(shorten(data.description))
.setThumbnail(data.cover)
.addField('❯ Creation Date', new Date(data.createDate).toDateString(), true)
- .addField('❯ Author', data.user, true)
+ .addField('❯ Author', data.user.name, true)
.addField('❯ Chapters', data.numParts, true)
.addField('❯ Reads', data.readCount, true)
.addField('❯ Votes', data.voteCount, true)
diff --git a/commands/search/weather.js b/commands/search/weather.js
index e245d67f..de66f3dd 100644
--- a/commands/search/weather.js
+++ b/commands/search/weather.js
@@ -34,7 +34,7 @@ module.exports = class WeatherCommand extends Command {
const data = body.query.results.channel;
const embed = new MessageEmbed()
.setColor(0x0000FF)
- .setAuthor(data.title, 'https://i.imgur.com/B9MMbtB.png', 'https://www.yahoo.com/news/weather')
+ .setAuthor(data.title, 'https://i.imgur.com/IYF2Pfa.jpg', 'https://www.yahoo.com/news/weather')
.setURL(data.link)
.setTimestamp()
.addField('❯ City', data.location.city, true)
diff --git a/package.json b/package.json
index 935c4f95..cca7c571 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "xiao",
- "version": "81.0.0",
+ "version": "81.0.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
(.+)<\/p>/)[1];
+ const image = text.match(/(.+)<\/a>/, '[$2]($1)'));
+ return msg.embed(embed);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
diff --git a/commands/image-edit/illegal.js b/commands/image-edit/illegal.js
index b8531941..0fb6fb14 100644
--- a/commands/image-edit/illegal.js
+++ b/commands/image-edit/illegal.js
@@ -1,6 +1,11 @@
-const Command = require('../../structures/Command');
-const request = require('node-superfetch');
-const { delay } = require('../../util/Util');
+const { Command } = require('discord.js-commando');
+const { createCanvas, loadImage, registerFont } = require('canvas');
+const { stripIndents } = require('common-tags');
+const path = require('path');
+const { shortenText } = require('../../util/Canvas');
+registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
+registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
+registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
module.exports = class IllegalCommand extends Command {
constructor(client) {
@@ -20,45 +25,32 @@ module.exports = class IllegalCommand extends Command {
key: 'text',
prompt: 'What should the text of the bill be?',
type: 'string',
- validate: text => {
- if (/^[a-zA-Z0-9 ]+$/g.test(text) && text.length < 11) return true;
- return 'Invalid text, please enter 10 or fewer basic unicode characters (A-Z, 0-9).';
- },
parse: text => text.toUpperCase()
+ },
+ {
+ key: 'verb',
+ prompt: 'Should the text use is, are, or am?',
+ type: 'string',
+ default: 'IS',
+ oneOf: ['is', 'are', 'am'],
+ parse: verb => verb.toUpperCase()
}
]
});
}
- async run(msg, { text }) {
- try {
- let gif = await this.fetchGIF(text);
- if (!gif) {
- await msg.say('Trump is busy signing the bill, please wait a moment...');
- await this.createGIF(text);
- gif = await this.fetchGIF(text);
- if (!gif) return msg.reply('Hmm... It seems Trump couldn\'t sign that bill...');
- }
- return msg.say({ files: [gif] });
- } catch (err) {
- return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
- }
- }
-
- async createGIF(text) {
- const { body } = await request
- .post('https://is-now-illegal.firebaseio.com/queue/tasks.json')
- .send({
- task: 'gif',
- word: text
- });
- await delay(5000);
- return body;
- }
-
- async fetchGIF(text) {
- const { body } = await request.get(`https://is-now-illegal.firebaseio.com/gifs/${text}.json`);
- if (!body) return null;
- return body.url;
+ async run(msg, { text, verb }) {
+ const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal.png'));
+ const canvas = createCanvas(base.width, base.height);
+ const ctx = canvas.getContext('2d');
+ ctx.drawImage(base, 0, 0);
+ ctx.rotate(7 * (Math.PI / 180));
+ ctx.font = '45px Noto';
+ ctx.fillText(stripIndents`
+ ${shortenText(ctx, text, 200)}
+ ${verb} NOW
+ ILLEGAL.
+ `, 750, 290);
+ return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] });
}
};
diff --git a/commands/number-edit/currency.js b/commands/number-edit/currency.js
index cbd96298..d33abcc9 100644
--- a/commands/number-edit/currency.js
+++ b/commands/number-edit/currency.js
@@ -43,7 +43,7 @@ module.exports = class CurrencyCommand extends Command {
if (!target) return msg.say('Invalid target.');
if (base.id === target.id) return msg.say(`Converting ${base.id} to ${target.id} is the same value, dummy.`);
const rate = await this.fetchRate(base, target);
- return msg.say(`${amount} ${base.id} is ${amount * rate} ${target.id}.`);
+ return msg.say(`${amount} ${base.id} is ${(amount * rate).toFixed(2)} ${target.id}.`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
diff --git a/commands/other/strawpoll.js b/commands/other/strawpoll.js
index 8437d6c4..fd3a9115 100644
--- a/commands/other/strawpoll.js
+++ b/commands/other/strawpoll.js
@@ -35,7 +35,11 @@ module.exports = class StrawpollCommand extends Command {
const { body } = await request
.post('https://www.strawpoll.me/api/v2/polls')
.set({ 'Content-Type': 'application/json' })
- .send({ title, options });
+ .send({
+ title,
+ options,
+ captcha: true
+ });
return msg.say(stripIndents`
${body.title}
http://www.strawpoll.me/${body.id}
diff --git a/commands/search/forecast.js b/commands/search/forecast.js
index eb1440b8..2623d06b 100644
--- a/commands/search/forecast.js
+++ b/commands/search/forecast.js
@@ -35,7 +35,7 @@ module.exports = class ForecastCommand extends Command {
const data = body.query.results.channel;
const embed = new MessageEmbed()
.setColor(0x0000FF)
- .setAuthor(data.title, 'https://i.imgur.com/B9MMbtB.png', 'https://www.yahoo.com/news/weather')
+ .setAuthor(data.title, 'https://i.imgur.com/IYF2Pfa.jpg', 'https://www.yahoo.com/news/weather')
.setURL(data.link)
.setTimestamp();
for (let i = 0; i < 7; i++) {
diff --git a/commands/search/neopets-item.js b/commands/search/neopets-item.js
index 2a14a929..bf29ceb0 100644
--- a/commands/search/neopets-item.js
+++ b/commands/search/neopets-item.js
@@ -48,7 +48,7 @@ module.exports = class NeopetsItemCommand extends Command {
});
const id = text.match(/\/item\/([0-9]+)/);
if (!id) return null;
- const price = text.match(/([0-9,]+) (NP|NC)/);
+ const price = text.match(/>([0-9,]+) (NP|NC));
const url = `https://items.jellyneo.net/item/${id[1]}/`;
const details = await request.get(url);
const detailsText = details.text;
diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js
index 679960e5..8a7c425a 100644
--- a/commands/search/wattpad.js
+++ b/commands/search/wattpad.js
@@ -42,7 +42,7 @@ module.exports = class WattpadCommand extends Command {
.setDescription(shorten(data.description))
.setThumbnail(data.cover)
.addField('❯ Creation Date', new Date(data.createDate).toDateString(), true)
- .addField('❯ Author', data.user, true)
+ .addField('❯ Author', data.user.name, true)
.addField('❯ Chapters', data.numParts, true)
.addField('❯ Reads', data.readCount, true)
.addField('❯ Votes', data.voteCount, true)
diff --git a/commands/search/weather.js b/commands/search/weather.js
index e245d67f..de66f3dd 100644
--- a/commands/search/weather.js
+++ b/commands/search/weather.js
@@ -34,7 +34,7 @@ module.exports = class WeatherCommand extends Command {
const data = body.query.results.channel;
const embed = new MessageEmbed()
.setColor(0x0000FF)
- .setAuthor(data.title, 'https://i.imgur.com/B9MMbtB.png', 'https://www.yahoo.com/news/weather')
+ .setAuthor(data.title, 'https://i.imgur.com/IYF2Pfa.jpg', 'https://www.yahoo.com/news/weather')
.setURL(data.link)
.setTimestamp()
.addField('❯ City', data.location.city, true)
diff --git a/package.json b/package.json
index 935c4f95..cca7c571 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "xiao",
- "version": "81.0.0",
+ "version": "81.0.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {