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 |
|
import path from 'path'; |
8 |
|
import { deleteFile, download } from '../../utils/util'; |
9 |
|
|
10 |
|
export default class HttpcatCommand extends BaseCommand { |
11 |
|
supportsInteractions: boolean = true; |
12 |
|
coolDown = 4000; |
13 |
|
|
14 |
module.exports = { |
constructor() { |
15 |
async handle(msg, cm) { |
super('httpcat', 'fun', []); |
16 |
if (cm.args[0] === undefined) { |
} |
17 |
|
|
18 |
|
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
19 |
|
if (!options.isInteraction && options.args[0] === undefined) { |
20 |
await msg.reply({ |
await msg.reply({ |
21 |
embeds: [ |
embeds: [ |
22 |
new MessageEmbed() |
new MessageEmbed() |
28 |
return; |
return; |
29 |
} |
} |
30 |
|
|
31 |
let status = parseInt(cm.args[0]); |
if (msg instanceof CommandInteraction) |
32 |
|
await msg.deferReply(); |
33 |
|
|
34 |
|
let status = parseInt((options.isInteraction ? options.options.getInteger('status') : options.args[0]) + ''); |
35 |
|
|
36 |
if (typeof status !== 'number' || status < 100 || status > 515) { |
if (typeof status !== 'number' || status < 100 || status > 515) { |
37 |
await msg.reply({ |
await this.deferReply(msg, { |
38 |
embeds: [ |
embeds: [ |
39 |
new MessageEmbed() |
new MessageEmbed() |
40 |
.setColor('#f14a60') |
.setColor('#f14a60') |
49 |
|
|
50 |
axios.get(url) |
axios.get(url) |
51 |
.then(async (data) => { |
.then(async (data) => { |
52 |
await msg.reply({ |
await this.deferReply(msg, { |
53 |
content: url |
content: url |
54 |
}); |
}); |
55 |
}) |
}) |
56 |
.catch(async err => { |
.catch(async err => { |
57 |
if (err.response.status === 404) { |
if (err.response.status === 404) { |
58 |
await msg.reply({ |
await this.deferReply(msg, { |
59 |
embeds: [ |
embeds: [ |
60 |
new MessageEmbed() |
new MessageEmbed() |
61 |
.setColor('#f14a60') |
.setColor('#f14a60') |
66 |
return; |
return; |
67 |
} |
} |
68 |
|
|
69 |
await msg.reply({ |
await this.deferReply(msg, { |
70 |
embeds: [ |
embeds: [ |
71 |
new MessageEmbed() |
new MessageEmbed() |
72 |
.setColor('#f14a60') |
.setColor('#f14a60') |
75 |
}); |
}); |
76 |
}); |
}); |
77 |
} |
} |
|
}; |
|
78 |
|
} |