/[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 393 by rakin, Mon Jul 29 17:29:59 2024 UTC
# Line 1  Line 1 
1  const MessageEmbed = require("../src/MessageEmbed");  /**
2  const axios = require('axios').default;  * This file is part of SudoBot.
3    *
4    * Copyright (C) 2021-2022 OSN Inc.
5    *
6    * SudoBot is free software; you can redistribute it and/or modify it
7    * under the terms of the GNU Affero General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10    *
11    * SudoBot is distributed in the hope that it will be useful, but
12    * WITHOUT ANY WARRANTY; without even the implied warranty of
13    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14    * GNU Affero General Public License for more details.
15    *
16    * You should have received a copy of the GNU Affero General Public License
17    * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
18    */
19    
20    import { CommandInteraction, Message, MessageEmbed } from 'discord.js';
21    import BaseCommand from '../../utils/structures/BaseCommand';
22    import DiscordClient from '../../client/Client';
23    import CommandOptions from '../../types/CommandOptions';
24    import InteractionOptions from '../../types/InteractionOptions';
25    import axios from 'axios';
26    
27    export default class HttpcatCommand extends BaseCommand {
28        supportsInteractions: boolean = true;
29        coolDown = 4000;
30    
31  module.exports = {      constructor() {
32      async handle(msg, cm) {          super('httpcat', 'fun', []);
33          if (cm.args[0] === undefined) {      }
34    
35        async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {
36            if (!options.isInteraction && options.args[0] === undefined) {
37              await msg.reply({              await msg.reply({
38                  embeds: [                  embeds: [
39                      new MessageEmbed()                      new MessageEmbed()
# Line 15  module.exports = { Line 45  module.exports = {
45              return;              return;
46          }          }
47    
48          let status = parseInt(cm.args[0]);          if (msg instanceof CommandInteraction)
49                await msg.deferReply();
50    
51            let status = parseInt((options.isInteraction ? options.options.getInteger('status') : options.args[0]) + '');
52    
53          if (typeof status !== 'number' || status < 100 || status > 515) {          if (typeof status !== 'number' || status < 100 || status > 515) {
54              await msg.reply({              await this.deferReply(msg, {
55                  embeds: [                  embeds: [
56                      new MessageEmbed()                      new MessageEmbed()
57                      .setColor('#f14a60')                      .setColor('#f14a60')
# Line 33  module.exports = { Line 66  module.exports = {
66    
67          axios.get(url)          axios.get(url)
68          .then(async (data) => {          .then(async (data) => {
69              await msg.reply({              await this.deferReply(msg, {
70                  content: url                  content: url
71              });              });
72          })          })
73          .catch(async err => {          .catch(async err => {
74              if (err.response.status === 404) {              if (err.response.status === 404) {
75                  await msg.reply({                  await this.deferReply(msg, {
76                      embeds: [                      embeds: [
77                          new MessageEmbed()                          new MessageEmbed()
78                          .setColor('#f14a60')                          .setColor('#f14a60')
# Line 50  module.exports = { Line 83  module.exports = {
83                  return;                  return;
84              }              }
85    
86              await msg.reply({              await this.deferReply(msg, {
87                  embeds: [                  embeds: [
88                      new MessageEmbed()                      new MessageEmbed()
89                      .setColor('#f14a60')                      .setColor('#f14a60')
# Line 59  module.exports = { Line 92  module.exports = {
92              });              });
93          });          });
94      }      }
 };  
95    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26