Module: Discordrb::API::Application

Defined in:
lib/discordrb/api/application.rb

Overview

API calls for slash commands.

Class Method Summary collapse

Class Method Details

.batch_edit_command_permissions(token, application_id, guild_id, permissions) ⇒ Object



191
192
193
194
195
196
197
198
199
200
201
# File 'lib/discordrb/api/application.rb', line 191

def batch_edit_command_permissions(token, application_id, guild_id, permissions)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands_cid_permissions,
    guild_id,
    :put,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/permissions",
    permissions.to_json,
    Authorization: token,
    content_type: :json
  )
end

.bulk_overwrite_global_commands(token, application_id, commands) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/discordrb/api/application.rb', line 73

def bulk_overwrite_global_commands(token, application_id, commands)
  Discordrb::API.request(
    :applications_aid_commands,
    nil,
    :put,
    "#{Discordrb::API.api_base}/applications/#{application_id}/commands",
    commands.to_json,
    Authorization: token,
    content_type: :json
  )
end

.bulk_overwrite_guild_commands(token, application_id, guild_id, commands) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
# File 'lib/discordrb/api/application.rb', line 151

def bulk_overwrite_guild_commands(token, application_id, guild_id, commands)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands,
    guild_id,
    :put,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
    commands.to_json,
    Authorization: token,
    content_type: :json
  )
end

.create_global_command(token, application_id, name, description, options = [], default_permission = nil, type = 1) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/discordrb/api/application.rb', line 33

def create_global_command(token, application_id, name, description, options = [], default_permission = nil, type = 1)
  Discordrb::API.request(
    :applications_aid_commands,
    nil,
    :post,
    "#{Discordrb::API.api_base}/applications/#{application_id}/commands",
    { name: name, description: description, options: options, default_permission: default_permission, type: type }.to_json,
    Authorization: token,
    content_type: :json
  )
end

.create_guild_command(token, application_id, guild_id, name, description, options = nil, default_permission = nil, type = 1) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/discordrb/api/application.rb', line 111

def create_guild_command(token, application_id, guild_id, name, description, options = nil, default_permission = nil, type = 1)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands,
    guild_id,
    :post,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
    { name: name, description: description, options: options, default_permission: default_permission, type: type }.to_json,
    Authorization: token,
    content_type: :json
  )
end

.delete_global_command(token, application_id, command_id) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/discordrb/api/application.rb', line 61

def delete_global_command(token, application_id, command_id)
  Discordrb::API.request(
    :applications_aid_commands_cid,
    nil,
    :delete,
    "#{Discordrb::API.api_base}/applications/#{application_id}/commands/#{command_id}",
    Authorization: token
  )
end

.delete_guild_command(token, application_id, guild_id, command_id) ⇒ Object



139
140
141
142
143
144
145
146
147
# File 'lib/discordrb/api/application.rb', line 139

def delete_guild_command(token, application_id, guild_id, command_id)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands_cid,
    guild_id,
    :delete,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
    Authorization: token
  )
end

.edit_global_command(token, application_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/discordrb/api/application.rb', line 47

def edit_global_command(token, application_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1)
  Discordrb::API.request(
    :applications_aid_commands_cid,
    nil,
    :patch,
    "#{Discordrb::API.api_base}/applications/#{application_id}/commands/#{command_id}",
    { name: name, description: description, options: options, default_permission: default_permission, type: type }.compact.to_json,
    Authorization: token,
    content_type: :json
  )
end

.edit_guild_command(token, application_id, guild_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
# File 'lib/discordrb/api/application.rb', line 125

def edit_guild_command(token, application_id, guild_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands_cid,
    guild_id,
    :patch,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
    { name: name, description: description, options: options, default_permission: default_permission, type: type }.compact.to_json,
    Authorization: token,
    content_type: :json
  )
end

.edit_guild_command_permissions(token, application_id, guild_id, command_id, permissions) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
# File 'lib/discordrb/api/application.rb', line 177

def edit_guild_command_permissions(token, application_id, guild_id, command_id, permissions)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands_cid_permissions,
    guild_id,
    :put,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions",
    { permissions: permissions }.to_json,
    Authorization: token,
    content_type: :json
  )
end

.get_global_command(token, application_id, command_id) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/discordrb/api/application.rb', line 21

def get_global_command(token, application_id, command_id)
  Discordrb::API.request(
    :applications_aid_commands_cid,
    nil,
    :get,
    "#{Discordrb::API.api_base}/applications/#{application_id}/commands/#{command_id}",
    Authorization: token
  )
end

.get_global_commands(token, application_id) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/discordrb/api/application.rb', line 9

def get_global_commands(token, application_id)
  Discordrb::API.request(
    :applications_aid_commands,
    nil,
    :get,
    "#{Discordrb::API.api_base}/applications/#{application_id}/commands",
    Authorization: token
  )
end

.get_guild_command(token, application_id, guild_id, command_id) ⇒ Object



99
100
101
102
103
104
105
106
107
# File 'lib/discordrb/api/application.rb', line 99

def get_guild_command(token, application_id, guild_id, command_id)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands_cid,
    guild_id,
    :get,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
    Authorization: token
  )
end

.get_guild_command_permissions(token, application_id, guild_id) ⇒ Object



165
166
167
168
169
170
171
172
173
# File 'lib/discordrb/api/application.rb', line 165

def get_guild_command_permissions(token, application_id, guild_id)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands_permissions,
    guild_id,
    :get,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/permissions",
    Authorization: token
  )
end

.get_guild_commands(token, application_id, guild_id) ⇒ Object



87
88
89
90
91
92
93
94
95
# File 'lib/discordrb/api/application.rb', line 87

def get_guild_commands(token, application_id, guild_id)
  Discordrb::API.request(
    :applications_aid_guilds_gid_commands,
    guild_id,
    :get,
    "#{Discordrb::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
    Authorization: token
  )
end