Guest User

vortexusframework.js

a guest
Sep 21st, 2019
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. module.exports = function (Bot,msg){
  3. if (!msg.content.startsWith(Bot.Config.Bot.prefix) || msg.author.bot) return
  4.  
  5. // Check if command exists
  6.  
  7. const args = msg.content.slice(Bot.Config.Bot.prefix.length).split(/ +/)
  8. const commandName = args.shift().toLowerCase()
  9. const command = Bot.Commands.get(commandName) || Bot.Commands.find(command => command.aliases && command.aliases.includes(commandName))
  10. if (!command) return
  11. if (!command.module) return
  12.  
  13. // Guildonly check
  14.  
  15. if (command.guildOnly && msg.channel.type !== "text") {
  16. const Embed = new Bot.Discord.RichEmbed()
  17. .setColor("#ff0000")
  18. .setTitle("`"+commandName+"` can only be used inside of servers.")
  19. .setFooter("Requested by "+msg.author.tag, msg.author.avatarURL)
  20. return msg.channel.send(Embed)
  21. } else if (command.guildOnly && msg.channel.type == "text" &! Bot.Config[msg.guild.id]) {
  22. const Embed = new Bot.Discord.RichEmbed()
  23. .setColor("#ff0000")
  24. .setTitle("There was an issue with running `"+commandName+"`")
  25. .setDescription("This command can only be used inside of guilds, and this guild's configuration isn't set up properly!")
  26. .setFooter("Requested by "+msg.author.tag, msg.author.avatarURL)
  27. return msg.channel.send(Embed)
  28. }
  29.  
  30. // Cooldown check
  31.  
  32. if (!Bot.Cooldowns.has(command.name)) {
  33. Bot.Cooldowns.set(command.name, new Bot.Discord.Collection())
  34. }
  35. const now = Date.now()
  36. const timestamps = Bot.Cooldowns.get(command.name)
  37. const cooldownAmount = (command.cooldown || Bot.Config.Bot.command_cooldown) * 1000
  38. if (timestamps.has(msg.author.id)) {
  39. const expirationTime = timestamps.get(msg.author.id) + cooldownAmount
  40.  
  41. if (now < expirationTime) {
  42. const timeLeft = (expirationTime - now) / 1000
  43. const Embed = new Bot.Discord.RichEmbed()
  44. .setColor("#ff0000")
  45. .setTitle("Please wait "+timeLeft.toFixed(1)+" more seconds before using `"+commandName+"`!")
  46. .setFooter("Requested by "+msg.author.tag, msg.author.avatarURL)
  47. return msg.channel.send(Embed)
  48. }
  49. }
  50. timestamps.set(msg.author.id, now)
  51. setTimeout(() => timestamps.delete(msg.author.id), cooldownAmount)
  52.  
  53. // Enabled Check
  54.  
  55. if (command.module && Bot.Config[msg.guild.id] && msg.channel.type == "text" && command.guildOnly) {
  56. if (!Bot.Config[msg.guild.id].modules[command.module][commandName].enabled) return
  57. }
  58. // Permission check
  59.  
  60. if (command.permissions && Bot.Config[msg.guild.id] && msg.channel.type == "text"){
  61. if (!msg.member.hasPermission(command.permissions)){
  62. const Embed = new Bot.Discord.RichEmbed()
  63. .setColor("#ff0000")
  64. .setTitle("You do not have permission to run `"+commandName+"`!")
  65. .setFooter("Requested by "+msg.author.tag, msg.author.avatarURL)
  66. return msg.channel.send(Embed)
  67. }
  68. if (!msg.guild.me.hasPermission(command.permissions)){
  69. const Embed = new Bot.Discord.RichEmbed()
  70. .setColor("#ff0000")
  71. .setTitle("I do not have permission to run `"+commandName+"`!")
  72. .setFooter("Requested by "+msg.author.tag, msg.author.avatarURL)
  73. return msg.channel.send(Embed)
  74. }
  75. }
  76.  
  77. // Argument check
  78.  
  79. if (command.args && !args.length) {
  80. const Embed = new Bot.Discord.RichEmbed()
  81. .setColor("#ff0000")
  82. .setTitle("`"+commandName+"` requires arguments!")
  83. .setDescription("The proper usage is `"+Bot.Config[msg.guild.id].prefix+commandName+" "+command.usage+"`")
  84. .setFooter("Requested by "+msg.author.tag, msg.author.avatarURL)
  85. return msg.channel.send(Embed)
  86. }
  87. try {
  88. msg.react("👀")
  89. Bot.Commands.get(command.name).execute(Bot,msg,args)
  90. } catch (error) {
  91. msg.channel.stopTyping(true)
  92. const Embed = new Bot.Discord.RichEmbed()
  93. .setColor("#ff0000")
  94. .setTitle("There was an issue with running `"+commandName+"`")
  95. .setDescription("For geeks: `"+error+"`")
  96. .setFooter("Requested by "+msg.author.tag, msg.author.avatarURL)
  97. msg.channel.send(Embed)
  98. }
  99. }
RAW Paste Data