summaryrefslogtreecommitdiff
path: root/src/commands/utility/iss.ts
blob: d49b4990b046106050225467c09da7661d65f115 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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()}`)
        }
    }
};