Spotify Now Playing Command

This commit is contained in:
Dragon Fire
2020-07-07 13:32:51 -04:00
parent cfd90f7907
commit 5e5e5e6cd4
5 changed files with 107 additions and 3 deletions
+8 -1
View File
@@ -243,7 +243,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 530
Total: 531
### Utility:
@@ -635,6 +635,7 @@ Total: 530
* **snapcode:** Responds with the Snapcode of a Snapchat user.
* **speed-limit:** Sends a Speed Limit sign with the limit of your choice.
* **spongebob-time-card:** Sends a Spongebob Time Card with the text of your choice.
* **spotify-now-playing:** Draws an image or a user's avatar on a Spotify album with the name and artist of your choice.
* **square:** Draws an image or a user's avatar as a square.
* **squish:** Draws an image or a user's avatar but squished across the X or Y axis.
* **steam-card:** Draws an image or a user's avatar on a Steam Trading Card.
@@ -1111,6 +1112,7 @@ here.
* sos ([Noto Font](https://www.google.com/get/noto/))
* spiderman-pointing ([Noto Font](https://www.google.com/get/noto/))
* spongebob-burn ([Noto Font](https://www.google.com/get/noto/))
* spotify-now-playing ([Noto Font](https://www.google.com/get/noto/))
* steam-card ([Noto Font](https://www.google.com/get/noto/))
* steam-now-playing ([Noto Font](https://www.google.com/get/noto/))
* steam-now-playing-classic ([Noto Font](https://www.google.com/get/noto/))
@@ -1405,6 +1407,7 @@ here.
* sonic-says (Concept)
* speed-limit (Concept)
* spiderman-pointing (Concept)
* spotify-now-playing (Concept)
* thicc (Concept)
* undertale (Concept)
* wild-pokemon (Concept)
@@ -1507,6 +1510,8 @@ here.
* pogchamp (Image)
- [Safebooru](https://safebooru.org/)
* safebooru (API)
- [Sam Thik](https://www.pinterest.com/Samthik/)
* spotify-now-playing ([Image](https://www.pinterest.com/pin/500251471109108490/))
- [SEGA](https://www.sega.com/)
* sonic-says ([Image, Original "Sonic the Hedgehog" Game](https://www.sonicthehedgehog.com/))
- [Serebii.net](https://www.serebii.net/index2.shtml)
@@ -1537,6 +1542,8 @@ here.
* lolcat (Translation Data)
- [Spongebob Fanon](https://spongebob-new-fanon.fandom.com/wiki/SpongeBob_Fanon_Wiki)
* spongebob-time-card ([Images](https://spongebob-new-fanon.fandom.com/wiki/Gallery_of_Textless_Title_Cards))
- [Spotify](https://www.spotify.com/us/)
* spotify-now-playing (Original Design)
- [Square Enix](https://square-enix-games.com/)
* nobody-name ([Original "Kingdom Hearts" Game](https://www.kingdomhearts.com/home/us/))
* sora-selfie ([Original "Kingdom Hearts" Game](https://www.kingdomhearts.com/home/us/))
Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

+2 -1
View File
@@ -101,5 +101,6 @@
"You can open doors with your charm and patience.",
"You will eat pant today.",
"You will step on the soil of many countries in your lifetime.",
"You will make very many friends in the future."
"You will make very many friends in the future.",
"Ask yourself this question: \"Is my attitude worth catching?\""
]
@@ -0,0 +1,96 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage, registerFont } = require('canvas');
const request = require('node-superfetch');
const path = require('path');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Bold.ttf'), { family: 'Noto', weight: 'bold' });
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 SpotifyNowPlayingCommand extends Command {
constructor(client) {
super(client, {
name: 'spotify-now-playing',
aliases: ['now-playing-spotify', 'spotify', 'spotify-playing', 'playing-spotify'],
group: 'edit-image',
memberName: 'spotify-now-playing',
description: 'Draws an image or a user\'s avatar on a Spotify album with the name and artist of your choice.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Spotify',
url: 'https://www.spotify.com/us/',
reason: 'Original Design'
},
{
name: 'Sam Thik',
url: 'https://www.pinterest.com/Samthik/',
reason: 'Image',
reasonURL: 'https://www.pinterest.com/pin/500251471109108490/'
},
{
name: 'Google',
url: 'https://www.google.com/',
reason: 'Noto Font',
reasonURL: 'https://www.google.com/get/noto/'
},
{
name: 'Overtime2005',
url: 'https://github.com/Overtime2005',
reason: 'Concept'
}
],
args: [
{
key: 'name',
prompt: 'What do you want the song to be named?',
type: 'string',
max: 50
},
{
key: 'artist',
prompt: 'Who is the artist of the song?',
type: 'string',
max: 50
},
{
key: 'image',
prompt: 'What image would you like to edit?',
type: 'image',
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 })
}
]
});
}
async run(msg, { name, artist, image }) {
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'spotify-now-playing.png'));
const { body } = await request.get(image);
const data = await loadImage(body);
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, base.width, base.height);
const height = 504 / data.width;
ctx.drawImage(data, 66, 132, 504, height * data.height);
ctx.drawImage(base, 0, 0);
ctx.textBaseline = 'top';
ctx.textAlign = 'center';
ctx.font = 'normal bold 25px Noto';
ctx.fillStyle = 'white';
ctx.fillText(name, base.width / 2, 685);
ctx.fillStyle = '#bdbec2';
ctx.font = '20px Noto';
ctx.fillText(artist, base.width / 2, 720);
ctx.fillText('Xiao\'s Picks', base.width / 2, 65);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'spotify-now-playing.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "119.11.3",
"version": "119.12.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {