Loading...
Searching...
No Matches
DiscordRestClient::DiscordRestClient Class Reference

this class provides the REST client API for communication with Discord servers More...

## Public Member Functions

| constructor (hash< auto > opts, *softbool do_not_connect)
| creates the object with the given options

## Static Public Member Functions

static hash< auto > | getOptions (hash< auto > opts)
| returns options for DiscordRestClient::DiscordRestClient::constructor()

## Public Attributes

const | DefaultApi = 10
| The default API to use.
const | DefaultAuthArgs = ...
| Default OAuth2 auth args.
const | DefaultAuthUrl = "https://discord.com/oauth2/authorize"
| Default authorization request URL.
const | DefaultData = "json"
| Default "data" option value.
const | DefaultGrantType = "authorization_code"
| Default OAuth2 grant type.
const | DefaultOptions = ...
| Default constructor options.
const | DefaultPingHeaders = ...
| Default Discord ping headers.
const | DefaultPingMethod = "GET"
| Default Discord ping method.
const | DefaultPingPath = "users/@me"
| Default Discord ping path.
const | DefaultScopes = ("bot", "guilds", "identify", "messages.read")
| Default OAuth2 scopes.
const | DefaultTokenUrl = "https://discord.com/api/oauth2/token"
| Default token request URL.
const | DefaultUrl = "https://discord.com/api"
| Default Discord REST API URL.

## Detailed Description

this class provides the REST client API for communication with Discord servers

You must use an OAuth2 token by setting the `token` and `oauth2_refresh_token` options; the following options need to be set as well:

- `oauth2_client_id:` the OAuth2 client ID
- `oauth2_client_secret:` the OAuth2 client secret

Then an external program has to guide the user through using the authorization_grant flow to get a token to use; this module does not implement that flow.

## Member Function Documentation

## constructor()

DiscordRestClient::DiscordRestClient::constructor | ( | hash< auto > | opts,
|  | *softbool | do_not_connect )

creates the object with the given options

Example:
  DiscordRestClient rest(opts);

Parameters

  opts | valid options are all the options for the RestClient class; note that the URL is set by default if not provided (see DefaultUrl)
  do_not_connect | if `False` (the default), then a connection will be immediately established to the remote server

Exceptions

  RESTCLIENT-ERROR | invalid option passed to constructor, unsupported data serialization, etc