Added region settings and right category

This commit is contained in:
loicbersier 2020-02-18 19:17:49 +01:00
parent 0e0cbbb028
commit 6596f5c05a

View file

@ -5,18 +5,29 @@ class wallpaperCommand extends Command {
constructor() { constructor() {
super('wallpaper', { super('wallpaper', {
aliases: ['wallpaper'], aliases: ['wallpaper'],
category: 'fun', category: 'utility',
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'], clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
args: [
{
id: 'region',
type: 'string',
match: 'rest',
}
],
description: { description: {
content: 'Show the Bing wallpaper of the day', 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: '', usage: '[region]',
examples: [''] examples: ['', 'zh-CN']
} }
}); });
} }
async exec(message) { async exec(message, args) {
fetch('https://bing.biturl.top/?mkt=en-US') let mkt = args.region;
console.log(mkt);
if (!args.region) mkt = 'en-us';
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}`)
.then(res => { .then(res => {
return res.json(); return res.json();
}) })