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