Module: OnyxCord::Bot::Invites
- Included in:
- OnyxCord::Bot
- Defined in:
- lib/onyxcord/core/bot/invites.rb
Instance Method Summary collapse
-
#accept_invite(invite) ⇒ Object
Makes the bot join an invite to a server.
-
#delete_invite(code) ⇒ Object
Revokes an invite to a server.
-
#invite_url(server: nil, permission_bits: nil, redirect_uri: nil, scopes: ['bot']) ⇒ String
Creates an OAuth invite URL that can be used to invite this bot to a particular server.
Instance Method Details
#accept_invite(invite) ⇒ Object
Makes the bot join an invite to a server.
8 9 10 11 |
# File 'lib/onyxcord/core/bot/invites.rb', line 8 def accept_invite(invite) resolved = invite(invite).code REST::Invite.accept(token, resolved) end |
#delete_invite(code) ⇒ Object
Revokes an invite to a server. Will fail unless you have the Manage Server permission. It is recommended that you use Invite#delete instead.
36 37 38 39 |
# File 'lib/onyxcord/core/bot/invites.rb', line 36 def delete_invite(code) invite = resolve_invite_code(code) REST::Invite.delete(token, invite) end |
#invite_url(server: nil, permission_bits: nil, redirect_uri: nil, scopes: ['bot']) ⇒ String
Creates an OAuth invite URL that can be used to invite this bot to a particular server.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/onyxcord/core/bot/invites.rb', line 19 def invite_url(server: nil, permission_bits: nil, redirect_uri: nil, scopes: ['bot']) @client_id ||= bot_application.id query = URI.encode_www_form({ client_id: @client_id, guild_id: server&.id, permissions: , redirect_uri: redirect_uri, scope: scopes.join(' ') }.compact) "https://discord.com/oauth2/authorize?#{query}" end |