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,QACE,OAID,EAAU,IAAI,EAAQ,OACzB,EAAU,IAAI,EAAQ,KAAM,IAAI,YAGlC,MAAM,EAAK,aAAa,EAAS,EAAW,EAAQ,OAAO,IAC3D,GAAI,EACF,EAAQ,QAAQ,KACd,eAAe,uCACb,EAAQ,uBAHd,EASuB,IAAnB,EAAQ,QAAiB,EAAQ,SAErC,IACE,EAAQ,QAAQ,EAAS,EAAM,EAAgB,KAAK,QACtD,CAAE,MAAO,GACP,KAAK,SAAS,EAAS,EAAS,EAClC,CARA,CAQA,IAGE,IACgB,mBAAP,EACT,EAAG,EAAO,UAEV,QAAQ,KACN,+DAAiE,GAIzE,EAGF,OAAO,QAAU","file":"/npm/discordjs-command@0.9.1/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/discordjs-command@0.9.1/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const { Collection } = require('discord.js');\r\n\r\nconst isValidMiddleware = require('./util/isValidMiddleware');\r\nconst parseCommand = require('./util/parseCommand');\r\nconst isInCooldown = require('./util/isInCooldown');\r\nconst helpCommand = require('./util/helpCommand');\r\nconst getAllFiles = require('./util/getAllFiles');\r\n\r\nclass Command {\r\n  constructor(\r\n    client,\r\n    {\r\n      prefix = '>>',\r\n      superUser = '',\r\n      showCommandNotFoundMessage = false,\r\n      directMessageCommands = 'ignore',\r\n      dmHelp = true,\r\n      typescript = false,\r\n    },\r\n    cmdDir\r\n  ) {\r\n    this._client = client;\r\n    this._config = {\r\n      prefix,\r\n      superUser,\r\n      showCommandNotFoundMessage,\r\n      directMessageCommands,\r\n      dmHelp,\r\n      typescript,\r\n    };\r\n    this._middleware = [];\r\n\r\n    // Error Handler\r\n    this._onError = (message, command, error) => {\r\n      console.error('[Discord] COMMAND ERROR ---');\r\n      console.error('Error: ' + error.message);\r\n      console.error('User: ' + message.author.username);\r\n      console.error('Command: ' + command.name);\r\n      console.error('Stack Trace: ');\r\n      console.error(error);\r\n      message.channel.send(\r\n        ':x: There was an error trying to execute that command!'\r\n      );\r\n    };\r\n\r\n    // COMMANDS HANDLER\r\n    client.commands = new Collection();\r\n    client.cooldowns = new Collection();\r\n\r\n    // Gets all .js files in the commands folder and its subfolders ignoring files that start with _\r\n    const cmdFiles = getAllFiles(cmdDir, {\r\n      typescript: this._config.typescript,\r\n    });\r\n\r\n    for (const file of cmdFiles) {\r\n      const command = require(file.replace(__dirname, './'));\r\n      client.commands.set(command.name, command);\r\n    }\r\n  }\r\n\r\n  changePrefix(newPrefix) {\r\n    this._config.prefix = newPrefix.trimStart();\r\n  }\r\n\r\n  getCommandList() {\r\n    return Array.from(this._client.commands.keys());\r\n  }\r\n\r\n  use(middleware) {\r\n    if (isValidMiddleware(middleware)) {\r\n      this._middleware.push(middleware);\r\n    } else {\r\n      throw new Error('Invalid middleware');\r\n    }\r\n  }\r\n\r\n  onError(errorHandler) {\r\n    if (!errorHandler || typeof errorHandler !== 'function') {\r\n      throw new Error('errorHandler must be a function');\r\n    }\r\n    this._onError = errorHandler;\r\n  }\r\n\r\n  ListenForCommands(cb) {\r\n    const client = this._client;\r\n    const { cooldowns } = this._client;\r\n\r\n    client.on('message', message => {\r\n      const {\r\n        prefix,\r\n        superUser,\r\n        showCommandNotFoundMessage,\r\n        directMessageCommands,\r\n      } = this._config;\r\n\r\n      // If message sent by bot or doesn't have prefix, return\r\n      if (!message.content.startsWith(prefix) || message.author.bot) {\r\n        return;\r\n      }\r\n\r\n      // Isolate command name and arguments\r\n      const commandRequest = { ...parseCommand(message.content, prefix) };\r\n\r\n      // Use all middleware registered\r\n      for (const middleware of this._middleware) {\r\n        try {\r\n          if (!middleware(commandRequest, message)) return;\r\n        } catch (e) {\r\n          console.error('An error ocurred in a middleware!');\r\n          return;\r\n        }\r\n      }\r\n\r\n      const { args, commandName, commandContent } = commandRequest;\r\n\r\n      const command =\r\n        client.commands.get(commandName) ||\r\n        client.commands.find(\r\n          cmd => cmd.aliases && cmd.aliases.includes(commandName)\r\n        );\r\n\r\n      if (!command) {\r\n        if (commandName === 'help') {\r\n          helpCommand(message, args, this._config.prefix, this._config.dmHelp);\r\n          return;\r\n        }\r\n        if (showCommandNotFoundMessage) {\r\n          message.channel.send('I could not find that command.');\r\n        }\r\n        return;\r\n      }\r\n\r\n      // superUser can be a string or array\r\n      const isSuperUser = superUser.includes(message.author.id);\r\n\r\n      // If the command is hidden and user is not a super user return\r\n      if (command.hidden && !isSuperUser) {\r\n        if (showCommandNotFoundMessage) {\r\n          message.channel.send('I could not find that command.');\r\n        }\r\n        return;\r\n      }\r\n\r\n      const hasAdminPermission =\r\n        isSuperUser ||\r\n        message.member.hasPermission('ADMINISTRATOR', false, true, true);\r\n\r\n      if (command.admin && !hasAdminPermission) {\r\n        if (showCommandNotFoundMessage) {\r\n          message.channel.send('I could not find that command.');\r\n        }\r\n        return;\r\n      }\r\n\r\n      // Command requires arguments\r\n      if (command.args && !args.length) {\r\n        let reply = `You didn't provide arguments, ${message.author}!`;\r\n        if (command.usage) {\r\n          reply += `\\nThe proper usage would be: \\`${prefix}${command.name} ${\r\n            command.usage\r\n          }\\``;\r\n        }\r\n        return message.channel.send(reply);\r\n      }\r\n\r\n      if (message.channel.type !== 'text') {\r\n        switch (directMessageCommands) {\r\n          case 'error':\r\n            return message.reply(`I can't execute commands inside DMs!`);\r\n          case 'allow':\r\n            if (command.guildOnly) {\r\n              return message.reply(\r\n                `I can't execute \\`${command.name}\\` inside DMs!`\r\n              );\r\n            }\r\n            break;\r\n          case 'ignore':\r\n          default:\r\n            return;\r\n        }\r\n      }\r\n\r\n      if (!cooldowns.has(command.name)) {\r\n        cooldowns.set(command.name, new Collection());\r\n      }\r\n\r\n      const cd = isInCooldown(command, cooldowns, message.author.id);\r\n      if (cd) {\r\n        message.channel.send(\r\n          `Please wait ${cd} more second(s) before using the \\`${\r\n            command.name\r\n          }\\` command.`\r\n        );\r\n        return;\r\n      }\r\n\r\n      if (command.delete === true) message.delete();\r\n\r\n      try {\r\n        command.execute(message, args, commandContent, this._config);\r\n      } catch (error) {\r\n        this._onError(message, command, error);\r\n      }\r\n    });\r\n\r\n    if (cb) {\r\n      if (typeof cb === 'function') {\r\n        cb(client.commands);\r\n      } else {\r\n        console.warn(\r\n          'Type of callback must be function. Instead received: ' + typeof cb\r\n        );\r\n      }\r\n    }\r\n  }\r\n}\r\n\r\nmodule.exports = Command;\r\n"]}