1 |
const MessageEmbed = require("../src/MessageEmbed"); |
import { CommandInteraction, Message, MessageEmbed } from 'discord.js'; |
2 |
const axios = require('axios').default; |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
|
import DiscordClient from '../../client/Client'; |
4 |
|
import CommandOptions from '../../types/CommandOptions'; |
5 |
|
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
|
import axios from 'axios'; |
7 |
|
|
8 |
|
export default class HttpdogCommand extends BaseCommand { |
9 |
|
supportsInteractions: boolean = true; |
10 |
|
coolDown = 4000; |
11 |
|
|
12 |
module.exports = { |
constructor() { |
13 |
async handle(msg, cm) { |
super('httpdog', 'fun', []); |
14 |
if (cm.args[0] === undefined) { |
} |
15 |
|
|
16 |
|
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
17 |
|
if (!options.isInteraction && options.args[0] === undefined) { |
18 |
await msg.reply({ |
await msg.reply({ |
19 |
embeds: [ |
embeds: [ |
20 |
new MessageEmbed() |
new MessageEmbed() |
26 |
return; |
return; |
27 |
} |
} |
28 |
|
|
29 |
let status = parseInt(cm.args[0]); |
if (msg instanceof CommandInteraction) |
30 |
|
await msg.deferReply(); |
31 |
|
|
32 |
|
let status = parseInt((options.isInteraction ? options.options.getInteger('status') : options.args[0]) + ''); |
33 |
|
|
34 |
if (typeof status !== 'number' || status < 100 || status > 515) { |
if (typeof status !== 'number' || status < 100 || status > 515) { |
35 |
await msg.reply({ |
await this.deferReply(msg, { |
36 |
embeds: [ |
embeds: [ |
37 |
new MessageEmbed() |
new MessageEmbed() |
38 |
.setColor('#f14a60') |
.setColor('#f14a60') |
47 |
|
|
48 |
axios.get(url) |
axios.get(url) |
49 |
.then(async (data) => { |
.then(async (data) => { |
50 |
await msg.reply({ |
await this.deferReply(msg, { |
51 |
content: url |
content: url |
52 |
}); |
}); |
53 |
}) |
}) |
54 |
.catch(async err => { |
.catch(async err => { |
55 |
if (err.response.status === 404) { |
if (err.response.status === 404) { |
56 |
await msg.reply({ |
await this.deferReply(msg, { |
57 |
embeds: [ |
embeds: [ |
58 |
new MessageEmbed() |
new MessageEmbed() |
59 |
.setColor('#f14a60') |
.setColor('#f14a60') |
64 |
return; |
return; |
65 |
} |
} |
66 |
|
|
67 |
await msg.reply({ |
await this.deferReply(msg, { |
68 |
embeds: [ |
embeds: [ |
69 |
new MessageEmbed() |
new MessageEmbed() |
70 |
.setColor('#f14a60') |
.setColor('#f14a60') |
73 |
}); |
}); |
74 |
}); |
}); |
75 |
} |
} |
|
}; |
|
76 |
|
} |