Module: OnyxCord::REST::Application

Defined in:
lib/onyxcord/rest/routes/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



199
200
201
202
203
204
205
206
207
208
209
# File 'lib/onyxcord/rest/routes/application.rb', line 199

def batch_edit_command_permissions(token, application_id, guild_id, permissions)
  OnyxCord::REST.request(
    :applications_aid_guilds_gid_commands_cid_permissions,
    guild_id,
    :put,
    "#{OnyxCord::REST.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



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/onyxcord/rest/routes/application.rb', line 77

def bulk_overwrite_global_commands(token, application_id, commands)
  OnyxCord::REST.request(
    :applications_aid_commands,
    nil,
    :put,
    "#{OnyxCord::REST.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



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/onyxcord/rest/routes/application.rb', line 159

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

.create_application_emoji(token, application_id, name, image) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
# File 'lib/onyxcord/rest/routes/application.rb', line 261

def create_application_emoji(token, application_id, name, image)
  OnyxCord::REST.request(
    :applications_aid_emojis,
    application_id,
    :post,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis",
    { name: name, image: image }.to_json,
    Authorization: token,
    content_type: :json
  )
end

.create_global_command(token, application_id, name, description, options = [], default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = false, integration_types = nil, name_localizations: nil, description_localizations: nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/onyxcord/rest/routes/application.rb', line 33

def create_global_command(token, application_id, name, description, options = [], default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = false, integration_types = nil, name_localizations: nil, description_localizations: nil)
  OnyxCord::REST.request(
    :applications_aid_commands,
    nil,
    :post,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/commands",
    { name: name, description: description, options: options, default_permission: default_permission, type: type,
      default_member_permissions: default_member_permissions, contexts: contexts, nsfw: nsfw, integration_types: integration_types,
      name_localizations: name_localizations, description_localizations: description_localizations }.compact.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, default_member_permissions = nil, contexts = nil, nsfw = false, integration_types = nil, name_localizations: nil, description_localizations: nil) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/onyxcord/rest/routes/application.rb', line 115

def create_guild_command(token, application_id, guild_id, name, description, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = false, integration_types = nil, name_localizations: nil, description_localizations: nil)
  OnyxCord::REST.request(
    :applications_aid_guilds_gid_commands,
    guild_id,
    :post,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
    { name: name, description: description, options: options, default_permission: default_permission, type: type,
      default_member_permissions: default_member_permissions, contexts: contexts, nsfw: nsfw, integration_types: integration_types,
      name_localizations: name_localizations, description_localizations: description_localizations }.compact.to_json,
    Authorization: token,
    content_type: :json
  )
end

.delete_application_emoji(token, application_id, emoji_id) ⇒ Object



289
290
291
292
293
294
295
296
297
# File 'lib/onyxcord/rest/routes/application.rb', line 289

def delete_application_emoji(token, application_id, emoji_id)
  OnyxCord::REST.request(
    :applications_aid_emojis_eid,
    application_id,
    :delete,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis/#{emoji_id}",
    Authorization: token
  )
end

.delete_global_command(token, application_id, command_id) ⇒ Object



65
66
67
68
69
70
71
72
73
# File 'lib/onyxcord/rest/routes/application.rb', line 65

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

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



147
148
149
150
151
152
153
154
155
# File 'lib/onyxcord/rest/routes/application.rb', line 147

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

.edit_application_emoji(token, application_id, emoji_id, name) ⇒ Object



275
276
277
278
279
280
281
282
283
284
285
# File 'lib/onyxcord/rest/routes/application.rb', line 275

def edit_application_emoji(token, application_id, emoji_id, name)
  OnyxCord::REST.request(
    :applications_aid_emojis_eid,
    application_id,
    :patch,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis/#{emoji_id}",
    { name: name }.to_json,
    Authorization: token,
    content_type: :json
  )
end

.edit_global_command(token, application_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = nil, integration_types = nil, name_localizations: nil, description_localizations: nil) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/onyxcord/rest/routes/application.rb', line 49

def edit_global_command(token, application_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = nil, integration_types = nil, name_localizations: nil, description_localizations: nil)
  OnyxCord::REST.request(
    :applications_aid_commands_cid,
    nil,
    :patch,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/commands/#{command_id}",
    { name: name, description: description, options: options, default_permission: default_permission, type: type,
      default_member_permissions: default_member_permissions, contexts: contexts, nsfw: nsfw, integration_types: integration_types,
      name_localizations: name_localizations, description_localizations: description_localizations }.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, default_member_permissions = nil, contexts = nil, nsfw = nil, integration_types = nil, name_localizations: nil, description_localizations: nil) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/onyxcord/rest/routes/application.rb', line 131

def edit_guild_command(token, application_id, guild_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = nil, integration_types = nil, name_localizations: nil, description_localizations: nil)
  OnyxCord::REST.request(
    :applications_aid_guilds_gid_commands_cid,
    guild_id,
    :patch,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
    { name: name, description: description, options: options, default_permission: default_permission, type: type,
      default_member_permissions: default_member_permissions, contexts: contexts, nsfw: nsfw, integration_types: integration_types,
      name_localizations: name_localizations, description_localizations: description_localizations }.compact.to_json,
    Authorization: token,
    content_type: :json
  )
end

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



185
186
187
188
189
190
191
192
193
194
195
# File 'lib/onyxcord/rest/routes/application.rb', line 185

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

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



225
226
227
228
229
230
231
232
233
# File 'lib/onyxcord/rest/routes/application.rb', line 225

def get_application_command_permissions(token, application_id, guild_id, command_id)
  OnyxCord::REST.request(
    :applications_aid_guilds_gid_commands_cid_permissions,
    guild_id,
    :get,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions",
    Authorization: token
  )
end

.get_application_emoji(token, application_id, emoji_id) ⇒ Object



249
250
251
252
253
254
255
256
257
# File 'lib/onyxcord/rest/routes/application.rb', line 249

def get_application_emoji(token, application_id, emoji_id)
  OnyxCord::REST.request(
    :applications_aid_emojis_eid,
    application_id,
    :get,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis/#{emoji_id}",
    Authorization: token
  )
end

.get_application_role_connection_metadata_records(token, application_id) ⇒ Object



315
316
317
318
319
320
321
322
323
# File 'lib/onyxcord/rest/routes/application.rb', line 315

def (token, application_id)
  OnyxCord::REST.request(
    :applications_aid_role_connections_metadata,
    nil,
    :get,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/role-connections/metadata",
    Authorization: token
  )
end

.get_global_command(token, application_id, command_id) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/onyxcord/rest/routes/application.rb', line 21

def get_global_command(token, application_id, command_id)
  OnyxCord::REST.request(
    :applications_aid_commands_cid,
    nil,
    :get,
    "#{OnyxCord::REST.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/onyxcord/rest/routes/application.rb', line 9

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

.get_guild_application_command_permissions(token, application_id, guild_id) ⇒ Object



213
214
215
216
217
218
219
220
221
# File 'lib/onyxcord/rest/routes/application.rb', line 213

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

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



103
104
105
106
107
108
109
110
111
# File 'lib/onyxcord/rest/routes/application.rb', line 103

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

.get_guild_command_permissions(token, application_id, guild_id) ⇒ Object



173
174
175
176
177
178
179
180
181
# File 'lib/onyxcord/rest/routes/application.rb', line 173

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

.get_guild_commands(token, application_id, guild_id) ⇒ Object



91
92
93
94
95
96
97
98
99
# File 'lib/onyxcord/rest/routes/application.rb', line 91

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

.list_application_emojis(token, application_id) ⇒ Object



237
238
239
240
241
242
243
244
245
# File 'lib/onyxcord/rest/routes/application.rb', line 237

def list_application_emojis(token, application_id)
  OnyxCord::REST.request(
    :applications_aid_emojis,
    application_id,
    :get,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis",
    Authorization: token
  )
end

.set_application_role_connection_metadata_records(token, application_id, metadata) ⇒ Object



327
328
329
330
331
332
333
334
335
336
337
# File 'lib/onyxcord/rest/routes/application.rb', line 327

def (token, application_id, )
  OnyxCord::REST.request(
    :applications_aid_role_connections_metadata,
    nil,
    :put,
    "#{OnyxCord::REST.api_base}/applications/#{application_id}/role-connections/metadata",
    .to_json,
    Authorization: token,
    content_type: :json
  )
end

.update_current_application(token, custom_install_url: :undef, description: :undef, role_connections_verification_url: :undef, install_params: :undef, integration_types_config: :undef, flags: :undef, interactions_endpoint_url: :undef, tags: :undef, event_webhooks_url: :undef, event_webhooks_status: :undef, event_webhooks_types: :undef, icon: :undef, cover_image: :undef) ⇒ Object

Edit the current application for the requesting bot user. https://discord.com/developers/docs/resources/application#edit-current-application



301
302
303
304
305
306
307
308
309
310
311
# File 'lib/onyxcord/rest/routes/application.rb', line 301

def update_current_application(token, custom_install_url: :undef, description: :undef, role_connections_verification_url: :undef, install_params: :undef, integration_types_config: :undef, flags: :undef, interactions_endpoint_url: :undef, tags: :undef, event_webhooks_url: :undef, event_webhooks_status: :undef, event_webhooks_types: :undef, icon: :undef, cover_image: :undef)
  OnyxCord::REST.request(
    :applications_me,
    nil,
    :patch,
    "#{OnyxCord::REST.api_base}/applications/@me",
    { custom_install_url:, description:, role_connections_verification_url:, install_params:, integration_types_config:, flags:, interactions_endpoint_url:, tags:, event_webhooks_url:, event_webhooks_status:, event_webhooks_types:, icon:, cover_image: }.reject { |_, value| value == :undef }.to_json,
    Authorization: token,
    content_type: :json
  )
end