diff options
Diffstat (limited to 'src/commands/utility/gmodserverstatus.ts')
| -rw-r--r-- | src/commands/utility/gmodserverstatus.ts | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/commands/utility/gmodserverstatus.ts b/src/commands/utility/gmodserverstatus.ts new file mode 100644 index 0000000..a92b5cf --- /dev/null +++ b/src/commands/utility/gmodserverstatus.ts @@ -0,0 +1,76 @@ +import { Command, CommandoMessage } from 'discord.js-commando'; +import { MessageEmbed } from 'discord.js'; +import emoji from 'emoji-random' +import gamedig from 'gamedig' +import gameDigHelper from '../../utils/gameDigHelper.js' + +module.exports = class GModServerStatusUtility extends Command { + constructor(client) { + super(client, { + name: 'gmodserverstatus', + aliases: [ + 'g-mod-server-status', + 'garrysmodserverstatus', + 'garrys-mod-server-status', + 'gmodss' + ], + group: 'utility', + memberName: 'gmodserverstatus', + description: 'Grabs you the server status of a GMod server.', + examples: [ + 'uwu!gmodserverstatus', + 'uwu!gmodss' + ], + userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + throttling: { + usages: 5, + duration: 30 + }, + args: [ + { + key: 'host', + prompt: 'What is the IP or host of the server?', + type: 'string' + }, + { + key: 'port', + prompt: 'What is the port of the server?', + type: 'integer', + default: '27015', + max: 65535, + min: 1 + } + ] + }); + } + async run(msg: CommandoMessage, { host, port }) { + try { + const options = { + host, + type: 'garrysmod' + } + + if (port) { + options.port = port + } + + gamedig + .query(options) + .then(data => { + let emb = gameDigHelper(data) + emb.setColor(0xFFCC4D) + emb.setThumbnail('https://steamcdn-a.akamaihd.net/steam/apps/4000/header.jpg') + return msg.replyEmbed(emb) + }) + .catch(err => { + if (err === 'UDP Watchdog Timeout') return msg.reply('Server timed out, it\'s probably offline. ' + emoji.random()) + + //console.error(err) + return msg.reply('Woops, an unknown error has occured. ' + emoji.random()) + }) + } finally { + msg.channel.stopTyping() + } + } +};
\ No newline at end of file |