diff options
Diffstat (limited to 'src/commands/utility')
| -rw-r--r-- | src/commands/utility/average.ts | 13 | ||||
| -rw-r--r-- | src/commands/utility/csgoserverstatus.ts | 22 | ||||
| -rw-r--r-- | src/commands/utility/fortnitestats.ts | 14 | ||||
| -rw-r--r-- | src/commands/utility/gmodserverstatus.ts | 20 | ||||
| -rw-r--r-- | src/commands/utility/google.ts | 9 | ||||
| -rw-r--r-- | src/commands/utility/iss.ts | 6 | ||||
| -rw-r--r-- | src/commands/utility/romannumeral.ts | 12 | ||||
| -rw-r--r-- | src/commands/utility/rustserverstatus.ts | 20 | ||||
| -rw-r--r-- | src/commands/utility/starboundserverstatus.ts | 22 | ||||
| -rw-r--r-- | src/commands/utility/time.ts | 7 | ||||
| -rw-r--r-- | src/commands/utility/whois.ts | 13 |
11 files changed, 91 insertions, 67 deletions
diff --git a/src/commands/utility/average.ts b/src/commands/utility/average.ts index 51ac9e6..233236c 100644 --- a/src/commands/utility/average.ts +++ b/src/commands/utility/average.ts @@ -1,10 +1,13 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +//@ts-ignore no types import emoji from 'emoji-random' import { formatDistance, formatRelative } from 'date-fns' +//TODO: check if this has types +//@ts-ignore no types import { stripIndents } from 'common-tags' module.exports = class AverageUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'average', aliases: [ @@ -34,10 +37,10 @@ module.exports = class AverageUtility extends Command { ] }); } - async run(msg: CommandoMessage, { nNum }) { + async run(msg: CommandoMessage, { nNum }: any) { // this is really a string 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()) + const reducer = (accumulator: any, currentValue: any) => accumulator + currentValue + return 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 index eba0aad..5f0cfe7 100644 --- a/src/commands/utility/csgoserverstatus.ts +++ b/src/commands/utility/csgoserverstatus.ts @@ -1,11 +1,12 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; -import { MessageEmbed } from 'discord.js'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +//@ts-ignore no types import emoji from 'emoji-random' +//@ts-ignore no @types import gamedig from 'gamedig' -import gameDigHelper from '../../utils/gameDigHelper.js' +const gameDigHelper = require('../../utils/gameDigHelper.js') module.exports = class CSGOServerStatusUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'csgoserverstatus', aliases: [ @@ -45,33 +46,34 @@ module.exports = class CSGOServerStatusUtility extends Command { ] }); } - async run(msg: CommandoMessage, { host, port }) { + async run(msg: CommandoMessage, { host, port }: any) { try { const options = { host, - type: 'csgo' + type: 'csgo', } if (port) { + //@ts-ignore this get auto appended options.port = port } - gamedig + return gamedig .query(options) - .then(data => { + .then((data: any) => { 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 => { + .catch((err: string) => { 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() + return msg.channel.stopTyping() } } };
\ No newline at end of file diff --git a/src/commands/utility/fortnitestats.ts b/src/commands/utility/fortnitestats.ts index 01f1f99..8eb65c4 100644 --- a/src/commands/utility/fortnitestats.ts +++ b/src/commands/utility/fortnitestats.ts @@ -1,12 +1,13 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; import { MessageEmbed } from 'discord.js'; +//@ts-ignore to types 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) { + constructor(client: CommandoClient) { super(client, { name: 'fortnitestats', aliases: [ @@ -40,7 +41,7 @@ module.exports = class FortniteStatsUtility extends Command { key: 'pPlatform', prompt: 'What platform would you like to search on.', type: 'string', - parse: platform => platform.toLowerCase(), + parse: (platform: string) => platform.toLowerCase(), oneOf: platforms }, { @@ -51,7 +52,9 @@ module.exports = class FortniteStatsUtility extends Command { ] }); } - async run(msg: CommandoMessage, { pPlatform, pUsername }) { + //TODO: + //@ts-ignore this is not async + async run(msg: CommandoMessage, { pPlatform, pUsername }: any) { try { const stats = ( await axios @@ -62,6 +65,7 @@ module.exports = class FortniteStatsUtility extends Command { console.error(err) return msg.reply('Woops, There was an error with the (https://api.fortnitetracker.com) API. ' + emoji.random()) }) + //@ts-ignore yes it does exist lmao ).data if (stats.error === 'Player Not Found') { @@ -96,7 +100,7 @@ module.exports = class FortniteStatsUtility extends Command { return msg.replyEmbed(emb); } finally { - msg.channel.stopTyping() + return msg.channel.stopTyping() } } };
\ No newline at end of file diff --git a/src/commands/utility/gmodserverstatus.ts b/src/commands/utility/gmodserverstatus.ts index cf59d4b..50c0e61 100644 --- a/src/commands/utility/gmodserverstatus.ts +++ b/src/commands/utility/gmodserverstatus.ts @@ -1,11 +1,12 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; -import { MessageEmbed } from 'discord.js'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +//@ts-ignore no types import emoji from 'emoji-random' +//@ts-ignore no types import gamedig from 'gamedig' -import gameDigHelper from '../../utils/gameDigHelper.js' +const gameDigHelper = require('../../utils/gameDigHelper.js') module.exports = class GModServerStatusUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'gmodserverstatus', aliases: [ @@ -44,7 +45,7 @@ module.exports = class GModServerStatusUtility extends Command { ] }); } - async run(msg: CommandoMessage, { host, port }) { + async run(msg: CommandoMessage, { host, port }: any) { try { const options = { host, @@ -52,25 +53,26 @@ module.exports = class GModServerStatusUtility extends Command { } if (port) { + //@ts-ignore added auto options.port = port } - gamedig + return gamedig .query(options) - .then(data => { + .then((data: any) => { 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 => { + .catch((err: string) => { 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() + return msg.channel.stopTyping() } } };
\ No newline at end of file diff --git a/src/commands/utility/google.ts b/src/commands/utility/google.ts index 68185cc..2c84bd5 100644 --- a/src/commands/utility/google.ts +++ b/src/commands/utility/google.ts @@ -1,9 +1,8 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; -import emoji from 'emoji-random'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; import { MessageEmbed } from 'discord.js'; module.exports = class GoogleUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'google', group: 'utility', @@ -25,11 +24,11 @@ module.exports = class GoogleUtility extends Command { ] }); } - async run(msg: CommandoMessage, { gTerm }) { + run(msg: CommandoMessage, { gTerm }: any) { let embed = new MessageEmbed() .setTitle('**Google Search**') .setColor(0xFFCC4D) .addField('Searching Google for`' + gTerm + '`...', `[Click Here](https://google.com/search?q=${gTerm.replace(/ /g, '%20')})`) - msg.say(embed) + return msg.say(embed) } };
\ No newline at end of file diff --git a/src/commands/utility/iss.ts b/src/commands/utility/iss.ts index d49b499..3bb4ff6 100644 --- a/src/commands/utility/iss.ts +++ b/src/commands/utility/iss.ts @@ -1,9 +1,10 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +//@ts-ignore no types import emoji from 'emoji-random'; import request from 'node-superfetch' module.exports = class ISSUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'iss', aliases: ['internationalspacestation', 'international-space-station'], @@ -22,6 +23,7 @@ module.exports = class ISSUtility extends Command { async run(msg: CommandoMessage) { try { const { body } = await request.get('http://api.open-notify.org/iss-now.json') + //@ts-ignore this exists const pos = body.iss_position return msg.reply(`The ISS is currentaly at **${pos.latitude}, ${pos.longitude}**. ${emoji.random()}`) } catch (err) { diff --git a/src/commands/utility/romannumeral.ts b/src/commands/utility/romannumeral.ts index 8dcc331..39b9320 100644 --- a/src/commands/utility/romannumeral.ts +++ b/src/commands/utility/romannumeral.ts @@ -1,9 +1,11 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +//@ts-ignore no types import emoji from 'emoji-random' +//@ts-ignore no types import romanize from 'romanize' module.exports = class RomanNumeralUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'romannumeral', aliases: [ @@ -31,12 +33,12 @@ module.exports = class RomanNumeralUtility extends Command { ] }); } - run(msg: CommandoMessage, { nNum }) { + run(msg: CommandoMessage, { nNum }: any) { if (nNum === parseInt(nNum, 10)) { msg.reply(romanize(nNum)) } - const back = value => { + const back = (value: string) => { let res = 0 const decimal = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] @@ -50,6 +52,6 @@ module.exports = class RomanNumeralUtility extends Command { return res } - msg.reply(back(nNum) + ' ' + emoji.random()) + return msg.reply(back(nNum) + ' ' + emoji.random()) } };
\ No newline at end of file diff --git a/src/commands/utility/rustserverstatus.ts b/src/commands/utility/rustserverstatus.ts index f7f58bc..dd91487 100644 --- a/src/commands/utility/rustserverstatus.ts +++ b/src/commands/utility/rustserverstatus.ts @@ -1,11 +1,12 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; -import { MessageEmbed } from 'discord.js'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +//@ts-ignore no types import emoji from 'emoji-random' +//@ts-ignore no types import gamedig from 'gamedig' -import gameDigHelper from '../../utils/gameDigHelper.js' +const gameDigHelper = require('../../utils/gameDigHelper.js') module.exports = class RustServerStatusUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'rustserverstatus', aliases: [ @@ -43,7 +44,7 @@ module.exports = class RustServerStatusUtility extends Command { ] }); } - async run(msg: CommandoMessage, { host, port }) { + run(msg: CommandoMessage, { host, port }: any) { try { const options = { host, @@ -51,26 +52,27 @@ module.exports = class RustServerStatusUtility extends Command { } if (port) { + //@ts-ignore gets added options.port = port } - gamedig + return gamedig .query(options) - .then(data => { + .then((data: any) => { msg.replyEmbed( gameDigHelper(data) .setThumbnail('https://steamcdn-a.akamaihd.net/steam/apps/252490/header.jpg') .setColor(0xFFCC4D) ) }) - .catch(err => { + .catch((err: string) => { 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() + return msg.channel.stopTyping() } } };
\ No newline at end of file diff --git a/src/commands/utility/starboundserverstatus.ts b/src/commands/utility/starboundserverstatus.ts index eaddfc8..0d8e319 100644 --- a/src/commands/utility/starboundserverstatus.ts +++ b/src/commands/utility/starboundserverstatus.ts @@ -1,11 +1,13 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; -import { MessageEmbed, Message } from 'discord.js'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +import { MessageEmbed } from 'discord.js'; +//@ts-ignore no types import emoji from 'emoji-random' +//@ts-ignore no types import gamedig from 'gamedig' -import gameDigHelper from '../../utils/gameDigHelper.js' +const gameDigHelper = require('../../utils/gameDigHelper.js') module.exports = class StarboundServerStatusUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'starboundserverstatus', aliases: [ @@ -43,7 +45,7 @@ module.exports = class StarboundServerStatusUtility extends Command { ] }); } - async run(msg: CommandoMessage, { host, port }) { + run(msg: CommandoMessage, { host, port }: any) { try { const options = { host, @@ -51,12 +53,14 @@ module.exports = class StarboundServerStatusUtility extends Command { } if (port) { + //@ts-ignore added auto options.port = port } - gamedig + return gamedig .query(options) - .then(data => { + // this is auto'd so might not be good + .then((data: { raw: { numplayers: any; }; maxplayers: any; name: any; query: { duration: any; address: any; port: any; }; password: any; }) => { const curr = data.raw.numplayers const max = data.maxplayers @@ -82,14 +86,14 @@ module.exports = class StarboundServerStatusUtility extends Command { .setColor(0xFFCC4D) ) }) - .catch(err => { + .catch((err: string) => { 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() + return msg.channel.stopTyping() } } };
\ No newline at end of file diff --git a/src/commands/utility/time.ts b/src/commands/utility/time.ts index 5bcf892..78fe391 100644 --- a/src/commands/utility/time.ts +++ b/src/commands/utility/time.ts @@ -1,8 +1,9 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +//@ts-ignore no types import emoji from 'emoji-random' module.exports = class TimeUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'time', group: 'utility', @@ -18,6 +19,6 @@ module.exports = class TimeUtility extends Command { }); } run(msg: CommandoMessage) { - msg.reply(`The time is currently **${new Date()}**.`) + return msg.reply(`The time is currently **${new Date()}**. ${emoji.random()}`) } };
\ No newline at end of file diff --git a/src/commands/utility/whois.ts b/src/commands/utility/whois.ts index 95c954c..d699e39 100644 --- a/src/commands/utility/whois.ts +++ b/src/commands/utility/whois.ts @@ -1,9 +1,11 @@ -import { Command, CommandoMessage } from 'discord.js-commando'; +import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; +//@ts-ignore no types import emoji from 'emoji-random'; +//@ts-ignore no types import whois from 'whois'; module.exports = class WhoIsUtility extends Command { - constructor(client) { + constructor(client: CommandoClient) { super(client, { name: 'whois', group: 'utility', @@ -25,12 +27,13 @@ module.exports = class WhoIsUtility extends Command { ] }); } - async run(msg: CommandoMessage, { host }) { - whois.lookup(host, (err, data) => { + run(msg: CommandoMessage, { host }: any) { + //@ts-ignore doesnt matter if none is returned + return whois.lookup(host, (err: any, data: any) => { if (err) return msg.reply(`Woops, there was an error getting that information for you! Please re-check your specified host/ domain. ${emoji.random()}`); msg.reply(`Check your DMs for the whois! ${emoji.random()}`); - msg.author.send(data, { split: true }); + return msg.author.send(data, { split: true }); }); } };
\ No newline at end of file |