/[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 344 by rakin, Mon Jul 29 17:29:40 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    
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()
# Line 15  module.exports = { Line 26  module.exports = {
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')
# Line 33  module.exports = { Line 47  module.exports = {
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')
# Line 50  module.exports = { Line 64  module.exports = {
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')
# Line 59  module.exports = { Line 73  module.exports = {
73              });              });
74          });          });
75      }      }
 };  
76    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26