From 6596f5c05a8265a16c80b34979e7de5fcc235aaa Mon Sep 17 00:00:00 2001 From: loicbersier Date: Tue, 18 Feb 2020 19:17:49 +0100 Subject: [PATCH] Added region settings and right category --- commands/utility/wallpaper.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/commands/utility/wallpaper.js b/commands/utility/wallpaper.js index 3fef8fbf..35c4863e 100644 --- a/commands/utility/wallpaper.js +++ b/commands/utility/wallpaper.js @@ -5,18 +5,29 @@ class wallpaperCommand extends Command { constructor() { super('wallpaper', { aliases: ['wallpaper'], - category: 'fun', + category: 'utility', clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'], + args: [ + { + id: 'region', + type: 'string', + match: 'rest', + } + ], description: { - content: 'Show the Bing wallpaper of the day', - usage: '', - examples: [''] + 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'] } }); } - async exec(message) { - fetch('https://bing.biturl.top/?mkt=en-US') + async exec(message, args) { + 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 => { return res.json(); })