From b20eefadacae79ea01071c533f470c4a74ed8cbb Mon Sep 17 00:00:00 2001 From: Alex <14044900+Al3366@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:58:17 +0000 Subject: [PATCH] add a command to check if the username "smith" is available --- bot/commands/fun/issmithavailableyet.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bot/commands/fun/issmithavailableyet.js diff --git a/bot/commands/fun/issmithavailableyet.js b/bot/commands/fun/issmithavailableyet.js new file mode 100644 index 0000000..d2cd1d2 --- /dev/null +++ b/bot/commands/fun/issmithavailableyet.js @@ -0,0 +1,23 @@ +'use strict'; + +/** + * @param {DubAPI} bot + */ +module.exports = function(bot) { + fetch('https://api.queup.net/user/query/availabilty?username=smith') // this endpoint has a typo, lol + .then(res => { + if (res.ok) return res.json(); + else throw new Error(res.status.toString()); + }) + .then(json => { + if (json.data.taken) { + bot.sendChat('No, someone still has the username Smith :rage:'); + } else { + bot.sendChat(':exclamation: THE USERNAME SMITH IS AVAILABLE :exclamation:'); + } + }) + .catch(err => { + bot.log('error', 'BOT', `[!issmithavailableyet] ${err.message}`); + bot.sendChat('Bad request to username availability check...'); + }); +}; \ No newline at end of file