Bing wallpaper of the day

This commit is contained in:
loicbersier 2020-02-18 18:50:29 +01:00
parent 64105bbc89
commit d8c19c32b1

View file

@ -0,0 +1,38 @@
const { Command } = require('discord-akairo');
const fetch = require('node-fetch');
class wallpaperCommand extends Command {
constructor() {
super('wallpaper', {
aliases: ['wallpaper'],
category: 'fun',
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
description: {
content: 'Show the Bing wallpaper of the day',
usage: '',
examples: ['']
}
});
}
async exec(message) {
fetch('https://bing.biturl.top/?mkt=en-US')
.then(res => {
return res.json();
})
.then(res => {
console.log(res);
const wallpaperEmbed = this.client.util.embed()
.setColor(message.member.displayHexColor)
.setTitle('Bing wallpaper of the day')
.addField('Copyright', `[${res.copyright}](${res.copyright_link})`)
.setDescription('[1366](https://bing.biturl.top/?resolution=1366&format=image&mkt=en-US) | [1920](https://bing.biturl.top/?resolution=1920&format=image&mkt=en-US)')
.setImage(res.url);
return message.channel.send(wallpaperEmbed);
});
}
}
module.exports = wallpaperCommand;