diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-14 21:22:09 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-14 21:22:09 -0400 |
commit | 53d2b18f7f73d5696fb7cd86d1c164a790dfdcc3 (patch) | |
tree | f95f23aad382879b35860d4d3be3642068fac8a2 /src/commands/utilities/serverStatus.ts | |
parent | eaaae08aeee1fa16a4e1ad0b26fceb42885bfcde (diff) | |
download | tanzanite-53d2b18f7f73d5696fb7cd86d1c164a790dfdcc3.tar.gz tanzanite-53d2b18f7f73d5696fb7cd86d1c164a790dfdcc3.tar.bz2 tanzanite-53d2b18f7f73d5696fb7cd86d1c164a790dfdcc3.zip |
started moving over some other commands
Diffstat (limited to 'src/commands/utilities/serverStatus.ts')
-rw-r--r-- | src/commands/utilities/serverStatus.ts | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/commands/utilities/serverStatus.ts b/src/commands/utilities/serverStatus.ts new file mode 100644 index 0000000..a20f0b2 --- /dev/null +++ b/src/commands/utilities/serverStatus.ts @@ -0,0 +1,58 @@ +import { MessageEmbed } from 'discord.js'; +import got from 'got'; +import { BushCommand, BushMessage } from '../../lib'; + +export default class ServerStatusCommand extends BushCommand { + public constructor() { + super('serverstatus', { + aliases: ['serverstatus', 'ss'], + category: 'utilities', + description: { + usage: 'serverstatus', + examples: ['serverstatus', 'ss'], + content: "Gives the status of moulberry's server" + }, + ratelimit: 4, + cooldown: 4000, + clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], + slash: true + }); + } + + public async exec(message: BushMessage): Promise<void> { + const msgEmbed: MessageEmbed = new MessageEmbed() + .setTitle('Server status') + .setDescription(`Checking server:\n${this.client.util.emojis.loading}`) + .setColor(this.client.util.colors.default) + .setFooter('Checking https://moulberry.codes/lowestbin.json'); + await message.util.reply({ embeds: [msgEmbed] }); + let main; + try { + await got.get('https://moulberry.codes/lowestbin.json').json(); + main = this.client.util.emojis.success; + } catch (e) { + main = this.client.util.emojis.error; + } + await message.util.edit({ embeds: [msgEmbed.setDescription(`Checking server:\n${main}`)] }); + if (main == this.client.util.emojis.success) { + await message.util.edit({ + embeds: [ + msgEmbed + .addField('Status', 'The server is online, all features related to prices will likely work.') + .setColor(this.client.util.colors.success) + ] + }); + } else { + await message.util.edit({ + embeds: [ + msgEmbed + .addField( + 'Status', + "It appears Moulberry's server is offline, this means that everything related to prices will likely not work." + ) + .setColor(this.client.util.colors.error) + ] + }); + } + } +} |