summaryrefslogtreecommitdiff
path: root/src/commands/utility
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/utility')
-rw-r--r--src/commands/utility/average.ts43
-rw-r--r--src/commands/utility/csgoserverstatus.ts77
-rw-r--r--src/commands/utility/fortnitestats.ts101
-rw-r--r--src/commands/utility/gmodserverstatus.ts76
-rw-r--r--src/commands/utility/iss.ts31
-rw-r--r--src/commands/utility/rustserverstatus.ts76
-rw-r--r--src/commands/utility/starboundserverstatus.ts95
7 files changed, 499 insertions, 0 deletions
diff --git a/src/commands/utility/average.ts b/src/commands/utility/average.ts
new file mode 100644
index 0000000..51ac9e6
--- /dev/null
+++ b/src/commands/utility/average.ts
@@ -0,0 +1,43 @@
+import { Command, CommandoMessage } from 'discord.js-commando';
+import emoji from 'emoji-random'
+import { formatDistance, formatRelative } from 'date-fns'
+import { stripIndents } from 'common-tags'
+
+module.exports = class AverageUtility extends Command {
+ constructor(client) {
+ super(client, {
+ name: 'average',
+ aliases: [
+ 'average-number',
+ 'averagenumber',
+ 'average-num',
+ 'averagenum'
+ ],
+ group: 'utility',
+ memberName: 'average',
+ description: 'Gets the average of specified numbers.',
+ examples: ['uwu!average 10 20 30 40 50'],
+ throttling: {
+ usages: 5,
+ duration: 30
+ },
+ userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
+ clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
+ args: [
+ {
+ key: 'nNum',
+ prompt: 'What\'s another number you would like to average?',
+ type: 'float',
+ label: 'number',
+ infinite: true
+ }
+ ]
+ });
+ }
+ async run(msg: CommandoMessage, { nNum }) {
+ if (nNum.length < 2) msg.reply('Please provide **2** or more numbers.')
+
+ const reducer = (accumulator, currentValue) => accumulator + currentValue
+ msg.reply(`The average of the specified numbers is ${nNum.reduce(reducer) / nNum.length}.` + ' ' + emoji.random())
+ }
+}; \ No newline at end of file
diff --git a/src/commands/utility/csgoserverstatus.ts b/src/commands/utility/csgoserverstatus.ts
new file mode 100644
index 0000000..39b5c81
--- /dev/null
+++ b/src/commands/utility/csgoserverstatus.ts
@@ -0,0 +1,77 @@
+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 CSGOServerStatusUtility extends Command {
+ constructor(client) {
+ super(client, {
+ name: 'csgoserverstatus',
+ aliases: [
+ 'counterstrikeserverstatus',
+ 'counter-strike-server-status',
+ 'counterstrikeglobaloffensiveserverstatus',
+ 'counter-strike-global-offensive-server-status',
+ 'csgoss'
+ ],
+ group: 'utility',
+ memberName: 'csgoserverstatus',
+ description: 'Grabs you the server status of a CS:GO server.',
+ examples: [
+ 'uwu!csgoserverstatus',
+ 'uwu!csgoss'
+ ],
+ 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: 'csgo'
+ }
+
+ 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/730/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
diff --git a/src/commands/utility/fortnitestats.ts b/src/commands/utility/fortnitestats.ts
new file mode 100644
index 0000000..88a50a0
--- /dev/null
+++ b/src/commands/utility/fortnitestats.ts
@@ -0,0 +1,101 @@
+import { Command, CommandoMessage } from 'discord.js-commando';
+import { MessageEmbed } from 'discord.js';
+import emoji from 'emoji-random'
+import axios from 'axios'
+import config from '../../config.json'
+const platforms = ['pc', 'xbl', 'psn']
+
+module.exports = class FortniteStatsUtility extends Command {
+ constructor(client) {
+ super(client, {
+ name: 'fortnitestats',
+ aliases: [
+ 'fortnite-stats',
+ 'fortnitestatistics',
+ 'fortnite-statistics',
+ 'fnstats',
+ 'fn-stats',
+ 'fnstatistics',
+ 'fn-statistics',
+ 'fns',
+ 'fn-s'
+ ],
+ group: 'utility',
+ memberName: 'fortnitestats',
+ description: 'Grabs a specified player\' Fortnite statistics.',
+ details: 'Available platforms are `pc` (PC), `xbp` (Xbox Live) and `psn` (Playstation Network).',
+ examples: [
+ 'uwu!fortnitestats Frozen',
+ 'uwu!fns Sin'
+ ],
+ userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
+ clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
+ throttling: {
+ usages: 5,
+ duration: 30
+ },
+ args: [
+ {
+ key: 'pPlatform',
+ prompt: 'What platform would you like to search on.',
+ type: 'string',
+ parse: platform => platform.toLowerCase(),
+ oneOf: platforms
+ },
+ {
+ key: 'pUsername',
+ prompt: 'What user would you like to look up?',
+ type: 'string'
+ }
+ ]
+ });
+ }
+ async run(msg: CommandoMessage, { pPlatform, pUsername }) {
+ try {
+ const stats = (
+ await axios
+ .get(`https://api.fortnitetracker.com/v1/profile/${pPlatform}/${pUsername}`, {
+ headers: { 'TRN-Api-Key': config.fortniteTrackerNetworkToken }
+ })
+ .catch(err => {
+ console.error(err)
+ return msg.reply('Woops, There was an error with the (https://api.fortnitetracker.com) API. ' + emoji.random())
+ })
+ ).data
+
+ if (stats.error === 'Player Not Found') {
+ return msg.reply('Specified player was not found on that platform. ' + emoji.random())
+ }
+
+ console.debug(`Result for ${pUsername} on ${pPlatform}:`, stats)
+ let emb = new MessageEmbed()
+ .setTitle(stats.epicUserHandle)
+ .setURL(`https://fortnitetracker.com/profile/${pPlatform}/${encodeURIComponent(pUsername)}`)
+ .setColor(0xFFCC4D)
+ .setFooter('Information providied by The Tracker Network.',)
+
+ if (stats.lifeTimeStats[8] && stats.lifeTimeStats[9]) {
+ emb.addField("🏆 Wins", `${stats.lifeTimeStats[8].value} wins (${stats.lifeTimeStats[9].value})`)
+ }
+
+ if (stats.lifeTimeStats[10] && stats.lifeTimeStats[11]) {
+ emb.addField(
+ "💀 Kills",
+ `${stats.lifeTimeStats[10].value} kills. ${stats.lifeTimeStats[11].value} K/D ratio.`
+ );
+ }
+
+ if (stats.lifeTimeStats[7]) {
+ emb.addField("🎮 Matches Played", stats.lifeTimeStats[7].value.toString());
+ }
+
+ if (stats.lifeTimeStats[6]) {
+ emb.addField("🔢 Score", stats.lifeTimeStats[6].value.toString());
+ }
+
+ return msg.replyEmbed(emb);
+ } finally {
+ msg.channel.stopTyping()
+ }
+ }
+}; \ No newline at end of file
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
diff --git a/src/commands/utility/iss.ts b/src/commands/utility/iss.ts
new file mode 100644
index 0000000..d49b499
--- /dev/null
+++ b/src/commands/utility/iss.ts
@@ -0,0 +1,31 @@
+import { Command, CommandoMessage } from 'discord.js-commando';
+import emoji from 'emoji-random';
+import request from 'node-superfetch'
+
+module.exports = class ISSUtility extends Command {
+ constructor(client) {
+ super(client, {
+ name: 'iss',
+ aliases: ['internationalspacestation', 'international-space-station'],
+ group: 'utility',
+ memberName: 'iss',
+ description: 'Tells you the current location of the International Space Station.',
+ examples: ['uwu!iss'],
+ userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
+ clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
+ throttling: {
+ usages: 5,
+ duration: 30
+ },
+ });
+ }
+ async run(msg: CommandoMessage) {
+ try {
+ const { body } = await request.get('http://api.open-notify.org/iss-now.json')
+ const pos = body.iss_position
+ return msg.reply(`The ISS is currentaly at **${pos.latitude}, ${pos.longitude}**. ${emoji.random()}`)
+ } catch (err) {
+ return msg.reply(`Woops, an error has occurred: \`${err.message}\`. Try again later! ${emoji.random()}`)
+ }
+ }
+}; \ No newline at end of file
diff --git a/src/commands/utility/rustserverstatus.ts b/src/commands/utility/rustserverstatus.ts
new file mode 100644
index 0000000..bce83cb
--- /dev/null
+++ b/src/commands/utility/rustserverstatus.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 RustServerStatusUtility extends Command {
+ constructor(client) {
+ super(client, {
+ name: 'rustserverstatus',
+ aliases: [
+ 'rust-ss',
+ 'rust-server-status',
+ 'rustss'
+ ],
+ group: 'utility',
+ memberName: 'rustserverstatus',
+ description: 'Grabs you the server status of a Rust server.',
+ examples: [
+ 'uwu!rustserverstatus',
+ 'uwu!rustss'
+ ],
+ 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: '28015',
+ max: 65535,
+ min: 1
+ }
+ ]
+ });
+ }
+ async run(msg: CommandoMessage, { host, port }) {
+ try {
+ const options = {
+ host,
+ type: 'rust'
+ }
+
+ if (port) {
+ options.port = port
+ }
+
+ gamedig
+ .query(options)
+ .then(data => {
+ msg.replyEmbed(
+ gameDigHelper(data)
+ .setThumbnail('https://steamcdn-a.akamaihd.net/steam/apps/252490/header.jpg')
+ .setColor(0xFFCC4D)
+ )
+ })
+ .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
diff --git a/src/commands/utility/starboundserverstatus.ts b/src/commands/utility/starboundserverstatus.ts
new file mode 100644
index 0000000..963f226
--- /dev/null
+++ b/src/commands/utility/starboundserverstatus.ts
@@ -0,0 +1,95 @@
+import { Command, CommandoMessage } from 'discord.js-commando';
+import { MessageEmbed, Message } from 'discord.js';
+import emoji from 'emoji-random'
+import gamedig from 'gamedig'
+import gameDigHelper from '../../utils/gameDigHelper.js'
+
+module.exports = class StarboundServerStatusUtility extends Command {
+ constructor(client) {
+ super(client, {
+ name: 'starboundserverstatus',
+ aliases: [
+ 'starbound-ss',
+ 'starbound-server-status',
+ 'sbss'
+ ],
+ group: 'utility',
+ memberName: 'starboundserverstatus',
+ description: 'Grabs you the server status of a Starbound server.',
+ examples: [
+ 'uwu!starboundserverstatus',
+ 'uwu!sbss'
+ ],
+ 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: '21025',
+ max: 65535,
+ min: 1
+ }
+ ]
+ });
+ }
+ async run(msg: CommandoMessage, { host, port }) {
+ try {
+ const options = {
+ host,
+ type: 'starbound'
+ }
+
+ if (port) {
+ options.port = port
+ }
+
+ gamedig
+ .query(options)
+ .then(data => {
+ const curr = data.raw.numplayers
+ const max = data.maxplayers
+
+ return msg.replyEmbed(
+ new MessageEmbed()
+ .setTitle(data.name)
+ .setThumbnail('https://steamcdn-a.akamaihd.net/steam/apps/211820/header.jpg')
+ .setFooter(`Took ${data.query.duration} to complete.`)
+ .addFields([
+ {
+ name: 'IP Address',
+ value: `${data.query.address} (port ${data.query.port})`
+ },
+ {
+ name: "Online Players",
+ value: `${curr}/${max} (${Math.round((curr / max) * 100)}%)`
+ },
+ {
+ name: "Password Required",
+ value: data.password ? "Yes" : "No"
+ }
+ ])
+ .setColor(0xFFCC4D)
+ )
+ })
+ .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