Class: DComm::DiscordAPI
- Inherits:
-
Object
- Object
- DComm::DiscordAPI
- Defined in:
- lib/dcomm/discord_api.rb
Instance Attribute Summary collapse
-
#auth_header ⇒ Object
readonly
Returns the value of attribute auth_header.
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
Instance Method Summary collapse
- #apply_global_app_cmds(app_id:, commands:) ⇒ Object
- #apply_guild_app_cmds(app_id:, guild_id:, commands:) ⇒ Object
- #create_global_app_cmd(app_id:, command:) ⇒ Object
- #create_guild_app_cmd(app_id:, guild_id:, command:) ⇒ Object
- #delete_global_app_cmd(app_id:, command_id:) ⇒ Object
- #delete_guild_app_cmd(app_id:, guild_id:, command_id:) ⇒ Object
- #edit_global_app_cmd(app_id:, command_id:, command:) ⇒ Object
- #edit_guild_app_cmd(app_id:, guild_id:, command_id:, command:) ⇒ Object
-
#initialize(auth_header:, base_uri: 'https://discord.com/api/v10') ⇒ DiscordAPI
constructor
A new instance of DiscordAPI.
- #list_global_app_cmds(app_id:) ⇒ Object
- #list_guild_app_cmds(app_id:, guild_id:) ⇒ Object
- #show_global_app_cmd(app_id:, command_id:) ⇒ Object
- #show_guild_app_cmd(app_id:, guild_id:, command_id:) ⇒ Object
Constructor Details
#initialize(auth_header:, base_uri: 'https://discord.com/api/v10') ⇒ DiscordAPI
Returns a new instance of DiscordAPI.
13 14 15 16 |
# File 'lib/dcomm/discord_api.rb', line 13 def initialize(auth_header:, base_uri: 'https://discord.com/api/v10') @auth_header = auth_header @base_uri = base_uri end |
Instance Attribute Details
#auth_header ⇒ Object (readonly)
Returns the value of attribute auth_header.
11 12 13 |
# File 'lib/dcomm/discord_api.rb', line 11 def auth_header @auth_header end |
#base_uri ⇒ Object (readonly)
Returns the value of attribute base_uri.
11 12 13 |
# File 'lib/dcomm/discord_api.rb', line 11 def base_uri @base_uri end |
Instance Method Details
#apply_global_app_cmds(app_id:, commands:) ⇒ Object
18 19 20 |
# File 'lib/dcomm/discord_api.rb', line 18 def apply_global_app_cmds(app_id:, commands:) put("/applications/#{app_id}/commands", body: commands) end |
#apply_guild_app_cmds(app_id:, guild_id:, commands:) ⇒ Object
22 23 24 |
# File 'lib/dcomm/discord_api.rb', line 22 def apply_guild_app_cmds(app_id:, guild_id:, commands:) put("/applications/#{app_id}/guilds/#{guild_id}/commands", body: commands) end |
#create_global_app_cmd(app_id:, command:) ⇒ Object
26 27 28 |
# File 'lib/dcomm/discord_api.rb', line 26 def create_global_app_cmd(app_id:, command:) post("/applications/#{app_id}/commands", body: command) end |
#create_guild_app_cmd(app_id:, guild_id:, command:) ⇒ Object
30 31 32 |
# File 'lib/dcomm/discord_api.rb', line 30 def create_guild_app_cmd(app_id:, guild_id:, command:) post("/applications/#{app_id}/guilds/#{guild_id}/commands", body: command) end |
#delete_global_app_cmd(app_id:, command_id:) ⇒ Object
34 35 36 |
# File 'lib/dcomm/discord_api.rb', line 34 def delete_global_app_cmd(app_id:, command_id:) delete("/applications/#{app_id}/commands/#{command_id}") end |
#delete_guild_app_cmd(app_id:, guild_id:, command_id:) ⇒ Object
38 39 40 |
# File 'lib/dcomm/discord_api.rb', line 38 def delete_guild_app_cmd(app_id:, guild_id:, command_id:) delete("/applications/#{app_id}/guilds/#{guild_id}/commands/#{command_id}") end |
#edit_global_app_cmd(app_id:, command_id:, command:) ⇒ Object
58 59 60 |
# File 'lib/dcomm/discord_api.rb', line 58 def edit_global_app_cmd(app_id:, command_id:, command:) patch("/applications/#{app_id}/commands/#{command_id}", body: command) end |
#edit_guild_app_cmd(app_id:, guild_id:, command_id:, command:) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/dcomm/discord_api.rb', line 62 def edit_guild_app_cmd(app_id:, guild_id:, command_id:, command:) patch( "/applications/#{app_id}/guilds/#{guild_id}/commands/#{command_id}", body: command, ) end |
#list_global_app_cmds(app_id:) ⇒ Object
42 43 44 |
# File 'lib/dcomm/discord_api.rb', line 42 def list_global_app_cmds(app_id:) get("/applications/#{app_id}/commands") end |
#list_guild_app_cmds(app_id:, guild_id:) ⇒ Object
46 47 48 |
# File 'lib/dcomm/discord_api.rb', line 46 def list_guild_app_cmds(app_id:, guild_id:) get("/applications/#{app_id}/guilds/#{guild_id}/commands") end |
#show_global_app_cmd(app_id:, command_id:) ⇒ Object
50 51 52 |
# File 'lib/dcomm/discord_api.rb', line 50 def show_global_app_cmd(app_id:, command_id:) get("/applications/#{app_id}/commands/#{command_id}") end |
#show_guild_app_cmd(app_id:, guild_id:, command_id:) ⇒ Object
54 55 56 |
# File 'lib/dcomm/discord_api.rb', line 54 def show_guild_app_cmd(app_id:, guild_id:, command_id:) get("/applications/#{app_id}/guilds/#{guild_id}/commands/#{command_id}") end |