Tsubaki, Native Image Reading
|
After Width: | Height: | Size: 271 KiB |
|
After Width: | Height: | Size: 301 KiB |
|
After Width: | Height: | Size: 554 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 368 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 875 KiB |
@@ -1,6 +1,9 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class YearsCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -37,11 +40,8 @@ module.exports = class YearsCommand extends Command {
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.drawImage(avatar, 461, 127, 200, 200);
|
||||
};
|
||||
const azImg = await request
|
||||
.get('https://i.imgur.com/eScwGFS.png');
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
base.src = azImg.body;
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', '3000years.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'az.png' }] })
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class BeautifulCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -36,13 +39,10 @@ module.exports = class BeautifulCommand extends Command {
|
||||
const generate = () => {
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.drawImage(avatar, 341, 35, 117, 135);
|
||||
ctx.drawImage(avatar, 342, 301, 117, 135);
|
||||
ctx.drawImage(avatar, 342, 303, 117, 135);
|
||||
};
|
||||
const grunkleImg = await request
|
||||
.get('https://i.imgur.com/71qLwPf.png');
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
base.src = grunkleImg.body;
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'beautiful.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'grunkle.png' }] })
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class BobRossCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -41,11 +44,8 @@ module.exports = class BobRossCommand extends Command {
|
||||
ctx.rotate(-3 * Math.PI / 180);
|
||||
ctx.drawImage(base, 0, 0);
|
||||
};
|
||||
const rossImg = await request
|
||||
.get('https://i.imgur.com/7NSiFLd.png');
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
base.src = rossImg.body;
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'bobross.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'ross.png' }] })
|
||||
|
||||
@@ -2,6 +2,8 @@ const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const moment = require('moment');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
const { version } = require('../../package');
|
||||
|
||||
@@ -61,11 +63,8 @@ module.exports = class CardCommand extends Command {
|
||||
ctx.fillText(member.id, 30, 355);
|
||||
ctx.fillText(`#${member.user.discriminator}`, 313, 355);
|
||||
};
|
||||
const cardImg = await request
|
||||
.get('https://i.imgur.com/6j8RHk1.png');
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
base.src = cardImg.body;
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'card.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'card.png' }] })
|
||||
|
||||
@@ -44,8 +44,7 @@ module.exports = class GreyscaleCommand extends Command {
|
||||
}
|
||||
ctx.putImageData(imgData, 0, 0);
|
||||
};
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'greyscale.png' }] })
|
||||
|
||||
@@ -42,8 +42,7 @@ module.exports = class InvertCommand extends Command {
|
||||
}
|
||||
ctx.putImageData(imgData, 0, 0);
|
||||
};
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'invert.png' }] })
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class RIPCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -46,11 +49,8 @@ module.exports = class RIPCommand extends Command {
|
||||
}
|
||||
ctx.putImageData(imgData, 158, 51);
|
||||
};
|
||||
const ripImg = await request
|
||||
.get('https://i.imgur.com/Gbu1B2m.png');
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
base.src = ripImg.body;
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'rip.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'rip.png' }] })
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class SteamCardCommand extends Command {
|
||||
@@ -43,11 +45,8 @@ module.exports = class SteamCardCommand extends Command {
|
||||
ctx.font = '30px Open Sans';
|
||||
ctx.fillText(username, 35, 48);
|
||||
};
|
||||
const cardImg = await request
|
||||
.get('https://i.imgur.com/JF0WwQX.png');
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
base.src = cardImg.body;
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'steamcard.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'card.png' }] })
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class TriggeredCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -44,11 +47,8 @@ module.exports = class TriggeredCommand extends Command {
|
||||
ctx.putImageData(imgData, 0, 0);
|
||||
ctx.drawImage(base, 0, 0);
|
||||
};
|
||||
const triggeredImg = await request
|
||||
.get('https://i.imgur.com/tF9yF62.png');
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
base.src = triggeredImg.body;
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'triggered.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'triggered.png' }] })
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Canvas = require('canvas');
|
||||
const request = require('superagent');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const fs = promisifyAll(require('fs'));
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class WantedCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -36,11 +39,8 @@ module.exports = class WantedCommand extends Command {
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.drawImage(avatar, 150, 360, 430, 430);
|
||||
};
|
||||
const wantedImg = await request
|
||||
.get('https://i.imgur.com/6bBDfsO.png');
|
||||
const avatarImg = await request
|
||||
.get(avatarURL);
|
||||
base.src = wantedImg.body;
|
||||
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'wanted.png'));
|
||||
const avatarImg = await request.get(avatarURL);
|
||||
avatar.src = avatarImg.body;
|
||||
generate();
|
||||
return msg.channel.send({ files: [{ attachment: canvas.toBuffer(), name: 'wanted.png' }] })
|
||||
|
||||
@@ -44,8 +44,7 @@ module.exports = class CurrencyCommand extends Command {
|
||||
const { base, to, amount } = args;
|
||||
if (base === to) return msg.say(`Converting ${base} to ${to} is the same value, dummy.`);
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`http://api.fixer.io/latest?base=${base}&symbols=${to}`);
|
||||
const { body } = await request.get(`http://api.fixer.io/latest?base=${base}&symbols=${to}`);
|
||||
const rate = body.rates[to];
|
||||
return msg.say(`${amount} ${base} is ${amount * rate} ${to}.`);
|
||||
} catch (err) {
|
||||
|
||||
@@ -11,9 +11,6 @@ module.exports = class SpamCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
if (msg.channel.type !== 'dm')
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
return msg.channel.send({ files: ['https://i.imgur.com/2JFu5xE.jpg'] })
|
||||
.catch(err => msg.say(err));
|
||||
}
|
||||
|
||||
@@ -13,9 +13,6 @@ module.exports = class CatCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
if (msg.channel.type !== 'dm')
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('http://random.cat/meow');
|
||||
|
||||
@@ -12,9 +12,6 @@ module.exports = class DogCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
if (msg.channel.type !== 'dm')
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://random.dog/woof.json');
|
||||
|
||||
@@ -13,9 +13,6 @@ module.exports = class XiaoCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
if (msg.channel.type !== 'dm')
|
||||
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
const xiao = xiaos[Math.floor(Math.random() * xiaos.length)];
|
||||
return msg.channel.send({ files: [xiao] })
|
||||
.catch(err => msg.say(err));
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = class BotSearchCommand extends Command {
|
||||
.set({ 'Authorization': DISCORD_BOTS_KEY });
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg')
|
||||
.setAuthor('Discord Bots')
|
||||
.setTitle(body.name)
|
||||
.setURL(`https://bots.discord.pw/bots/${bot.id}`)
|
||||
.setDescription(body.description)
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = class ForecastCommand extends Command {
|
||||
const forecasts = body.query.results.channel.item.forecast;
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
||||
.setAuthor(body.query.results.channel.title)
|
||||
.setURL(body.query.results.channel.link)
|
||||
.setTimestamp()
|
||||
.addField(`**${forecasts[0].day} - ${forecasts[0].date}:**`,
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = class IMDBCommand extends Command {
|
||||
if (body.Error) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xDBA628)
|
||||
.setAuthor('IMDB', 'https://i.imgur.com/sXwwIQs.png')
|
||||
.setAuthor('IMDB')
|
||||
.setURL(`http://www.imdb.com/title/${body.imdbID}`)
|
||||
.setTitle(`${body.Title} (${body.imdbRating} Score)`)
|
||||
.setDescription(body.Plot.substr(0, 2000))
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class OsuCommand extends Command {
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xFF66AA)
|
||||
.setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png')
|
||||
.setAuthor('osu!')
|
||||
.setURL('https://osu.ppy.sh/')
|
||||
.addField('**Username:**',
|
||||
body[0].username, true)
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = class SoundCloudCommand extends Command {
|
||||
if (!body.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF15A22)
|
||||
.setAuthor(body[0].title, 'https://i.imgur.com/lFIz7RU.png')
|
||||
.setAuthor(body[0].title)
|
||||
.setURL(body[0].permalink_url)
|
||||
.setThumbnail(body[0].artwork_url)
|
||||
.addField('**Artist:**',
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = class UrbanCommand extends Command {
|
||||
if (!body.list.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x32a8f0)
|
||||
.setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png')
|
||||
.setAuthor('Urban Dictionary')
|
||||
.setURL(body.list[0].permalink)
|
||||
.setTitle(body.list[0].word)
|
||||
.setDescription(body.list[0].definition.substr(0, 2000))
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = class WattpadCommand extends Command {
|
||||
if (!body.stories.length) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0xF89C34)
|
||||
.setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png')
|
||||
.setAuthor('Wattpad')
|
||||
.setURL(body.stories[0].url)
|
||||
.setTitle(body.stories[0].title)
|
||||
.setDescription(body.stories[0].description.substr(0, 2000))
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = class WeatherCommand extends Command {
|
||||
if (!body.query.count) throw new Error('Location Not Found.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x0000FF)
|
||||
.setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png')
|
||||
.setAuthor(body.query.results.channel.title)
|
||||
.setURL(body.query.results.channel.link)
|
||||
.setTimestamp()
|
||||
.addField('**City:**',
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = class WikipediaCommand extends Command {
|
||||
.setColor(0xE7E7E7)
|
||||
.setTitle(body.query.pages[0].title)
|
||||
.setURL(`https://en.wikipedia.org/wiki/${query}`)
|
||||
.setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png')
|
||||
.setAuthor('Wikipedia')
|
||||
.setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n'));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
|
||||
@@ -34,7 +34,7 @@ module.exports = class YouTubeCommand extends Command {
|
||||
.setColor(0xDD2825)
|
||||
.setTitle(body.items[0].snippet.title)
|
||||
.setDescription(body.items[0].snippet.description)
|
||||
.setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://i.imgur.com/hkUafwu.png')
|
||||
.setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`)
|
||||
.setURL(`https://www.youtube.com/watch?v=${body.items[0].id.videoId}`)
|
||||
.setThumbnail(body.items[0].snippet.thumbnails.default.url);
|
||||
return msg.embed(embed);
|
||||
|
||||
@@ -34,7 +34,7 @@ module.exports = class YuGiOhCommand extends Command {
|
||||
.setColor(0xBE5F1F)
|
||||
.setTitle(body.data.name)
|
||||
.setDescription(body.data.text)
|
||||
.setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png')
|
||||
.setAuthor('Yu-Gi-Oh!')
|
||||
.addField('**Card Type:**',
|
||||
body.data.card_type, true)
|
||||
.addField('**Type:**',
|
||||
|
||||
@@ -57,12 +57,12 @@ module.exports = class UserInfoCommand extends Command {
|
||||
member.id, true)
|
||||
.addField('**Joined Discord On:**',
|
||||
stripIndents`
|
||||
${moment(member.user.createdTimestamp).format('MMMM Do YYYY h:mm:ss a')}
|
||||
${moment(member.user.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')}
|
||||
${moment.duration(Date.now() - member.user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.
|
||||
`)
|
||||
.addField('**Joined Server On:**',
|
||||
stripIndents`
|
||||
${moment(member.joinedTimestamp).format('MMMM Do YYYY h:mm:ss a')}
|
||||
${moment(member.joinedTimestamp).format('MMMM Do YYYY h:mm:ss A')}
|
||||
${moment.duration(Date.now() - member.joinedTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.
|
||||
`)
|
||||
.addField('**Status:**',
|
||||
|
||||
@@ -58,7 +58,8 @@ module.exports = class InfoCommand extends Command {
|
||||
[canvas](https://github.com/Automattic/node-canvas),
|
||||
[cheerio](https://cheerio.js.org),
|
||||
[sequelize](http://docs.sequelizejs.com),
|
||||
[pg](https://github.com/brianc/node-postgres)
|
||||
[pg](https://github.com/brianc/node-postgres),
|
||||
[tsubaki](https://github.com/iCrawl/tsubaki)
|
||||
`
|
||||
)
|
||||
.addField('APIs',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "19.2.2",
|
||||
"version": "19.2.3",
|
||||
"description": "A Discord Bot",
|
||||
"main": "shardingmanager.js",
|
||||
"scripts": {
|
||||
@@ -44,6 +44,7 @@
|
||||
"pg": "^6.1.5",
|
||||
"sequelize": "^3.30.4",
|
||||
"superagent": "^3.5.2",
|
||||
"tsubaki": "^1.1.0",
|
||||
"zalgolize": "^1.2.4"
|
||||
}
|
||||
}
|
||||
|
||||