Method: Discordrb::API.raw_request

Defined in:
lib/discordrb/api.rb

.raw_request(type, attributes) ⇒ Object

Performs a RestClient request.

Parameters:

  • type (Symbol)

    The type of HTTP request to use.

  • attributes (Array)

    The attributes for the request.



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/discordrb/api.rb', line 80

def raw_request(type, attributes)
  RestClient.send(type, *attributes)
rescue RestClient::Forbidden => e
  # HACK: for #request, dynamically inject restclient's response into NoPermission - this allows us to ratelimit
  noprm = Discordrb::Errors::NoPermission.new
  noprm.define_singleton_method(:_rc_response) { e.response }
  raise noprm, "The bot doesn't have the required permission to do this!"
rescue RestClient::BadGateway
  Discordrb::LOGGER.warn('Got a 502 while sending a request! Not a big deal, retrying the request')
  retry
end