/[sudobot]/trunk/src/commands/fun/HttpcatCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/fun/HttpcatCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/commands/httpcat.js revision 5 by rakin, Mon Jul 29 17:28:11 2024 UTC trunk/src/commands/fun/HttpcatCommand.ts revision 51 by rakin, Mon Jul 29 17:28:23 2024 UTC
# Line 1  Line 1 
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()
# Line 15  module.exports = { Line 27  module.exports = {
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')
# Line 33  module.exports = { Line 48  module.exports = {
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')
# Line 50  module.exports = { Line 65  module.exports = {
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')
# Line 59  module.exports = { Line 74  module.exports = {
74              });              });
75          });          });
76      }      }
 };  
77    }

Legend:
Removed from v.5  
changed lines
  Added in v.51

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26