forked from Supositware/Haha-Yes
show despacito album
This commit is contained in:
parent
98f3c06771
commit
5618e2470f
2 changed files with 20 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const responseObject = require("../../json/despacito.json");
|
const responseObject = require("../../json/despacito.json");
|
||||||
|
const { createCanvas, loadImage, getContext } = require('canvas')
|
||||||
|
const superagent = require('superagent')
|
||||||
|
const Discord = require('discord.js');
|
||||||
module.exports = class DespacitoCommand extends Command {
|
module.exports = class DespacitoCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
|
@ -11,7 +14,7 @@ module.exports = class DespacitoCommand extends Command {
|
||||||
{
|
{
|
||||||
key: 'user',
|
key: 'user',
|
||||||
prompt: 'What do you want me to say',
|
prompt: 'What do you want me to say',
|
||||||
type: 'member',
|
type: 'user',
|
||||||
default: ''
|
default: ''
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -19,6 +22,15 @@ module.exports = class DespacitoCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(message, { user }) {
|
async run(message, { user }) {
|
||||||
|
const canvas = createCanvas(660, 660);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
const background = await loadImage(user.avatarURL);
|
||||||
|
ctx.drawImage(background, 5, 12, canvas.width, canvas.height);
|
||||||
|
const { body: buffer } = await superagent.get('https://image.noelshack.com/fichiers/2018/41/6/1539381851-untitled.png');
|
||||||
|
const bg = await loadImage(buffer);
|
||||||
|
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);
|
||||||
|
const attachment = new Discord.Attachment(canvas.toBuffer(), 'despacito.png');
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
const number = Object.keys(responseObject).length;
|
const number = Object.keys(responseObject).length;
|
||||||
const despacitoNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1;
|
const despacitoNumber = Math.floor (Math.random() * (number - 1 + 1)) + 1;
|
||||||
|
@ -28,8 +40,11 @@ module.exports = class DespacitoCommand extends Command {
|
||||||
return message.say(`Did you just try to despacitoad yourself?`);
|
return message.say(`Did you just try to despacitoad yourself?`);
|
||||||
} else if (user.id === this.client.user.id) {
|
} else if (user.id === this.client.user.id) {
|
||||||
return message.say('Nice try but you wont get me :^)');
|
return message.say('Nice try but you wont get me :^)');
|
||||||
} else
|
} else {
|
||||||
message.delete();
|
message.delete();
|
||||||
message.say(`${user}, you have been despacitoad`);
|
message.say(`${user}, you have been despacitoad`, attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
|
@ -18,6 +18,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/loicbersier/discordbot#readme",
|
"homepage": "https://gitlab.com/loicbersier/discordbot#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"canvas": "^2.0.0-alpha.18",
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.4.2",
|
||||||
"discord.js-commando": "^0.10.0",
|
"discord.js-commando": "^0.10.0",
|
||||||
"faceapp": "^0.4.4",
|
"faceapp": "^0.4.4",
|
||||||
|
|
Loading…
Reference in a new issue