From d8c19c32b110addad3ea35b1b60ffbfd54a96517 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 18 Feb 2020 18:50:29 +0100 Subject: [PATCH] Bing wallpaper of the day --- commands/utility/wallpaper.js | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 commands/utility/wallpaper.js diff --git a/commands/utility/wallpaper.js b/commands/utility/wallpaper.js new file mode 100644 index 00000000..3fef8fbf --- /dev/null +++ b/commands/utility/wallpaper.js @@ -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; \ No newline at end of file