Class: ESM::Command::Community::ResetCooldown

Inherits:
ApplicationCommand show all
Defined in:
lib/esm/command/community/reset_cooldown.rb

Instance Method Summary collapse

Instance Method Details

#on_executeObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/esm/command/community/reset_cooldown.rb', line 40

def on_execute
  check_for_owned_server! if arguments.server_id
  check_for_valid_command!
  check_for_registered_target_user! # Don't allow User::Ephemeral

  # Send the confirmation request
  reply(confirmation_embed)
  response = ESM.bot.await_response(current_user, expected: [I18n.t("yes"), I18n.t("no")], timeout: 120)
  return reply(I18n.t("commands.reset_cooldown.cancellation_reply")) if response.nil? || response.downcase == I18n.t("no").downcase

  # Reset all cooldowns for that user.
  cooldown_query.each(&:reset!)

  # Send the success message
  reply(success_embed)
end