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

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

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

trunk/commands/httpdog.js revision 5 by rakin, Mon Jul 29 17:28:11 2024 UTC trunk/src/commands/fun/HttpdogCommand.ts revision 56 by rakin, Mon Jul 29 17:28:24 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    export default class HttpdogCommand extends BaseCommand {
11        supportsInteractions: boolean = true;
12        coolDown = 4000;
13    
14  module.exports = {      constructor() {
15      async handle(msg, cm) {          super('httpdog', '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()
# Line 15  module.exports = { Line 28  module.exports = {
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')
# Line 33  module.exports = { Line 49  module.exports = {
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')
# Line 50  module.exports = { Line 66  module.exports = {
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')
# Line 59  module.exports = { Line 75  module.exports = {
75              });              });
76          });          });
77      }      }
 };  
78    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26