2020-02-18 18:50:29 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
class wallpaperCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('wallpaper', {
|
|
|
|
aliases: ['wallpaper'],
|
2020-02-18 19:17:49 +01:00
|
|
|
category: 'utility',
|
2020-02-18 18:50:29 +01:00
|
|
|
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
|
2020-02-18 19:17:49 +01:00
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'region',
|
|
|
|
type: 'string',
|
|
|
|
match: 'rest',
|
|
|
|
}
|
|
|
|
],
|
2020-02-18 18:50:29 +01:00
|
|
|
description: {
|
2020-02-18 19:17:49 +01:00
|
|
|
content: 'Show the Bing wallpaper of the day, can use any of the following region: zh-CN, en-US, ja-JP, en-AU, en-UK, de-DE, en-NZ, en-CA',
|
|
|
|
usage: '[region]',
|
|
|
|
examples: ['', 'zh-CN']
|
2020-02-18 18:50:29 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-18 19:17:49 +01:00
|
|
|
async exec(message, args) {
|
|
|
|
let mkt = args.region;
|
2020-02-18 19:49:47 +01:00
|
|
|
if (!args.region) mkt = 'en-US';
|
2020-02-18 19:17:49 +01:00
|
|
|
if (!['zh-CN', 'en-US', 'ja-JP', 'en-AU', 'en-UK', 'de-DE', 'en-NZ', 'en-CA'].includes(mkt)) return message.channel.send('Please choose a valid region settings: zh-CN, en-US, ja-JP, en-AU, en-UK, de-DE, en-NZ, en-CA');
|
|
|
|
fetch(`https://bing.biturl.top/?mkt=${mkt}`)
|
2020-02-18 18:50:29 +01:00
|
|
|
.then(res => {
|
|
|
|
return res.json();
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
const wallpaperEmbed = this.client.util.embed()
|
|
|
|
.setColor(message.member.displayHexColor)
|
|
|
|
.setTitle('Bing wallpaper of the day')
|
|
|
|
.addField('Copyright', `[${res.copyright}](${res.copyright_link})`)
|
2020-02-21 15:17:07 +01:00
|
|
|
.setDescription(`[1366](https://bing.biturl.top/?resolution=1366&format=image&mkt=${mkt}) | [1920](https://bing.biturl.top/?resolution=1920&format=image&mkt=${mkt})`)
|
2020-02-18 18:50:29 +01:00
|
|
|
.setImage(res.url);
|
|
|
|
|
|
|
|
return message.channel.send(wallpaperEmbed);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = wallpaperCommand;
|