lib_discord 0.1.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +88 -0
- data/README.md +39 -65
- data/lib/lib_discord/client.rb +2665 -138
- data/lib/lib_discord/formatter.rb +108 -0
- data/lib/lib_discord/maps.rb +731 -0
- data/lib/lib_discord/permissions.rb +85 -0
- data/lib/lib_discord/urls.rb +3 -12
- data/lib/lib_discord/version.rb +1 -4
- data/lib/lib_discord.rb +3 -5
- metadata +10 -119
- data/CHANGELOG.md +0 -152
- data/lib/lib_discord/application.rb +0 -43
- data/lib/lib_discord/application_command.rb +0 -341
- data/lib/lib_discord/application_role_connection_metadata.rb +0 -52
- data/lib/lib_discord/audit_log.rb +0 -36
- data/lib/lib_discord/auto_moderation.rb +0 -106
- data/lib/lib_discord/channel.rb +0 -716
- data/lib/lib_discord/emoji.rb +0 -106
- data/lib/lib_discord/errors.rb +0 -31
- data/lib/lib_discord/guild.rb +0 -830
- data/lib/lib_discord/guild_scheduled_event.rb +0 -133
- data/lib/lib_discord/guild_template.rb +0 -128
- data/lib/lib_discord/interaction.rb +0 -163
- data/lib/lib_discord/invite.rb +0 -47
- data/lib/lib_discord/mappers/application_command_option_types.rb +0 -22
- data/lib/lib_discord/mappers/application_command_permission_types.rb +0 -14
- data/lib/lib_discord/mappers/application_command_types.rb +0 -14
- data/lib/lib_discord/mappers/application_integration_types.rb +0 -13
- data/lib/lib_discord/mappers/application_role_connection_metadata_types.rb +0 -19
- data/lib/lib_discord/mappers/audit_log_events.rb +0 -67
- data/lib/lib_discord/mappers/auto_moderation_action_types.rb +0 -14
- data/lib/lib_discord/mappers/auto_moderation_event_types.rb +0 -12
- data/lib/lib_discord/mappers/auto_moderation_keyword_preset_types.rb +0 -14
- data/lib/lib_discord/mappers/auto_moderation_trigger_types.rb +0 -15
- data/lib/lib_discord/mappers/channel_forum_layout_types.rb +0 -14
- data/lib/lib_discord/mappers/channel_message_activity_types.rb +0 -15
- data/lib/lib_discord/mappers/channel_message_types.rb +0 -42
- data/lib/lib_discord/mappers/channel_sort_order_types.rb +0 -13
- data/lib/lib_discord/mappers/channel_types.rb +0 -24
- data/lib/lib_discord/mappers/channel_video_quality_modes.rb +0 -13
- data/lib/lib_discord/mappers/guild_default_message_notification_levels.rb +0 -13
- data/lib/lib_discord/mappers/guild_explicit_content_filter_levels.rb +0 -14
- data/lib/lib_discord/mappers/guild_integration_expire_behaviors.rb +0 -13
- data/lib/lib_discord/mappers/guild_mfa_levels.rb +0 -13
- data/lib/lib_discord/mappers/guild_nsfw_levels.rb +0 -15
- data/lib/lib_discord/mappers/guild_onboarding_modes.rb +0 -13
- data/lib/lib_discord/mappers/guild_premium_tiers.rb +0 -15
- data/lib/lib_discord/mappers/guild_prompt_types.rb +0 -13
- data/lib/lib_discord/mappers/guild_scheduled_event_entity_types.rb +0 -14
- data/lib/lib_discord/mappers/guild_scheduled_event_privacy_levels.rb +0 -12
- data/lib/lib_discord/mappers/guild_scheduled_event_statuses.rb +0 -15
- data/lib/lib_discord/mappers/guild_verification_levels.rb +0 -16
- data/lib/lib_discord/mappers/interaction_callback_types.rb +0 -19
- data/lib/lib_discord/mappers/interaction_context_types.rb +0 -14
- data/lib/lib_discord/mappers/interaction_types.rb +0 -16
- data/lib/lib_discord/mappers/invite_target_types.rb +0 -13
- data/lib/lib_discord/mappers/message_component_button_styles.rb +0 -16
- data/lib/lib_discord/mappers/message_component_text_input_styles.rb +0 -13
- data/lib/lib_discord/mappers/message_component_types.rb +0 -19
- data/lib/lib_discord/mappers/poll_layout_types.rb +0 -12
- data/lib/lib_discord/mappers/stage_instance_privacy_levels.rb +0 -13
- data/lib/lib_discord/mappers/sticker_format_types.rb +0 -15
- data/lib/lib_discord/mappers/sticker_types.rb +0 -13
- data/lib/lib_discord/mappers/user_premium_types.rb +0 -15
- data/lib/lib_discord/mappers/user_visibility_types.rb +0 -13
- data/lib/lib_discord/mappers/webhooks_types.rb +0 -14
- data/lib/lib_discord/mappers.rb +0 -87
- data/lib/lib_discord/poll.rb +0 -62
- data/lib/lib_discord/resource.rb +0 -133
- data/lib/lib_discord/response.rb +0 -43
- data/lib/lib_discord/stage_instance.rb +0 -79
- data/lib/lib_discord/sticker.rb +0 -132
- data/lib/lib_discord/types.rb +0 -47
- data/lib/lib_discord/user.rb +0 -174
- data/lib/lib_discord/voice.rb +0 -29
- data/lib/lib_discord/webhook.rb +0 -299
data/lib/lib_discord/client.rb
CHANGED
@@ -1,209 +1,2736 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry-container"
|
4
3
|
require "logger"
|
4
|
+
require "net/http" # includes URI
|
5
5
|
|
6
|
-
require "lib_discord/application"
|
7
|
-
require "lib_discord/application_command"
|
8
|
-
require "lib_discord/application_role_connection_metadata"
|
9
|
-
require "lib_discord/audit_log"
|
10
|
-
require "lib_discord/auto_moderation"
|
11
|
-
require "lib_discord/channel"
|
12
|
-
require "lib_discord/emoji"
|
13
|
-
require "lib_discord/errors"
|
14
|
-
require "lib_discord/guild"
|
15
|
-
require "lib_discord/guild_scheduled_event"
|
16
|
-
require "lib_discord/guild_template"
|
17
|
-
require "lib_discord/interaction"
|
18
|
-
require "lib_discord/invite"
|
19
|
-
require "lib_discord/poll"
|
20
|
-
require "lib_discord/stage_instance"
|
21
|
-
require "lib_discord/sticker"
|
22
|
-
require "lib_discord/types"
|
23
6
|
require "lib_discord/urls"
|
24
|
-
require "lib_discord/user"
|
25
7
|
require "lib_discord/version"
|
26
|
-
require "lib_discord/voice"
|
27
|
-
require "lib_discord/webhook"
|
28
8
|
|
29
9
|
module LibDiscord
|
30
10
|
##
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
11
|
+
# @param (see Client#initialize)
|
12
|
+
# @return [Client]
|
13
|
+
#
|
14
|
+
# @see Client#initialize
|
15
|
+
def self.client(*) = Client.new(*)
|
16
|
+
|
17
|
+
##
|
18
|
+
# You will mainly be interacting with instances of this class when using
|
19
|
+
# +lib_discord+ to access Discord's web API. Initialize a client and cache it
|
20
|
+
# for as long as you need to make requests to Discord using a given
|
21
|
+
# authorization header.
|
34
22
|
#
|
35
23
|
# require "lib_discord"
|
36
24
|
# client = LibDiscord::Client.new("Bot my.amazing.token")
|
37
25
|
class Client
|
38
26
|
##
|
39
|
-
#
|
40
|
-
# RESTful web API.
|
41
|
-
#
|
42
|
-
# @param auth_header [#to_s] Authorization header to be used in
|
27
|
+
# @param auth [String] Authorization header value to be used in
|
43
28
|
# communication with Discord. In the format +Bot <token>+ or +Bearer
|
44
|
-
# <token>+.
|
45
|
-
#
|
46
|
-
# @param user_agent [
|
29
|
+
# <token>+. If you intend only to make requests to unauthenticated
|
30
|
+
# endpoints, +auth+ is not necessary.
|
31
|
+
# @param user_agent [String] User-Agent header value to use in requests to
|
47
32
|
# Discord.
|
48
|
-
# @param logger [
|
49
|
-
# provided, a basic INFO-level +$stdout+ logger is
|
50
|
-
# ( +l = Logger.new($stdout); l.level = :info+
|
51
|
-
#
|
33
|
+
# @param logger [#debug, #info, #warn, #error, #fatal] Logger to use for
|
34
|
+
# output messages. If not provided, a basic INFO-level +$stdout+ logger is
|
35
|
+
# created for internal use ( +l = Logger.new($stdout); l.level = :info+
|
36
|
+
# ). *CAUTION*: a +DEBUG+ level logger in production will leak sensitive
|
37
|
+
# data including authorization headers.
|
52
38
|
# @return [self]
|
53
39
|
#
|
54
|
-
# @raise [ConstraintError] if parameters for +auth_header+,
|
55
|
-
# +base_url+, or +user_agent+ do not respond to #to_s.
|
56
|
-
# @raise [ConstraintError] if the parameter for +logger+ is not
|
57
|
-
# an instance of Logger, or an instance that inherits from Logger.
|
58
|
-
#
|
59
40
|
# @example hook in your own logger and app-specific user-agent
|
60
41
|
# client = LibDiscord::Client.new(
|
61
42
|
# "Bot my.token",
|
62
43
|
# user_agent: "MyApp (https://example.myapp.com, 1.2.3)",
|
63
44
|
# logger: my_logger
|
64
45
|
# )
|
65
|
-
# @example
|
46
|
+
# @example Suppress all +stdout+ logger output.
|
66
47
|
# client = LibDiscord::Client.new(
|
67
48
|
# "Bot my.token",
|
68
49
|
# logger: Logger.new("/dev/null")
|
69
50
|
# )
|
51
|
+
# @example Make a request to a public endpoint.
|
52
|
+
# client = LibDiscord::Client.new
|
53
|
+
# client.get_gateway # => LibDiscord::Response
|
70
54
|
#
|
71
55
|
# @see https://discord.com/developers/docs/reference#authentication Discord
|
72
56
|
# documentation "Authentication"
|
73
57
|
# @see https://discord.com/developers/docs/reference#user-agent Discord
|
74
58
|
# documentation "User Agent"
|
75
59
|
def initialize(
|
76
|
-
|
77
|
-
base_url: "https://discord.com/api/v10",
|
60
|
+
auth = nil,
|
78
61
|
user_agent: "LibDiscord (#{LibDiscord::PROJECT_URL}, #{LibDiscord.version})",
|
79
62
|
logger: nil
|
80
63
|
)
|
81
|
-
|
82
|
-
|
83
|
-
|
64
|
+
@default_headers = {
|
65
|
+
"User-Agent" => user_agent,
|
66
|
+
"Authorization" => auth
|
67
|
+
}.compact
|
84
68
|
|
85
|
-
|
86
|
-
|
87
|
-
logger
|
69
|
+
@logger = logger
|
70
|
+
unless @logger
|
71
|
+
@logger = Logger.new($stdout)
|
72
|
+
@logger.level = :info
|
88
73
|
end
|
74
|
+
end
|
89
75
|
|
90
|
-
|
76
|
+
# @!macro [new] pQuery
|
77
|
+
# @param query [Object] HTTP query parameters. +query+ is formatted via
|
78
|
+
# +URI.encode_www_form()+.
|
79
|
+
# @!macro [new] pBody
|
80
|
+
# @param body [#to_json] Request body
|
81
|
+
# @!macro [new] rResponse
|
82
|
+
# @return [Response]
|
91
83
|
|
92
|
-
|
84
|
+
### Interaction {{{
|
93
85
|
|
94
|
-
|
95
|
-
|
96
|
-
|
86
|
+
##
|
87
|
+
# @param interaction_id [#to_s] Interaction ID
|
88
|
+
# @param interaction_token [#to_s] Interaction Token
|
89
|
+
# @macro pBody
|
90
|
+
# @macro rResponse
|
91
|
+
#
|
92
|
+
# @see https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
|
93
|
+
# Discord documentation "Create Interaction Response"
|
94
|
+
def create_interaction_response(interaction_id, interaction_token, body)
|
95
|
+
json_request(:post, discord("/interactions/#{interaction_id}/#{interaction_token}/callback"), body:)
|
96
|
+
end
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
##
|
99
|
+
# @param application_id [#to_s] Application ID
|
100
|
+
# @param interaction_token [#to_s] Interaction Token
|
101
|
+
# @macro rResponse
|
102
|
+
#
|
103
|
+
# @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response
|
104
|
+
# Discord documentation "Get Original Interaction Response"
|
105
|
+
def get_original_interaction_response(application_id, interaction_token)
|
106
|
+
json_request(:get, discord("/webhooks/#{application_id}/#{interaction_token}/messages/@original"))
|
107
|
+
end
|
101
108
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
109
|
+
##
|
110
|
+
# @param application_id [#to_s] Application ID
|
111
|
+
# @param interaction_token [#to_s] Interaction Token
|
112
|
+
# @macro pBody
|
113
|
+
# @macro rResponse
|
114
|
+
#
|
115
|
+
# @see https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response
|
116
|
+
# Discord documentation "Edit Original Interaction Response"
|
117
|
+
def edit_original_interaction_response(application_id, interaction_token, body)
|
118
|
+
json_request(:patch, discord("/webhooks/#{application_id}/#{interaction_token}/messages/@original"), body:)
|
119
|
+
end
|
110
120
|
|
111
|
-
|
112
|
-
|
113
|
-
|
121
|
+
##
|
122
|
+
# @param application_id [#to_s] Application ID
|
123
|
+
# @param interaction_token [#to_s] Interaction Token
|
124
|
+
# @macro rResponse
|
125
|
+
#
|
126
|
+
# @see https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response
|
127
|
+
# Discord documentation "Delete Original Interaction Response"
|
128
|
+
def delete_original_interaction_response(application_id, interaction_token)
|
129
|
+
json_request(:delete, discord("/webhooks/#{application_id}/#{interaction_token}/messages/@original"))
|
130
|
+
end
|
114
131
|
|
115
|
-
|
116
|
-
|
117
|
-
|
132
|
+
##
|
133
|
+
# @param application_id [#to_s] Application ID
|
134
|
+
# @param interaction_token [#to_s] Interaction Token
|
135
|
+
# @macro pBody
|
136
|
+
# @macro rResponse
|
137
|
+
#
|
138
|
+
# @see https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message
|
139
|
+
# Discord documentation "Create Followup Message"
|
140
|
+
def create_followup_message(application_id, interaction_token, body)
|
141
|
+
json_request(:post, discord("/webhooks/#{application_id}/#{interaction_token}"), body:)
|
142
|
+
end
|
118
143
|
|
119
|
-
|
120
|
-
|
121
|
-
|
144
|
+
##
|
145
|
+
# @param application_id [#to_s] Application ID
|
146
|
+
# @param interaction_token [#to_s] Interaction Token
|
147
|
+
# @param message_id [#to_s] Message ID
|
148
|
+
# @macro rResponse
|
149
|
+
#
|
150
|
+
# @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message
|
151
|
+
# Discord documentation "Get Followup Message"
|
152
|
+
def get_followup_message(application_id, interaction_token, message_id)
|
153
|
+
json_request(:get, discord("/webhooks/#{application_id}/#{interaction_token}/messages/#{message_id}"))
|
154
|
+
end
|
122
155
|
|
123
|
-
|
124
|
-
|
125
|
-
|
156
|
+
##
|
157
|
+
# @param application_id [#to_s] Application ID
|
158
|
+
# @param interaction_token [#to_s] Interaction Token
|
159
|
+
# @param message_id [#to_s] Message ID
|
160
|
+
# @macro pBody
|
161
|
+
# @macro rResponse
|
162
|
+
#
|
163
|
+
# @see https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message
|
164
|
+
# Discord documentation "Edit Followup Message"
|
165
|
+
def edit_followup_message(application_id, interaction_token, message_id, body)
|
166
|
+
json_request(:patch, discord("/webhooks/#{application_id}/#{interaction_token}/messages/#{message_id}"), body:)
|
167
|
+
end
|
126
168
|
|
127
|
-
|
128
|
-
|
129
|
-
|
169
|
+
##
|
170
|
+
# @param application_id [#to_s] Application ID
|
171
|
+
# @param interaction_token [#to_s] Interaction Token
|
172
|
+
# @param message_id [#to_s] Message ID
|
173
|
+
# @macro rResponse
|
174
|
+
#
|
175
|
+
# @see https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message
|
176
|
+
# Discord documentation "Delete Followup Message"
|
177
|
+
def delete_followup_message(application_id, interaction_token, message_id)
|
178
|
+
json_request(:delete, discord("/webhooks/#{application_id}/#{interaction_token}/messages/#{message_id}"))
|
179
|
+
end
|
130
180
|
|
131
|
-
|
132
|
-
GuildScheduledEvent.new(auth_header, base_url, user_agent, logger)
|
133
|
-
end
|
181
|
+
### }}} Interaction
|
134
182
|
|
135
|
-
|
136
|
-
GuildTemplate.new(auth_header, base_url, user_agent, logger)
|
137
|
-
end
|
183
|
+
### Application Command {{{
|
138
184
|
|
139
|
-
|
140
|
-
|
141
|
-
|
185
|
+
##
|
186
|
+
# @param application_id [#to_s] Application ID
|
187
|
+
# @macro pQuery
|
188
|
+
# @macro rResponse
|
189
|
+
#
|
190
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands
|
191
|
+
# Discord documentation "Get Global Application Commands"
|
192
|
+
def get_global_application_commands(application_id, query = {})
|
193
|
+
json_request(:get, discord("/applications/#{application_id}/commands"), query:)
|
194
|
+
end
|
142
195
|
|
143
|
-
|
144
|
-
|
145
|
-
|
196
|
+
##
|
197
|
+
# @param application_id [#to_s] Application ID
|
198
|
+
# @macro pBody
|
199
|
+
# @macro rResponse
|
200
|
+
#
|
201
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
|
202
|
+
# Discord documentation "Create Global Application Command"
|
203
|
+
def create_global_application_command(application_id, body)
|
204
|
+
json_request(:post, discord("/applications/#{application_id}/commands"), body:)
|
205
|
+
end
|
146
206
|
|
147
|
-
|
148
|
-
|
149
|
-
|
207
|
+
##
|
208
|
+
# @param application_id [#to_s] Application ID
|
209
|
+
# @param command_id [#to_s] Command ID
|
210
|
+
# @macro rResponse
|
211
|
+
#
|
212
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#get-global-application-command
|
213
|
+
# Discord documentation "Get Global Application Command"
|
214
|
+
def get_global_application_command(application_id, command_id)
|
215
|
+
json_request(:get, discord("/applications/#{application_id}/commands/#{command_id}"))
|
216
|
+
end
|
150
217
|
|
151
|
-
|
152
|
-
|
153
|
-
|
218
|
+
##
|
219
|
+
# @param application_id [#to_s] Application ID
|
220
|
+
# @param command_id [#to_s] Command ID
|
221
|
+
# @macro pBody
|
222
|
+
# @macro rResponse
|
223
|
+
#
|
224
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
|
225
|
+
# Discord documentation "Edit Global Application Command"
|
226
|
+
def edit_global_application_command(application_id, command_id, body)
|
227
|
+
json_request(:patch, discord("/applications/#{application_id}/commands/#{command_id}"), body:)
|
228
|
+
end
|
154
229
|
|
155
|
-
|
156
|
-
|
157
|
-
|
230
|
+
##
|
231
|
+
# @param application_id [#to_s] Application ID
|
232
|
+
# @param command_id [#to_s] Command ID
|
233
|
+
# @macro rResponse
|
234
|
+
#
|
235
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command
|
236
|
+
# Discord documentation "Delete Global Application Command"
|
237
|
+
def delete_global_application_command(application_id, command_id)
|
238
|
+
json_request(:delete, discord("/applications/#{application_id}/commands/#{command_id}"))
|
239
|
+
end
|
158
240
|
|
159
|
-
|
160
|
-
|
161
|
-
|
241
|
+
##
|
242
|
+
# @param application_id [#to_s] Application ID
|
243
|
+
# @macro pBody
|
244
|
+
# @macro rResponse
|
245
|
+
#
|
246
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands
|
247
|
+
# Discord documentation "Bulk Overwrite Global Application Commands"
|
248
|
+
def bulk_overwrite_global_application_commands(application_id, body)
|
249
|
+
json_request(:put, discord("/applications/#{application_id}/commands"), body:)
|
250
|
+
end
|
162
251
|
|
163
|
-
|
164
|
-
|
165
|
-
|
252
|
+
##
|
253
|
+
# @param application_id [#to_s] Application ID
|
254
|
+
# @param guild_id [#to_s] Guild ID
|
255
|
+
# @macro pQuery
|
256
|
+
# @macro rResponse
|
257
|
+
#
|
258
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
|
259
|
+
# Discord documentation "Get Guild Application Commands"
|
260
|
+
def get_guild_application_commands(application_id, guild_id, query = {})
|
261
|
+
json_request(:get, discord("/applications/#{application_id}/guilds/#{guild_id}/commands"), query:)
|
262
|
+
end
|
166
263
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
264
|
+
##
|
265
|
+
# @param application_id [#to_s] Application ID
|
266
|
+
# @param guild_id [#to_s] Guild ID
|
267
|
+
# @macro pBody
|
268
|
+
# @macro rResponse
|
269
|
+
#
|
270
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
|
271
|
+
# Discord documentation "Create Guild Application Command"
|
272
|
+
def create_guild_application_command(application_id, guild_id, body)
|
273
|
+
json_request(:post, discord("/applications/#{application_id}/guilds/#{guild_id}/commands"), body:)
|
274
|
+
end
|
275
|
+
|
276
|
+
##
|
277
|
+
# @param application_id [#to_s] Application ID
|
278
|
+
# @param guild_id [#to_s] Guild ID
|
279
|
+
# @param command_id [#to_s] Command ID
|
280
|
+
# @macro rResponse
|
281
|
+
#
|
282
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command
|
283
|
+
# Discord documentation "Get Guild Application Command"
|
284
|
+
def get_guild_application_command(application_id, guild_id, command_id)
|
285
|
+
json_request(:get, discord("/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}"))
|
286
|
+
end
|
287
|
+
|
288
|
+
##
|
289
|
+
# @param application_id [#to_s] Application ID
|
290
|
+
# @param guild_id [#to_s] Guild ID
|
291
|
+
# @param command_id [#to_s] Command ID
|
292
|
+
# @macro pBody
|
293
|
+
# @macro rResponse
|
294
|
+
#
|
295
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
|
296
|
+
# Discord documentation "Edit Guild Application Command"
|
297
|
+
def edit_guild_application_command(application_id, guild_id, command_id, body)
|
298
|
+
json_request(:patch, discord("/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}"), body:)
|
172
299
|
end
|
173
300
|
|
174
301
|
##
|
175
|
-
#
|
302
|
+
# @param application_id [#to_s] Application ID
|
303
|
+
# @param guild_id [#to_s] Guild ID
|
304
|
+
# @param command_id [#to_s] Command ID
|
305
|
+
# @macro rResponse
|
176
306
|
#
|
177
|
-
# @
|
307
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command
|
308
|
+
# Discord documentation "Delete Guild Application Command"
|
309
|
+
def delete_guild_application_command(application_id, guild_id, command_id)
|
310
|
+
json_request(:delete, discord("/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}"))
|
311
|
+
end
|
312
|
+
|
313
|
+
##
|
314
|
+
# @param application_id [#to_s] Application ID
|
315
|
+
# @param guild_id [#to_s] Guild ID
|
316
|
+
# @macro pBody
|
317
|
+
# @macro rResponse
|
318
|
+
#
|
319
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
|
320
|
+
# Discord documentation "Bulk Overwrite Guild Application Commands"
|
321
|
+
def bulk_overwrite_guild_application_commands(application_id, guild_id, body)
|
322
|
+
json_request(:put, discord("/applications/#{application_id}/guilds/#{guild_id}/commands"), body:)
|
323
|
+
end
|
324
|
+
|
325
|
+
##
|
326
|
+
# @param application_id [#to_s] Application ID
|
327
|
+
# @param guild_id [#to_s] Guild ID
|
328
|
+
# @macro rResponse
|
178
329
|
#
|
179
|
-
# @
|
330
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions
|
331
|
+
# Discord documentation "Get Guild Application Command Permissions"
|
332
|
+
def get_guild_application_command_permissions(application_id, guild_id)
|
333
|
+
json_request(:get, discord("/applications/#{application_id}/guilds/#{guild_id}/commands/permissions"))
|
334
|
+
end
|
335
|
+
|
336
|
+
##
|
337
|
+
# @param application_id [#to_s] Application ID
|
338
|
+
# @param guild_id [#to_s] Guild ID
|
339
|
+
# @param command_id [#to_s] Command ID
|
340
|
+
# @macro rResponse
|
180
341
|
#
|
181
|
-
# @
|
342
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions
|
343
|
+
# Discord documentation "Get Application Command Permissions"
|
344
|
+
def get_application_command_permissions(application_id, guild_id, command_id)
|
345
|
+
json_request(:get, discord("/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions"))
|
346
|
+
end
|
347
|
+
|
348
|
+
##
|
349
|
+
# @param application_id [#to_s] Application ID
|
350
|
+
# @param guild_id [#to_s] Guild ID
|
351
|
+
# @param command_id [#to_s] Command ID
|
352
|
+
# @macro pBody
|
353
|
+
# @macro rResponse
|
182
354
|
#
|
183
|
-
# @
|
184
|
-
#
|
185
|
-
|
186
|
-
|
187
|
-
# client["not.a.valid.key"]
|
188
|
-
# # => key not found "not.a.valid.key" (LibDiscord::KeyError)
|
189
|
-
def [](resource)
|
190
|
-
@container[resource]
|
191
|
-
rescue Dry::Container::KeyError => e
|
192
|
-
raise KeyError.new(e.message)
|
355
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions
|
356
|
+
# Discord documentation "Edit Application Command Permissions"
|
357
|
+
def edit_application_command_permissions(application_id, guild_id, command_id, body)
|
358
|
+
json_request(:put, discord("/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions"), body:)
|
193
359
|
end
|
194
360
|
|
195
361
|
##
|
196
|
-
#
|
362
|
+
# @deprecated This endpoint has been disabled with
|
363
|
+
# {https://discord.com/developers/docs/change-log#updated-command-permissions
|
364
|
+
# updates to command permissions (Permissions v2)}. Instead, you can
|
365
|
+
# {#edit_application_command_permissions edit each application command
|
366
|
+
# permissions} (though you should be careful to handle any potential
|
367
|
+
# {https://discord.com/developers/docs/topics/rate-limits rate limits}).
|
197
368
|
#
|
198
|
-
# @
|
369
|
+
# @param application_id [#to_s] Application ID
|
370
|
+
# @param guild_id [#to_s] Guild ID
|
371
|
+
# @macro pBody
|
372
|
+
# @macro rResponse
|
199
373
|
#
|
200
|
-
# @
|
201
|
-
#
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
374
|
+
# @see https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions
|
375
|
+
# Discord documentation "Batch Edit Application Command Permissions"
|
376
|
+
def batch_edit_application_command_permissions(application_id, guild_id, body)
|
377
|
+
json_request(:put, discord("/applications/#{application_id}/guilds/#{guild_id}/commands/permissions"), body:)
|
378
|
+
end
|
379
|
+
|
380
|
+
### }}} Application Command
|
381
|
+
|
382
|
+
### Gateway {{{
|
383
|
+
|
384
|
+
##
|
385
|
+
# @macro rResponse
|
386
|
+
#
|
387
|
+
# @see https://discord.com/developers/docs/events/gateway#get-gateway
|
388
|
+
# Discord documentation "Get Gateway"
|
389
|
+
def get_gateway
|
390
|
+
json_request(:get, discord("/gateway"))
|
391
|
+
end
|
392
|
+
|
393
|
+
##
|
394
|
+
# @macro rResponse
|
395
|
+
#
|
396
|
+
# @see https://discord.com/developers/docs/events/gateway#get-gateway-bot
|
397
|
+
# Discord documentation "Get Gateway Bot"
|
398
|
+
def get_gateway_bot
|
399
|
+
json_request(:get, discord("/gateway/bot"))
|
400
|
+
end
|
401
|
+
|
402
|
+
### }}} Gateway
|
403
|
+
|
404
|
+
### Application Role Connection Metadata {{{
|
405
|
+
|
406
|
+
##
|
407
|
+
# @param application_id [#to_s] Application ID
|
408
|
+
# @macro rResponse
|
409
|
+
#
|
410
|
+
# @see https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records
|
411
|
+
# Discord documentation "Get Application Role Connection Metadata
|
412
|
+
# Records"
|
413
|
+
def get_application_role_connection_metadata_records(application_id)
|
414
|
+
json_request(:get, discord("/applications/#{application_id}/role-connections/metadata"))
|
415
|
+
end
|
416
|
+
|
417
|
+
##
|
418
|
+
# @param application_id [#to_s] Application ID
|
419
|
+
# @macro pBody
|
420
|
+
# @macro rResponse
|
421
|
+
#
|
422
|
+
# @see https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records
|
423
|
+
# Discord documentation "Update Application Role Connection Metadata
|
424
|
+
# Records"
|
425
|
+
def update_application_role_connection_metadata_records(application_id, body)
|
426
|
+
json_request(:put, discord("/applications/#{application_id}/role-connections/metadata"), body:)
|
427
|
+
end
|
428
|
+
|
429
|
+
### }}} Application Role Connection Metadata
|
430
|
+
|
431
|
+
### Application {{{
|
432
|
+
|
433
|
+
##
|
434
|
+
# @macro rResponse
|
435
|
+
#
|
436
|
+
# @see https://discord.com/developers/docs/resources/application#get-current-application
|
437
|
+
# Discord documentation "Get Current Application"
|
438
|
+
def get_current_application
|
439
|
+
json_request(:get, discord("/applications/@me"))
|
440
|
+
end
|
441
|
+
|
442
|
+
##
|
443
|
+
# @macro pBody
|
444
|
+
# @macro rResponse
|
445
|
+
#
|
446
|
+
# @see https://discord.com/developers/docs/resources/application#edit-current-application
|
447
|
+
# Discord documentation "Edit Current Application"
|
448
|
+
def edit_current_application(body)
|
449
|
+
json_request(:patch, discord("/applications/@me"), body:)
|
450
|
+
end
|
451
|
+
|
452
|
+
##
|
453
|
+
# @param application_id [#to_s] Application ID
|
454
|
+
# @param instance_id [#to_s] Activity Instance ID
|
455
|
+
# @macro rResponse
|
456
|
+
#
|
457
|
+
# @see https://discord.com/developers/docs/resources/application#get-application-activity-instance
|
458
|
+
# Discord documentation "Get Application Activity Instance"
|
459
|
+
def get_application_activity_instance(application_id, instance_id)
|
460
|
+
json_request(:get, discord("/applications/#{application_id}/activity-instances/#{instance_id}"))
|
461
|
+
end
|
462
|
+
|
463
|
+
### }}} Application
|
464
|
+
|
465
|
+
### Audit Log {{{
|
466
|
+
|
467
|
+
##
|
468
|
+
# @param guild_id [#to_s] Guild ID
|
469
|
+
# @macro pQuery
|
470
|
+
# @macro rResponse
|
471
|
+
#
|
472
|
+
# @see https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
|
473
|
+
# Discord documentation "Get Guild Audit Log"
|
474
|
+
def get_guild_audit_log(guild_id, query = {})
|
475
|
+
json_request(:get, discord("/guilds/#{guild_id}/audit-logs"), query:)
|
476
|
+
end
|
477
|
+
|
478
|
+
### }}} Audit Log
|
479
|
+
|
480
|
+
### Auto Moderation {{{
|
481
|
+
|
482
|
+
##
|
483
|
+
# @param guild_id [#to_s] Guild ID
|
484
|
+
# @macro rResponse
|
485
|
+
#
|
486
|
+
# @see https://discord.com/developers/docs/resources/auto-moderation#list-auto-moderation-rules-for-guild
|
487
|
+
# Discord documentation "List Auto Moderation Rules for Guild"
|
488
|
+
def list_auto_moderation_rules_for_guild(guild_id)
|
489
|
+
json_request(:get, discord("/guilds/#{guild_id}/auto-moderation/rules"))
|
490
|
+
end
|
491
|
+
|
492
|
+
##
|
493
|
+
# @param guild_id [#to_s] Guild ID
|
494
|
+
# @param auto_moderation_rule_id [#to_s] Auto Moderation Rule ID
|
495
|
+
# @macro rResponse
|
496
|
+
#
|
497
|
+
# @see https://discord.com/developers/docs/resources/auto-moderation#get-auto-moderation-rule
|
498
|
+
# Discord documentation "Get Auto Moderation Rule"
|
499
|
+
def get_auto_moderation_rule(guild_id, auto_moderation_rule_id)
|
500
|
+
json_request(:get, discord("/guilds/#{guild_id}/auto-moderation/rules/#{auto_moderation_rule_id}"))
|
501
|
+
end
|
502
|
+
|
503
|
+
##
|
504
|
+
# @param guild_id [#to_s] Guild ID
|
505
|
+
# @macro pBody
|
506
|
+
# @macro rResponse
|
507
|
+
#
|
508
|
+
# @see https://discord.com/developers/docs/resources/auto-moderation#create-auto-moderation-rule
|
509
|
+
# Discord documentation "Create Auto Moderation Rule"
|
510
|
+
def create_auto_moderation_rule(guild_id, body)
|
511
|
+
json_request(:post, discord("/guilds/#{guild_id}/auto-moderation/rules"), body:)
|
512
|
+
end
|
513
|
+
|
514
|
+
##
|
515
|
+
# @param guild_id [#to_s] Guild ID
|
516
|
+
# @param auto_moderation_rule_id [#to_s] Auto Moderation Rule ID
|
517
|
+
# @macro pBody
|
518
|
+
# @macro rResponse
|
519
|
+
#
|
520
|
+
# @see https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule
|
521
|
+
# Discord documentation "Modify Auto Moderation Rule"
|
522
|
+
def modify_auto_moderation_rule(guild_id, auto_moderation_rule_id, body)
|
523
|
+
json_request(:patch, discord("/guilds/#{guild_id}/auto-moderation/rules/#{auto_moderation_rule_id}"), body:)
|
524
|
+
end
|
525
|
+
|
526
|
+
##
|
527
|
+
# @param guild_id [#to_s] Guild ID
|
528
|
+
# @param auto_moderation_rule_id [#to_s] Auto Moderation Rule ID
|
529
|
+
# @macro rResponse
|
530
|
+
#
|
531
|
+
# @see https://discord.com/developers/docs/resources/auto-moderation#delete-auto-moderation-rule
|
532
|
+
# Discord documentation "Delete Auto Moderation Rule"
|
533
|
+
def delete_auto_moderation_rule(guild_id, auto_moderation_rule_id)
|
534
|
+
json_request(:delete, discord("/guilds/#{guild_id}/auto-moderation/rules/#{auto_moderation_rule_id}"))
|
535
|
+
end
|
536
|
+
|
537
|
+
### }}} Auto Moderation
|
538
|
+
|
539
|
+
### Channel {{{
|
540
|
+
|
541
|
+
##
|
542
|
+
# @param channel_id [#to_s] Channel ID
|
543
|
+
# @macro rResponse
|
544
|
+
#
|
545
|
+
# @see https://discord.com/developers/docs/resources/channel#get-channel
|
546
|
+
# Discord documentation "Get Channel"
|
547
|
+
def get_channel(channel_id)
|
548
|
+
json_request(:get, discord("/channels/#{channel_id}"))
|
549
|
+
end
|
550
|
+
|
551
|
+
##
|
552
|
+
# @param channel_id [#to_s] Channel ID
|
553
|
+
# @macro pBody
|
554
|
+
# @macro rResponse
|
555
|
+
#
|
556
|
+
# @see https://discord.com/developers/docs/resources/channel#modify-channel
|
557
|
+
# Discord documentation "Modify Channel"
|
558
|
+
def modify_channel(channel_id, body)
|
559
|
+
json_request(:patch, discord("/channels/#{channel_id}"), body:)
|
560
|
+
end
|
561
|
+
|
562
|
+
##
|
563
|
+
# @param channel_id [#to_s] Channel ID
|
564
|
+
# @macro rResponse
|
565
|
+
#
|
566
|
+
# @see https://discord.com/developers/docs/resources/channel#deleteclose-channel
|
567
|
+
# Discord documentation "Delete/Close Channel"
|
568
|
+
def delete_channel(channel_id)
|
569
|
+
json_request(:delete, discord("/channels/#{channel_id}"))
|
570
|
+
end
|
571
|
+
|
572
|
+
alias_method :close_channel, :delete_channel
|
573
|
+
|
574
|
+
##
|
575
|
+
# @param channel_id [#to_s] Channel ID
|
576
|
+
# @param overwrite_id [#to_s] Overwrite ID
|
577
|
+
# @macro pBody
|
578
|
+
#
|
579
|
+
# @macro rResponse
|
580
|
+
#
|
581
|
+
# @see https://discord.com/developers/docs/resources/channel#edit-channel-permissions
|
582
|
+
# Discord documentation "Edit Channel Permissions"
|
583
|
+
def edit_channel_permissions(channel_id, overwrite_id, body)
|
584
|
+
json_request(:put, discord("/channels/#{channel_id}/permissions/#{overwrite_id}"), body:)
|
585
|
+
end
|
586
|
+
|
587
|
+
##
|
588
|
+
# @param channel_id [#to_s] Channel ID
|
589
|
+
# @macro rResponse
|
590
|
+
#
|
591
|
+
# @see https://discord.com/developers/docs/resources/channel#get-channel-invites
|
592
|
+
# Discord documentation "Get Channel Invites"
|
593
|
+
def get_channel_invites(channel_id)
|
594
|
+
json_request(:get, discord("/channels/#{channel_id}/invites"))
|
595
|
+
end
|
596
|
+
|
597
|
+
##
|
598
|
+
# @param channel_id [#to_s] Channel ID
|
599
|
+
# @macro pBody
|
600
|
+
# @macro rResponse
|
601
|
+
#
|
602
|
+
# @see https://discord.com/developers/docs/resources/channel#create-channel-invite
|
603
|
+
# Discord documentation "Create Channel Invite"
|
604
|
+
def create_channel_invite(channel_id, body)
|
605
|
+
json_request(:post, discord("/channels/#{channel_id}/invites"), body:)
|
606
|
+
end
|
607
|
+
|
608
|
+
##
|
609
|
+
# @param channel_id [#to_s] Channel ID
|
610
|
+
# @param overwrite_id [#to_s] Overwrite ID
|
611
|
+
# @macro rResponse
|
612
|
+
#
|
613
|
+
# @see https://discord.com/developers/docs/resources/channel#delete-channel-permission
|
614
|
+
# Discord documentation "Delete Channel Permission"
|
615
|
+
def delete_channel_permission(channel_id, overwrite_id)
|
616
|
+
json_request(:delete, discord("/channels/#{channel_id}/permissions/#{overwrite_id}"))
|
617
|
+
end
|
618
|
+
|
619
|
+
##
|
620
|
+
# @param channel_id [#to_s] Channel ID
|
621
|
+
# @macro pBody
|
622
|
+
# @macro rResponse
|
623
|
+
#
|
624
|
+
# @see https://discord.com/developers/docs/resources/channel#follow-announcement-channel
|
625
|
+
# Discord documentation "Follow Announcement Channel"
|
626
|
+
def follow_announcement_channel(channel_id, body)
|
627
|
+
json_request(:post, discord("/channels/#{channel_id}/followers"), body:)
|
628
|
+
end
|
629
|
+
|
630
|
+
##
|
631
|
+
# @param channel_id [#to_s] Channel ID
|
632
|
+
# @macro rResponse
|
633
|
+
#
|
634
|
+
# @see https://discord.com/developers/docs/resources/channel#trigger-typing-indicator
|
635
|
+
# Discord documentation "Trigger Typing Indicator"
|
636
|
+
def trigger_typing_indicator(channel_id)
|
637
|
+
json_request(:post, discord("/channels/#{channel_id}/typing"))
|
638
|
+
end
|
639
|
+
|
640
|
+
##
|
641
|
+
# @param channel_id [#to_s] Channel ID
|
642
|
+
# @macro rResponse
|
643
|
+
#
|
644
|
+
# @see https://discord.com/developers/docs/resources/channel#get-pinned-messages
|
645
|
+
# Discord documentation "Get Pinned Messages"
|
646
|
+
def get_pinned_messages(channel_id)
|
647
|
+
json_request(:get, discord("/channels/#{channel_id}/pins"))
|
648
|
+
end
|
649
|
+
|
650
|
+
##
|
651
|
+
# @param channel_id [#to_s] Channel ID
|
652
|
+
# @param message_id [#to_s] Message ID
|
653
|
+
# @macro rResponse
|
654
|
+
#
|
655
|
+
# @see https://discord.com/developers/docs/resources/channel#pin-message
|
656
|
+
# Discord documentation "Pin Message"
|
657
|
+
def pin_message(channel_id, message_id)
|
658
|
+
json_request(:put, discord("/channels/#{channel_id}/pins/#{message_id}"))
|
659
|
+
end
|
660
|
+
|
661
|
+
##
|
662
|
+
# @param channel_id [#to_s] Channel ID
|
663
|
+
# @param message_id [#to_s] Message ID
|
664
|
+
# @macro rResponse
|
665
|
+
#
|
666
|
+
# @see https://discord.com/developers/docs/resources/channel#unpin-message
|
667
|
+
# Discord documentation "Unpin Message"
|
668
|
+
def unpin_message(channel_id, message_id)
|
669
|
+
json_request(:delete, discord("/channels/#{channel_id}/pins/#{message_id}"))
|
670
|
+
end
|
671
|
+
|
672
|
+
##
|
673
|
+
# @param channel_id [#to_s] Channel ID
|
674
|
+
# @param user_id [#to_s] User ID
|
675
|
+
# @macro pBody
|
676
|
+
# @macro rResponse
|
677
|
+
#
|
678
|
+
# @see https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
|
679
|
+
# Discord documentation "Group DM Add Recipient"
|
680
|
+
def group_dm_add_recipient(channel_id, user_id, body)
|
681
|
+
json_request(:put, discord("/channels/#{channel_id}/recipients/#{user_id}"), body:)
|
682
|
+
end
|
683
|
+
|
684
|
+
##
|
685
|
+
# @param channel_id [#to_s] Channel ID
|
686
|
+
# @param user_id [#to_s] User ID
|
687
|
+
# @macro rResponse
|
688
|
+
#
|
689
|
+
# @see https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient
|
690
|
+
# Discord documentation "Group DM Remove Recipient"
|
691
|
+
def group_dm_remove_recipient(channel_id, user_id)
|
692
|
+
json_request(:delete, discord("/channels/#{channel_id}/recipients/#{user_id}"))
|
693
|
+
end
|
694
|
+
|
695
|
+
##
|
696
|
+
# @param channel_id [#to_s] Channel ID
|
697
|
+
# @param message_id [#to_s] Message ID
|
698
|
+
# @macro pBody
|
699
|
+
# @macro rResponse
|
700
|
+
#
|
701
|
+
# @see https://discord.com/developers/docs/resources/channel#start-thread-from-message
|
702
|
+
# Discord documentation "Start Thread from Message"
|
703
|
+
def start_thread_from_message(channel_id, message_id, body)
|
704
|
+
json_request(:post, discord("/channels/#{channel_id}/messages/#{message_id}/threads"), body:)
|
705
|
+
end
|
706
|
+
|
707
|
+
##
|
708
|
+
# @param channel_id [#to_s] Channel ID
|
709
|
+
# @macro pBody
|
710
|
+
# @macro rResponse
|
711
|
+
#
|
712
|
+
# @see https://discord.com/developers/docs/resources/channel#start-thread-without-message
|
713
|
+
# Discord documentation "Start Thread without Message"
|
714
|
+
def start_thread_without_message(channel_id, body)
|
715
|
+
json_request(:post, discord("/channels/#{channel_id}/threads"), body:)
|
716
|
+
end
|
717
|
+
|
718
|
+
##
|
719
|
+
# @param channel_id [#to_s] Channel ID
|
720
|
+
# @macro pBody
|
721
|
+
# @macro rResponse
|
722
|
+
#
|
723
|
+
# @see https://discord.com/developers/docs/resources/channel#start-thread-in-forum-or-media-channel
|
724
|
+
# Discord documentation "Start Thread in Forum or Media Channel"
|
725
|
+
def start_thread_in_forum_or_media_channel(channel_id, body)
|
726
|
+
json_request(:post, discord("/channels/#{channel_id}/threads"), body:)
|
727
|
+
end
|
728
|
+
|
729
|
+
##
|
730
|
+
# @param channel_id [#to_s] Channel ID
|
731
|
+
# @macro rResponse
|
732
|
+
#
|
733
|
+
# @see https://discord.com/developers/docs/resources/channel#join-thread
|
734
|
+
# Discord documentation "Join Thread"
|
735
|
+
def join_thread(channel_id)
|
736
|
+
json_request(:put, discord("/channels/#{channel_id}/thread-members/@me"))
|
737
|
+
end
|
738
|
+
|
739
|
+
##
|
740
|
+
# @param channel_id [#to_s] Channel ID
|
741
|
+
# @param user_id [#to_s] User ID
|
742
|
+
# @macro rResponse
|
743
|
+
#
|
744
|
+
# @see https://discord.com/developers/docs/resources/channel#add-thread-member
|
745
|
+
# Discord documentation "Add Thread Member"
|
746
|
+
def add_thread_member(channel_id, user_id)
|
747
|
+
json_request(:put, discord("/channels/#{channel_id}/thread-members/#{user_id}"))
|
748
|
+
end
|
749
|
+
|
750
|
+
##
|
751
|
+
# @param channel_id [#to_s] Channel ID
|
752
|
+
# @macro rResponse
|
753
|
+
#
|
754
|
+
# @see https://discord.com/developers/docs/resources/channel#leave-thread
|
755
|
+
# Discord documentation "Leave Thread"
|
756
|
+
def leave_thread(channel_id)
|
757
|
+
json_request(:delete, discord("/channels/#{channel_id}/thread-members/@me"))
|
758
|
+
end
|
759
|
+
|
760
|
+
##
|
761
|
+
# @param channel_id [#to_s] Channel ID
|
762
|
+
# @param user_id [#to_s] User ID
|
763
|
+
# @macro rResponse
|
764
|
+
#
|
765
|
+
# @see https://discord.com/developers/docs/resources/channel#remove-thread-member
|
766
|
+
# Discord documentation "Remove Thread Member"
|
767
|
+
def remove_thread_member(channel_id, user_id)
|
768
|
+
json_request(:delete, discord("/channels/#{channel_id}/thread-members/#{user_id}"))
|
769
|
+
end
|
770
|
+
|
771
|
+
##
|
772
|
+
# @param channel_id [#to_s] Channel ID
|
773
|
+
# @param user_id [#to_s] User ID
|
774
|
+
# @macro pQuery
|
775
|
+
# @macro rResponse
|
776
|
+
#
|
777
|
+
# @see https://discord.com/developers/docs/resources/channel#get-thread-member
|
778
|
+
# Discord documentation "Get Thread Member"
|
779
|
+
def get_thread_member(channel_id, user_id, query = {})
|
780
|
+
json_request(:get, discord("/channels/#{channel_id}/thread-members/#{user_id}"), query:)
|
781
|
+
end
|
782
|
+
|
783
|
+
##
|
784
|
+
# @param channel_id [#to_s] Channel ID
|
785
|
+
# @macro pQuery
|
786
|
+
# @macro rResponse
|
787
|
+
#
|
788
|
+
# @see https://discord.com/developers/docs/resources/channel#list-thread-members
|
789
|
+
# Discord documentation "List Thread Members"
|
790
|
+
def list_thread_members(channel_id, query = {})
|
791
|
+
json_request(:get, discord("/channels/#{channel_id}/thread-members"), query:)
|
792
|
+
end
|
793
|
+
|
794
|
+
##
|
795
|
+
# @param channel_id [#to_s] Channel ID
|
796
|
+
# @macro pQuery
|
797
|
+
#
|
798
|
+
# @macro rResponse
|
799
|
+
#
|
800
|
+
# @see https://discord.com/developers/docs/resources/channel#list-public-archived-threads
|
801
|
+
# Discord documentation "List Public Archived Threads"
|
802
|
+
def list_public_archived_threads(channel_id, query = {})
|
803
|
+
json_request(:get, discord("/channels/#{channel_id}/threads/archived/public"), query:)
|
804
|
+
end
|
805
|
+
|
806
|
+
##
|
807
|
+
# @param channel_id [#to_s] Channel ID
|
808
|
+
# @macro pQuery
|
809
|
+
# @macro rResponse
|
810
|
+
#
|
811
|
+
# @see https://discord.com/developers/docs/resources/channel#list-private-archived-threads
|
812
|
+
# Discord documentation "List Private Archived Threads"
|
813
|
+
def list_private_archived_threads(channel_id, query = {})
|
814
|
+
json_request(:get, discord("/channels/#{channel_id}/threads/archived/private"), query:)
|
815
|
+
end
|
816
|
+
|
817
|
+
##
|
818
|
+
# @param channel_id [#to_s] Channel ID
|
819
|
+
# @macro pQuery
|
820
|
+
# @macro rResponse
|
821
|
+
#
|
822
|
+
# @see https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads
|
823
|
+
# Discord documentation "List Joined Private Archived Threads"
|
824
|
+
def list_joined_private_archived_threads(channel_id, query = {})
|
825
|
+
json_request(:get, discord("/channels/#{channel_id}/users/@me/threads/archived/private"), query:)
|
826
|
+
end
|
827
|
+
|
828
|
+
### }}} Channel
|
829
|
+
|
830
|
+
### Emoji {{{
|
831
|
+
|
832
|
+
##
|
833
|
+
# @param guild_id [#to_s] Guild ID
|
834
|
+
# @macro rResponse
|
835
|
+
#
|
836
|
+
# @see https://discord.com/developers/docs/resources/emoji#list-guild-emojis
|
837
|
+
# Discord documentation "List Guild Emojis"
|
838
|
+
def list_guild_emojis(guild_id)
|
839
|
+
json_request(:get, discord("/guilds/#{guild_id}/emojis"))
|
840
|
+
end
|
841
|
+
|
842
|
+
##
|
843
|
+
# @param guild_id [#to_s] Guild ID
|
844
|
+
# @param emoji_id [#to_s] Emoji ID
|
845
|
+
# @macro rResponse
|
846
|
+
#
|
847
|
+
# @see https://discord.com/developers/docs/resources/emoji#get-guild-emoji
|
848
|
+
# Discord documentation "Get Guild Emoji"
|
849
|
+
def get_guild_emoji(guild_id, emoji_id)
|
850
|
+
json_request(:get, discord("/guilds/#{guild_id}/emojis/#{emoji_id}"))
|
851
|
+
end
|
852
|
+
|
853
|
+
##
|
854
|
+
# @param guild_id [#to_s] Guild ID
|
855
|
+
# @macro pBody
|
856
|
+
# @macro rResponse
|
857
|
+
#
|
858
|
+
# @see https://discord.com/developers/docs/resources/emoji#create-guild-emoji
|
859
|
+
# Discord documentation "Create Guild Emoji"
|
860
|
+
def create_guild_emoji(guild_id, body)
|
861
|
+
json_request(:post, discord("/guilds/#{guild_id}/emojis"), body:)
|
862
|
+
end
|
863
|
+
|
864
|
+
##
|
865
|
+
# @param guild_id [#to_s] Guild ID
|
866
|
+
# @param emoji_id [#to_s] Emoji ID
|
867
|
+
# @macro pBody
|
868
|
+
# @macro rResponse
|
869
|
+
#
|
870
|
+
# @see https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
|
871
|
+
# Discord documentation "Modify Guild Emoji"
|
872
|
+
def modify_guild_emoji(guild_id, emoji_id, body)
|
873
|
+
json_request(:patch, discord("/guilds/#{guild_id}/emojis/#{emoji_id}"), body:)
|
874
|
+
end
|
875
|
+
|
876
|
+
##
|
877
|
+
# @param guild_id [#to_s] Guild ID
|
878
|
+
# @param emoji_id [#to_s] Emoji ID
|
879
|
+
# @macro rResponse
|
880
|
+
#
|
881
|
+
# @see https://discord.com/developers/docs/resources/emoji#delete-guild-emoji
|
882
|
+
# Discord documentation "Delete Guild Emoji"
|
883
|
+
def delete_guild_emoji(guild_id, emoji_id)
|
884
|
+
json_request(:delete, discord("/guilds/#{guild_id}/emojis/#{emoji_id}"))
|
885
|
+
end
|
886
|
+
|
887
|
+
##
|
888
|
+
# @param application_id [#to_s] Application ID
|
889
|
+
# @macro rResponse
|
890
|
+
#
|
891
|
+
# @see https://discord.com/developers/docs/resources/emoji#list-application-emojis
|
892
|
+
# Discord documentation "List Application Emojis"
|
893
|
+
def list_application_emojis(application_id)
|
894
|
+
json_request(:get, discord("/applications/#{application_id}/emojis"))
|
895
|
+
end
|
896
|
+
|
897
|
+
##
|
898
|
+
# @param application_id [#to_s] Application ID
|
899
|
+
# @param emoji_id [#to_s] Emoji ID
|
900
|
+
# @macro rResponse
|
901
|
+
#
|
902
|
+
# @see https://discord.com/developers/docs/resources/emoji#get-application-emoji
|
903
|
+
# Discord documentation "Get Application Emoji"
|
904
|
+
def get_application_emoji(application_id, emoji_id)
|
905
|
+
json_request(:get, discord("/applications/#{application_id}/emojis/#{emoji_id}"))
|
906
|
+
end
|
907
|
+
|
908
|
+
##
|
909
|
+
# @param application_id [#to_s] Application ID
|
910
|
+
# @macro pBody
|
911
|
+
# @macro rResponse
|
912
|
+
#
|
913
|
+
# @see https://discord.com/developers/docs/resources/emoji#create-application-emoji
|
914
|
+
# Discord documentation "Create Application Emoji"
|
915
|
+
def create_application_emoji(application_id, body)
|
916
|
+
json_request(:post, discord("/applications/#{application_id}/emojis"), body:)
|
917
|
+
end
|
918
|
+
|
919
|
+
##
|
920
|
+
# @param application_id [#to_s] Application ID
|
921
|
+
# @param emoji_id [#to_s] Emoji ID
|
922
|
+
# @macro pBody
|
923
|
+
# @macro rResponse
|
924
|
+
#
|
925
|
+
# @see https://discord.com/developers/docs/resources/emoji#modify-application-emoji
|
926
|
+
# Discord documentation "Modify Application Emoji"
|
927
|
+
def modify_application_emoji(application_id, emoji_id, body)
|
928
|
+
json_request(:patch, discord("/applications/#{application_id}/emojis/#{emoji_id}"), body:)
|
929
|
+
end
|
930
|
+
|
931
|
+
##
|
932
|
+
# @param application_id [#to_s] Application ID
|
933
|
+
# @param emoji_id [#to_s] Emoji ID
|
934
|
+
# @macro rResponse
|
935
|
+
#
|
936
|
+
# @see https://discord.com/developers/docs/resources/emoji#delete-application-emoji
|
937
|
+
# Discord documentation "Delete Application Emoji"
|
938
|
+
def delete_application_emoji(application_id, emoji_id)
|
939
|
+
json_request(:delete, discord("/applications/#{application_id}/emojis/#{emoji_id}"))
|
940
|
+
end
|
941
|
+
|
942
|
+
### }}} Emoji
|
943
|
+
|
944
|
+
### Entitlement {{{
|
945
|
+
|
946
|
+
##
|
947
|
+
# @param application_id [#to_s] Application ID
|
948
|
+
# @macro rResponse
|
949
|
+
#
|
950
|
+
# @see https://discord.com/developers/docs/resources/entitlement#list-entitlements
|
951
|
+
# Discord documentation "List Entitlements"
|
952
|
+
def list_entitlements(application_id)
|
953
|
+
json_request(:get, discord("/applications/#{application_id}/entitlements"))
|
954
|
+
end
|
955
|
+
|
956
|
+
##
|
957
|
+
# @param application_id [#to_s] Application ID
|
958
|
+
# @param entitlement_id [#to_s] Entitlement ID
|
959
|
+
# @macro rResponse
|
960
|
+
#
|
961
|
+
# @see https://discord.com/developers/docs/resources/entitlement#get-entitlement
|
962
|
+
# Discord documentation "Get Entitlement"
|
963
|
+
def get_entitlement(application_id, entitlement_id)
|
964
|
+
json_request(:get, discord("/applications/#{application_id}/entitlements/#{entitlement_id}"))
|
965
|
+
end
|
966
|
+
|
967
|
+
##
|
968
|
+
# @param application_id [#to_s] Application ID
|
969
|
+
# @param entitlement_id [#to_s] Entitlement ID
|
970
|
+
# @macro rResponse
|
971
|
+
#
|
972
|
+
# @see https://discord.com/developers/docs/resources/entitlement#consume-an-entitlement
|
973
|
+
# Discord documentation "Consume an Entitlement"
|
974
|
+
def consume_entitlement(application_id, entitlement_id)
|
975
|
+
json_request(:post, discord("/applications/#{application_id}/entitlements/#{entitlement_id}/consume"))
|
976
|
+
end
|
977
|
+
|
978
|
+
##
|
979
|
+
# @param application_id [#to_s] Application ID
|
980
|
+
# @macro rResponse
|
981
|
+
#
|
982
|
+
# @see https://discord.com/developers/docs/resources/entitlement#create-test-entitlement
|
983
|
+
# Discord documentation "Create Test Entitlement"
|
984
|
+
def create_test_entitlement(application_id, body)
|
985
|
+
json_request(:post, discord("/applications/#{application_id}/entitlements"), body:)
|
986
|
+
end
|
987
|
+
|
988
|
+
##
|
989
|
+
# @param application_id [#to_s] Application ID
|
990
|
+
# @param entitlement_id [#to_s] Entitlement ID
|
991
|
+
# @macro rResponse
|
992
|
+
#
|
993
|
+
# @see https://discord.com/developers/docs/resources/entitlement#delete-test-entitlement
|
994
|
+
# Discord documentation "Delete Test Entitlement"
|
995
|
+
def delete_test_entitlement(application_id, entitlement_id)
|
996
|
+
json_request(:delete, discord("/applications/#{application_id}/entitlements/#{entitlement_id}"))
|
997
|
+
end
|
998
|
+
|
999
|
+
### }}} Entitlement
|
1000
|
+
|
1001
|
+
### Guild Scheduled Event {{{
|
1002
|
+
|
1003
|
+
##
|
1004
|
+
# @param guild_id [#to_s] Guild ID
|
1005
|
+
# @macro pQuery
|
1006
|
+
# @macro rResponse
|
1007
|
+
#
|
1008
|
+
# @see https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild
|
1009
|
+
# Discord documentation "List Scheduled Events for Guild"
|
1010
|
+
def list_scheduled_events_for_guild(guild_id, query = {})
|
1011
|
+
json_request(:get, discord("/guilds/#{guild_id}/scheduled-events"), query:)
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
##
|
1015
|
+
# @param guild_id [#to_s] Guild ID
|
1016
|
+
# @macro pBody
|
1017
|
+
# @macro rResponse
|
1018
|
+
#
|
1019
|
+
# @see https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
|
1020
|
+
# Discord documentation "Create Guild Scheduled Event"
|
1021
|
+
def create_guild_scheduled_event(guild_id, body)
|
1022
|
+
json_request(:post, discord("/guilds/#{guild_id}/scheduled-events"), body:)
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
##
|
1026
|
+
# @param guild_id [#to_s] Guild ID
|
1027
|
+
# @param guild_scheduled_event_id [#to_s] Guild Scheduled Event ID
|
1028
|
+
# @macro pQuery
|
1029
|
+
# @macro rResponse
|
1030
|
+
#
|
1031
|
+
# @see https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event
|
1032
|
+
# Discord documentation "Get Guild Scheduled Event"
|
1033
|
+
def get_guild_scheduled_event(guild_id, guild_scheduled_event_id, query = {})
|
1034
|
+
json_request(:get, discord("/guilds/#{guild_id}/scheduled-events/#{guild_scheduled_event_id}"), query:)
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
##
|
1038
|
+
# @param guild_id [#to_s] Guild ID
|
1039
|
+
# @param guild_scheduled_event_id [#to_s] Guild Scheduled Event ID
|
1040
|
+
# @macro pBody
|
1041
|
+
# @macro rResponse
|
1042
|
+
#
|
1043
|
+
# @see https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
|
1044
|
+
# Discord documentation "Modify Guild Scheduled Event"
|
1045
|
+
def modify_guild_scheduled_event(guild_id, guild_scheduled_event_id, body)
|
1046
|
+
json_request(:patch, discord("/guilds/#{guild_id}/scheduled-events/#{guild_scheduled_event_id}"), body:)
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
##
|
1050
|
+
# @param guild_id [#to_s] Guild ID
|
1051
|
+
# @param guild_scheduled_event_id [#to_s] Guild Scheduled Event ID
|
1052
|
+
# @macro rResponse
|
1053
|
+
#
|
1054
|
+
# @see https://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-event
|
1055
|
+
# Discord documentation "Delete Guild Scheduled Event"
|
1056
|
+
def delete_guild_scheduled_event(guild_id, guild_scheduled_event_id)
|
1057
|
+
json_request(:delete, discord("/guilds/#{guild_id}/scheduled-events/#{guild_scheduled_event_id}"))
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
##
|
1061
|
+
# @param guild_id [#to_s] Guild ID
|
1062
|
+
# @param guild_scheduled_event_id [#to_s] Guild Scheduled Event ID
|
1063
|
+
# @macro pQuery
|
1064
|
+
# @macro rResponse
|
1065
|
+
#
|
1066
|
+
# @see https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users
|
1067
|
+
# Discord documentation "Get Guild Scheduled Event Users"
|
1068
|
+
def get_guild_scheduled_event_users(guild_id, guild_scheduled_event_id, query = {})
|
1069
|
+
json_request(:get, discord("/guilds/#{guild_id}/scheduled-events/#{guild_scheduled_event_id}/users"), query:)
|
1070
|
+
end
|
1071
|
+
|
1072
|
+
### }}} Guild Scheduled Event
|
1073
|
+
|
1074
|
+
### Guild Template {{{
|
1075
|
+
|
1076
|
+
##
|
1077
|
+
# @param template_code [#to_s] Template Code
|
1078
|
+
# @macro rResponse
|
1079
|
+
#
|
1080
|
+
# @see https://discord.com/developers/docs/resources/guild-template#get-guild-template
|
1081
|
+
# Discord documentation "Get Guild Template"
|
1082
|
+
def get_guild_template(template_code)
|
1083
|
+
json_request(:get, discord("/guilds/templates/#{template_code}"))
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
##
|
1087
|
+
# @param template_code [#to_s] Template Code
|
1088
|
+
# @macro pBody
|
1089
|
+
# @macro rResponse
|
1090
|
+
#
|
1091
|
+
# @see https://discord.com/developers/docs/resources/guild-template#create-guild-from-guild-template
|
1092
|
+
# Discord documentation "Create Guild from Guild Template"
|
1093
|
+
def create_guild_from_guild_template(template_code, body)
|
1094
|
+
json_request(:post, discord("/guilds/templates/#{template_code}"), body:)
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
##
|
1098
|
+
# @param guild_id [#to_s] Guild ID
|
1099
|
+
# @macro rResponse
|
1100
|
+
#
|
1101
|
+
# @see https://discord.com/developers/docs/resources/guild-template#get-guild-templates
|
1102
|
+
# Discord documentation "Get Guild Templates"
|
1103
|
+
def get_guild_templates(guild_id)
|
1104
|
+
json_request(:get, discord("/guilds/#{guild_id}/templates"))
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
##
|
1108
|
+
# @param guild_id [#to_s] Guild ID
|
1109
|
+
# @macro pBody
|
1110
|
+
# @macro rResponse
|
1111
|
+
#
|
1112
|
+
# @see https://discord.com/developers/docs/resources/guild-template#create-guild-template
|
1113
|
+
# Discord documentation "Create Guild Template"
|
1114
|
+
def create_guild_template(guild_id, body)
|
1115
|
+
json_request(:post, discord("/guilds/#{guild_id}/templates"), body:)
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
##
|
1119
|
+
# @param guild_id [#to_s] Guild ID
|
1120
|
+
# @param template_code [#to_s] Template Code
|
1121
|
+
# @macro rResponse
|
1122
|
+
#
|
1123
|
+
# @see https://discord.com/developers/docs/resources/guild-template#sync-guild-template
|
1124
|
+
# Discord documentation "Sync Guild Template"
|
1125
|
+
def sync_guild_template(guild_id, template_code)
|
1126
|
+
json_request(:put, discord("/guilds/#{guild_id}/templates/#{template_code}"))
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
##
|
1130
|
+
# @param guild_id [#to_s] Guild ID
|
1131
|
+
# @param template_code [#to_s] Template Code
|
1132
|
+
# @macro pBody
|
1133
|
+
# @macro rResponse
|
1134
|
+
#
|
1135
|
+
# @see https://discord.com/developers/docs/resources/guild-template#modify-guild-template
|
1136
|
+
# Discord documentation "Modify Guild Template"
|
1137
|
+
def modify_guild_template(guild_id, template_code, body)
|
1138
|
+
json_request(:patch, discord("/guilds/#{guild_id}/templates/#{template_code}"), body:)
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
##
|
1142
|
+
# @param guild_id [#to_s] Guild ID
|
1143
|
+
# @param template_code [#to_s] Template Code
|
1144
|
+
# @macro rResponse
|
1145
|
+
#
|
1146
|
+
# @see https://discord.com/developers/docs/resources/guild-template#delete-guild-template
|
1147
|
+
# Discord documentation "Delete Guild Template"
|
1148
|
+
def delete_guild_template(guild_id, template_code)
|
1149
|
+
json_request(:delete, discord("/guilds/#{guild_id}/templates/#{template_code}"))
|
1150
|
+
end
|
1151
|
+
|
1152
|
+
### }}} Guild Template
|
1153
|
+
|
1154
|
+
### Guild {{{
|
1155
|
+
|
1156
|
+
##
|
1157
|
+
# @macro pBody
|
1158
|
+
# @macro rResponse
|
1159
|
+
#
|
1160
|
+
# @see https://discord.com/developers/docs/resources/guild#create-guild
|
1161
|
+
# Discord documentation "Create Guild"
|
1162
|
+
def create_guild(body)
|
1163
|
+
json_request(:post, discord("/guilds"), body:)
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
##
|
1167
|
+
# @param guild_id [#to_s] Guild ID
|
1168
|
+
# @macro pQuery
|
1169
|
+
# @macro rResponse
|
1170
|
+
#
|
1171
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild
|
1172
|
+
# Discord documentation "Get Guild"
|
1173
|
+
def get_guild(guild_id, query = {})
|
1174
|
+
json_request(:get, discord("/guilds/#{guild_id}"), query:)
|
1175
|
+
end
|
1176
|
+
|
1177
|
+
##
|
1178
|
+
# @param guild_id [#to_s] Guild ID
|
1179
|
+
# @macro rResponse
|
1180
|
+
#
|
1181
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-preview
|
1182
|
+
# Discord documentation "Get Guild Preview"
|
1183
|
+
def get_guild_preview(guild_id)
|
1184
|
+
json_request(:get, discord("/guilds/#{guild_id}/preview"))
|
1185
|
+
end
|
1186
|
+
|
1187
|
+
##
|
1188
|
+
# @param guild_id [#to_s] Guild ID
|
1189
|
+
# @macro pBody
|
1190
|
+
# @macro rResponse
|
1191
|
+
#
|
1192
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild
|
1193
|
+
# Discord documentation "Modify Guild"
|
1194
|
+
def modify_guild(guild_id, body)
|
1195
|
+
json_request(:patch, discord("/guilds/#{guild_id}"), body:)
|
1196
|
+
end
|
1197
|
+
|
1198
|
+
##
|
1199
|
+
# @param guild_id [#to_s] Guild ID
|
1200
|
+
# @macro rResponse
|
1201
|
+
#
|
1202
|
+
# @see https://discord.com/developers/docs/resources/guild#delete-guild
|
1203
|
+
# Discord documentation "Delete Guild"
|
1204
|
+
def delete_guild(guild_id)
|
1205
|
+
json_request(:delete, discord("/guilds/#{guild_id}"))
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
##
|
1209
|
+
# @param guild_id [#to_s] Guild ID
|
1210
|
+
# @macro rResponse
|
1211
|
+
#
|
1212
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-channels
|
1213
|
+
# Discord documentation "Get Guild Channels"
|
1214
|
+
def get_guild_channels(guild_id)
|
1215
|
+
json_request(:get, discord("/guilds/#{guild_id}/channels"))
|
1216
|
+
end
|
1217
|
+
|
1218
|
+
##
|
1219
|
+
# @param guild_id [#to_s] Guild ID
|
1220
|
+
# @macro pBody
|
1221
|
+
# @macro rResponse
|
1222
|
+
#
|
1223
|
+
# @see https://discord.com/developers/docs/resources/guild#create-guild-channel
|
1224
|
+
# Discord documentation "Create Guild Channel"
|
1225
|
+
def create_guild_channel(guild_id, body)
|
1226
|
+
json_request(:post, discord("/guilds/#{guild_id}/channels"), body:)
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
##
|
1230
|
+
# @param guild_id [#to_s] Guild ID
|
1231
|
+
# @macro pBody
|
1232
|
+
# @macro rResponse
|
1233
|
+
#
|
1234
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
|
1235
|
+
# Discord documentation "Modify Guild Channel Positions"
|
1236
|
+
def modify_guild_channel_positions(guild_id, body)
|
1237
|
+
json_request(:patch, discord("/guilds/#{guild_id}/channels"), body:)
|
1238
|
+
end
|
1239
|
+
|
1240
|
+
##
|
1241
|
+
# @param guild_id [#to_s] Guild ID
|
1242
|
+
# @macro rResponse
|
1243
|
+
#
|
1244
|
+
# @see https://discord.com/developers/docs/resources/guild#list-active-guild-threads
|
1245
|
+
# Discord documentation "List Active Guild Threads"
|
1246
|
+
def list_active_guild_threads(guild_id)
|
1247
|
+
json_request(:get, discord("/guilds/#{guild_id}/threads/active"))
|
1248
|
+
end
|
1249
|
+
|
1250
|
+
##
|
1251
|
+
# @param guild_id [#to_s] Guild ID
|
1252
|
+
# @param user_id [#to_s] User ID
|
1253
|
+
# @macro rResponse
|
1254
|
+
#
|
1255
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-member
|
1256
|
+
# Discord documentation "Get Guild Member"
|
1257
|
+
def get_guild_member(guild_id, user_id)
|
1258
|
+
json_request(:get, discord("/guilds/#{guild_id}/members/#{user_id}"))
|
1259
|
+
end
|
1260
|
+
|
1261
|
+
##
|
1262
|
+
# @param guild_id [#to_s] Guild ID
|
1263
|
+
# @macro pQuery
|
1264
|
+
# @macro rResponse
|
1265
|
+
#
|
1266
|
+
# @see https://discord.com/developers/docs/resources/guild#list-guild-members
|
1267
|
+
# Discord documentation "List Guild Members"
|
1268
|
+
def list_guild_members(guild_id, query = {})
|
1269
|
+
json_request(:get, discord("/guilds/#{guild_id}/members"), query:)
|
1270
|
+
end
|
1271
|
+
|
1272
|
+
##
|
1273
|
+
# @param guild_id [#to_s] Guild ID
|
1274
|
+
# @macro pQuery
|
1275
|
+
# @macro rResponse
|
1276
|
+
#
|
1277
|
+
# @see https://discord.com/developers/docs/resources/guild#search-guild-members
|
1278
|
+
# Discord documentation "Search Guild Members"
|
1279
|
+
def search_guild_members(guild_id, query = {})
|
1280
|
+
json_request(:get, discord("/guilds/#{guild_id}/members/search"), query:)
|
1281
|
+
end
|
1282
|
+
|
1283
|
+
##
|
1284
|
+
# @param guild_id [#to_s] Guild ID
|
1285
|
+
# @param user_id [#to_s] User ID
|
1286
|
+
# @macro pBody
|
1287
|
+
# @macro rResponse
|
1288
|
+
#
|
1289
|
+
# @see https://discord.com/developers/docs/resources/guild#add-guild-member
|
1290
|
+
# Discord documentation "Add Guild Member"
|
1291
|
+
def add_guild_member(guild_id, user_id, body)
|
1292
|
+
json_request(:put, discord("/guilds/#{guild_id}/members/#{user_id}"), body:)
|
1293
|
+
end
|
1294
|
+
|
1295
|
+
##
|
1296
|
+
# @param guild_id [#to_s] Guild ID
|
1297
|
+
# @param user_id [#to_s] User ID
|
1298
|
+
# @macro pBody
|
1299
|
+
# @macro rResponse
|
1300
|
+
#
|
1301
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-member
|
1302
|
+
# Discord documentation "Modify Guild Member"
|
1303
|
+
def modify_guild_member(guild_id, user_id, body)
|
1304
|
+
json_request(:patch, discord("/guilds/#{guild_id}/members/#{user_id}"), body:)
|
1305
|
+
end
|
1306
|
+
|
1307
|
+
##
|
1308
|
+
# @param guild_id [#to_s] Guild ID
|
1309
|
+
# @macro pBody
|
1310
|
+
# @macro rResponse
|
1311
|
+
#
|
1312
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-current-member
|
1313
|
+
# Discord documentation "Modify Current Member"
|
1314
|
+
def modify_current_member(guild_id, body)
|
1315
|
+
json_request(:patch, discord("/guilds/#{guild_id}/members/@me"), body:)
|
1316
|
+
end
|
1317
|
+
|
1318
|
+
##
|
1319
|
+
# @deprecated Use {#modify_current_member} instead.
|
1320
|
+
#
|
1321
|
+
# @param guild_id [#to_s] Guild ID
|
1322
|
+
# @macro pBody
|
1323
|
+
# @macro rResponse
|
1324
|
+
#
|
1325
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-current-user-nick
|
1326
|
+
# Discord documentation "Modify Current User Nick"
|
1327
|
+
def modify_current_user_nick(guild_id, body)
|
1328
|
+
json_request(:patch, discord("/guilds/#{guild_id}/members/@me/nick"), body:)
|
1329
|
+
end
|
1330
|
+
|
1331
|
+
##
|
1332
|
+
# @param guild_id [#to_s] Guild ID
|
1333
|
+
# @param user_id [#to_s] User ID
|
1334
|
+
# @param role_id [#to_s] Role ID
|
1335
|
+
# @macro rResponse
|
1336
|
+
#
|
1337
|
+
# @see https://discord.com/developers/docs/resources/guild#add-guild-member-role
|
1338
|
+
# Discord documentation "Add Guild Member Role"
|
1339
|
+
def add_guild_member_role(guild_id, user_id, role_id)
|
1340
|
+
json_request(:put, discord("/guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}"))
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
##
|
1344
|
+
# @param guild_id [#to_s] Guild ID
|
1345
|
+
# @param user_id [#to_s] User ID
|
1346
|
+
# @param role_id [#to_s] Role ID
|
1347
|
+
# @macro rResponse
|
1348
|
+
#
|
1349
|
+
# @see https://discord.com/developers/docs/resources/guild#remove-guild-member-role
|
1350
|
+
# Discord documentation "Remove Guild Member Role"
|
1351
|
+
def remove_guild_member_role(guild_id, user_id, role_id)
|
1352
|
+
json_request(:delete, discord("/guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}"))
|
1353
|
+
end
|
1354
|
+
|
1355
|
+
##
|
1356
|
+
# @param guild_id [#to_s] Guild ID
|
1357
|
+
# @param user_id [#to_s] User ID
|
1358
|
+
# @macro rResponse
|
1359
|
+
#
|
1360
|
+
# @see https://discord.com/developers/docs/resources/guild#remove-guild-member
|
1361
|
+
# Discord documentation "Remove Guild Member"
|
1362
|
+
def remove_guild_member(guild_id, user_id)
|
1363
|
+
json_request(:delete, discord("/guilds/#{guild_id}/members/#{user_id}"))
|
1364
|
+
end
|
1365
|
+
|
1366
|
+
##
|
1367
|
+
# @param guild_id [#to_s] Guild ID
|
1368
|
+
# @macro pQuery
|
1369
|
+
# @macro rResponse
|
1370
|
+
#
|
1371
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-bans
|
1372
|
+
# Discord documentation "Get Guild Bans"
|
1373
|
+
def get_guild_bans(guild_id, query = {})
|
1374
|
+
json_request(:get, discord("/guilds/#{guild_id}/bans"), query:)
|
1375
|
+
end
|
1376
|
+
|
1377
|
+
##
|
1378
|
+
# @param guild_id [#to_s] Guild ID
|
1379
|
+
# @param user_id [#to_s] User ID
|
1380
|
+
# @macro rResponse
|
1381
|
+
#
|
1382
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-ban
|
1383
|
+
# Discord documentation "Get Guild Ban"
|
1384
|
+
def get_guild_ban(guild_id, user_id)
|
1385
|
+
json_request(:get, discord("/guilds/#{guild_id}/bans/#{user_id}"))
|
1386
|
+
end
|
1387
|
+
|
1388
|
+
##
|
1389
|
+
# @param guild_id [#to_s] Guild ID
|
1390
|
+
# @param user_id [#to_s] User ID
|
1391
|
+
# @macro pBody
|
1392
|
+
# @macro rResponse
|
1393
|
+
#
|
1394
|
+
# @see https://discord.com/developers/docs/resources/guild#create-guild-ban
|
1395
|
+
# Discord documentation "Create Guild Ban"
|
1396
|
+
def create_guild_ban(guild_id, user_id, body)
|
1397
|
+
json_request(:put, discord("/guilds/#{guild_id}/bans/#{user_id}"), body:)
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
##
|
1401
|
+
# @param guild_id [#to_s] Guild ID
|
1402
|
+
# @param user_id [#to_s] User ID
|
1403
|
+
# @macro rResponse
|
1404
|
+
#
|
1405
|
+
# @see https://discord.com/developers/docs/resources/guild#remove-guild-ban
|
1406
|
+
# Discord documentation "Remove Guild Ban"
|
1407
|
+
def remove_guild_ban(guild_id, user_id)
|
1408
|
+
json_request(:delete, discord("/guilds/#{guild_id}/bans/#{user_id}"))
|
1409
|
+
end
|
1410
|
+
|
1411
|
+
##
|
1412
|
+
# @param guild_id [#to_s] Guild ID
|
1413
|
+
# @macro pBody
|
1414
|
+
# @macro rResponse
|
1415
|
+
#
|
1416
|
+
# @see https://discord.com/developers/docs/resources/guild#bulk-guild-ban
|
1417
|
+
# Discord documentation "Bulk Guild Ban"
|
1418
|
+
def bulk_guild_ban(guild_id, body)
|
1419
|
+
json_request(:post, discord("/guilds/#{guild_id}/bulk-ban"), body:)
|
1420
|
+
end
|
1421
|
+
|
1422
|
+
##
|
1423
|
+
# @param guild_id [#to_s] Guild ID
|
1424
|
+
# @macro rResponse
|
1425
|
+
#
|
1426
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-roles
|
1427
|
+
# Discord documentation "Get Guild Roles"
|
1428
|
+
def get_guild_roles(guild_id)
|
1429
|
+
json_request(:get, discord("/guilds/#{guild_id}/roles"))
|
1430
|
+
end
|
1431
|
+
|
1432
|
+
##
|
1433
|
+
# @param guild_id [#to_s] Guild ID
|
1434
|
+
# @param role_id [#to_s] Role ID
|
1435
|
+
# @macro rResponse
|
1436
|
+
#
|
1437
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-role
|
1438
|
+
# Discord documentation "Get Guild Role"
|
1439
|
+
def get_guild_role(guild_id, role_id)
|
1440
|
+
json_request(:get, discord("/guilds/#{guild_id}/roles/#{role_id}"))
|
1441
|
+
end
|
1442
|
+
|
1443
|
+
##
|
1444
|
+
# @param guild_id [#to_s] Guild ID
|
1445
|
+
# @macro pBody
|
1446
|
+
# @macro rResponse
|
1447
|
+
#
|
1448
|
+
# @see https://discord.com/developers/docs/resources/guild#create-guild-role
|
1449
|
+
# Discord documentation "Create Guild Role"
|
1450
|
+
def create_guild_role(guild_id, body)
|
1451
|
+
json_request(:post, discord("/guilds/#{guild_id}/roles"), body:)
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
##
|
1455
|
+
# @param guild_id [#to_s] Guild ID
|
1456
|
+
# @macro pBody
|
1457
|
+
# @macro rResponse
|
1458
|
+
#
|
1459
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
|
1460
|
+
# Discord documentation "Modify Guild Role Positions"
|
1461
|
+
def modify_guild_role_positions(guild_id, body)
|
1462
|
+
json_request(:patch, discord("/guilds/#{guild_id}/roles"), body:)
|
1463
|
+
end
|
1464
|
+
|
1465
|
+
##
|
1466
|
+
# @param guild_id [#to_s] Guild ID
|
1467
|
+
# @param role_id [#to_s] Role ID
|
1468
|
+
# @macro pBody
|
1469
|
+
# @macro rResponse
|
1470
|
+
#
|
1471
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-role
|
1472
|
+
# Discord documentation "Modify Guild Role"
|
1473
|
+
def modify_guild_role(guild_id, role_id, body)
|
1474
|
+
json_request(:patch, discord("/guilds/#{guild_id}/roles/#{role_id}"), body:)
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
##
|
1478
|
+
# @param guild_id [#to_s] Guild ID
|
1479
|
+
# @macro pBody
|
1480
|
+
# @macro rResponse
|
1481
|
+
#
|
1482
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-mfa-level
|
1483
|
+
# Discord documentation "Modify Guild MFA level"
|
1484
|
+
def modify_guild_mfa_level(guild_id, body)
|
1485
|
+
json_request(:post, discord("/guilds/#{guild_id}/mfa"), body:)
|
1486
|
+
end
|
1487
|
+
|
1488
|
+
##
|
1489
|
+
# @param guild_id [#to_s] Guild ID
|
1490
|
+
# @param role_id [#to_s] Role ID
|
1491
|
+
# @macro rResponse
|
1492
|
+
#
|
1493
|
+
# @see https://discord.com/developers/docs/resources/guild#delete-guild-role
|
1494
|
+
# Discord documentation "Delete Guild Role"
|
1495
|
+
def delete_guild_role(guild_id, role_id)
|
1496
|
+
json_request(:delete, discord("/guilds/#{guild_id}/roles/#{role_id}"))
|
1497
|
+
end
|
1498
|
+
|
1499
|
+
##
|
1500
|
+
# @param guild_id [#to_s] Guild ID
|
1501
|
+
# @macro pQuery
|
1502
|
+
# @macro rResponse
|
1503
|
+
#
|
1504
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-prune-count
|
1505
|
+
# Discord documentation "Get Guild Prune Count"
|
1506
|
+
def get_guild_prune_count(guild_id, query = {})
|
1507
|
+
json_request(:get, discord("/guilds/#{guild_id}/prune"), query:)
|
1508
|
+
end
|
1509
|
+
|
1510
|
+
##
|
1511
|
+
# @param guild_id [#to_s] Guild ID
|
1512
|
+
# @macro pBody
|
1513
|
+
# @macro rResponse
|
1514
|
+
#
|
1515
|
+
# @see https://discord.com/developers/docs/resources/guild#begin-guild-prune
|
1516
|
+
# Discord documentation "Begin Guild Prune"
|
1517
|
+
def begin_guild_prune(guild_id, body)
|
1518
|
+
json_request(:post, discord("/guilds/#{guild_id}/prune"), body:)
|
1519
|
+
end
|
1520
|
+
|
1521
|
+
##
|
1522
|
+
# @param guild_id [#to_s] Guild ID
|
1523
|
+
# @macro rResponse
|
1524
|
+
#
|
1525
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
|
1526
|
+
# Discord documentation "Get Guild Voice Regions"
|
1527
|
+
def get_guild_voice_regions(guild_id)
|
1528
|
+
json_request(:get, discord("/guilds/#{guild_id}/regions"))
|
1529
|
+
end
|
1530
|
+
|
1531
|
+
##
|
1532
|
+
# @param guild_id [#to_s] Guild ID
|
1533
|
+
# @macro rResponse
|
1534
|
+
#
|
1535
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-invites
|
1536
|
+
# Discord documentation "Get Guild Invites"
|
1537
|
+
def get_guild_invites(guild_id)
|
1538
|
+
json_request(:get, discord("/guilds/#{guild_id}/invites"))
|
1539
|
+
end
|
1540
|
+
|
1541
|
+
##
|
1542
|
+
# @param guild_id [#to_s] Guild ID
|
1543
|
+
# @macro rResponse
|
1544
|
+
#
|
1545
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-integrations
|
1546
|
+
# Discord documentation "Get Guild Integrations"
|
1547
|
+
def get_guild_integrations(guild_id)
|
1548
|
+
json_request(:get, discord("/guilds/#{guild_id}/integrations"))
|
1549
|
+
end
|
1550
|
+
|
1551
|
+
##
|
1552
|
+
# @param guild_id [#to_s] Guild ID
|
1553
|
+
# @param integration_id [#to_s] Integration ID
|
1554
|
+
# @macro rResponse
|
1555
|
+
#
|
1556
|
+
# @see https://discord.com/developers/docs/resources/guild#delete-guild-integration
|
1557
|
+
# Discord documentation "Delete Guild Integration"
|
1558
|
+
def delete_guild_integration(guild_id, integration_id)
|
1559
|
+
json_request(:delete, discord("/guilds/#{guild_id}/integrations/#{integration_id}"))
|
1560
|
+
end
|
1561
|
+
|
1562
|
+
##
|
1563
|
+
# @param guild_id [#to_s] Guild ID
|
1564
|
+
# @macro rResponse
|
1565
|
+
#
|
1566
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-widget-settings
|
1567
|
+
# Discord documentation "Get Guild Widget Settings"
|
1568
|
+
def get_guild_widget_settings(guild_id)
|
1569
|
+
json_request(:get, discord("/guilds/#{guild_id}/widget"))
|
1570
|
+
end
|
1571
|
+
|
1572
|
+
##
|
1573
|
+
# @param guild_id [#to_s] Guild ID
|
1574
|
+
# @macro pBody
|
1575
|
+
# @macro rResponse
|
1576
|
+
#
|
1577
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-widget
|
1578
|
+
# Discord documentation "Modify Guild Widget"
|
1579
|
+
def modify_guild_widget(guild_id, body)
|
1580
|
+
json_request(:patch, discord("/guilds/#{guild_id}/widget"), body:)
|
1581
|
+
end
|
1582
|
+
|
1583
|
+
##
|
1584
|
+
# @param guild_id [#to_s] Guild ID
|
1585
|
+
# @macro rResponse
|
1586
|
+
#
|
1587
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-widget
|
1588
|
+
# Discord documentation "Get Guild Widget"
|
1589
|
+
def get_guild_widget(guild_id)
|
1590
|
+
json_request(:get, discord("/guilds/#{guild_id}/widget.json"))
|
1591
|
+
end
|
1592
|
+
|
1593
|
+
##
|
1594
|
+
# @param guild_id [#to_s] Guild ID
|
1595
|
+
# @macro rResponse
|
1596
|
+
#
|
1597
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-vanity-url
|
1598
|
+
# Discord documentation "Get Guild Vanity URL"
|
1599
|
+
def get_guild_vanity_url(guild_id)
|
1600
|
+
json_request(:get, discord("/guilds/#{guild_id}/vanity-url"))
|
1601
|
+
end
|
1602
|
+
|
1603
|
+
##
|
1604
|
+
# @param guild_id [#to_s] Guild ID
|
1605
|
+
# @macro pQuery
|
1606
|
+
# @macro rResponse
|
1607
|
+
#
|
1608
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-widget-image
|
1609
|
+
# Discord documentation "Get Guild Widget Image"
|
1610
|
+
def get_guild_widget_image(guild_id, query = {})
|
1611
|
+
net_request(:get, discord("/guilds/#{guild_id}/widget.png"), query:)
|
1612
|
+
end
|
1613
|
+
|
1614
|
+
##
|
1615
|
+
# @param guild_id [#to_s] Guild ID
|
1616
|
+
# @macro rResponse
|
1617
|
+
#
|
1618
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
|
1619
|
+
# Discord documentation "Get Guild Welcome Screen"
|
1620
|
+
def get_guild_welcome_screen(guild_id)
|
1621
|
+
json_request(:get, discord("/guilds/#{guild_id}/welcome-screen"))
|
1622
|
+
end
|
1623
|
+
|
1624
|
+
##
|
1625
|
+
# @param guild_id [#to_s] Guild ID
|
1626
|
+
# @macro pBody
|
1627
|
+
# @macro rResponse
|
1628
|
+
#
|
1629
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
|
1630
|
+
# Discord documentation "Modify Guild Welcome Screen"
|
1631
|
+
def modify_guild_welcome_screen(guild_id, body)
|
1632
|
+
json_request(:patch, discord("/guilds/#{guild_id}/welcome-screen"), body:)
|
1633
|
+
end
|
1634
|
+
|
1635
|
+
##
|
1636
|
+
# @param guild_id [#to_s] Guild ID
|
1637
|
+
# @macro rResponse
|
1638
|
+
#
|
1639
|
+
# @see https://discord.com/developers/docs/resources/guild#get-guild-onboarding
|
1640
|
+
# Discord documentation "Get Guild Onboarding"
|
1641
|
+
def get_guild_onboarding(guild_id)
|
1642
|
+
json_request(:get, discord("/guilds/#{guild_id}/onboarding"))
|
1643
|
+
end
|
1644
|
+
|
1645
|
+
##
|
1646
|
+
# @param guild_id [#to_s] Guild ID
|
1647
|
+
# @macro pBody
|
1648
|
+
# @macro rResponse
|
1649
|
+
#
|
1650
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-onboarding
|
1651
|
+
# Discord documentation "Modify Guild Onboarding"
|
1652
|
+
def modify_guild_onboarding(guild_id, body)
|
1653
|
+
json_request(:put, discord("/guilds/#{guild_id}/onboarding"), body:)
|
1654
|
+
end
|
1655
|
+
|
1656
|
+
##
|
1657
|
+
# @param guild_id [#to_s] Guild ID
|
1658
|
+
# @macro pBody
|
1659
|
+
# @macro rResponse
|
1660
|
+
#
|
1661
|
+
# @see https://discord.com/developers/docs/resources/guild#modify-guild-incident-actions
|
1662
|
+
# Discord documentation "Modify Guild Incident Actions"
|
1663
|
+
def modify_guild_incident_actions(guild_id, body)
|
1664
|
+
json_request(:put, discord("/guilds/#{guild_id}/incident-actions"), body:)
|
1665
|
+
end
|
1666
|
+
|
1667
|
+
### }}} Guild
|
1668
|
+
|
1669
|
+
### Invite {{{
|
1670
|
+
|
1671
|
+
##
|
1672
|
+
# @param invite_code [#to_s] Invite Code
|
1673
|
+
# @macro pQuery
|
1674
|
+
# @macro rResponse
|
1675
|
+
#
|
1676
|
+
# @see https://discord.com/developers/docs/resources/invite#get-invite
|
1677
|
+
# Discord documentation "Get Invite"
|
1678
|
+
def get_invite(invite_code, query = {})
|
1679
|
+
json_request(:get, discord("/invites/#{invite_code}"), query:)
|
1680
|
+
end
|
1681
|
+
|
1682
|
+
##
|
1683
|
+
# @param invite_code [#to_s] Invite Code
|
1684
|
+
# @macro rResponse
|
1685
|
+
#
|
1686
|
+
# @see https://discord.com/developers/docs/resources/invite#delete-invite
|
1687
|
+
# Discord documentation "Delete Invite"
|
1688
|
+
def delete_invite(invite_code)
|
1689
|
+
json_request(:delete, discord("/invites/#{invite_code}"))
|
1690
|
+
end
|
1691
|
+
|
1692
|
+
### }}} Invite
|
1693
|
+
|
1694
|
+
### Lobby {{{
|
1695
|
+
|
1696
|
+
##
|
1697
|
+
# @macro pBody
|
1698
|
+
# @macro rResponse
|
1699
|
+
#
|
1700
|
+
# @see https://discord.com/developers/docs/resources/lobby#create-lobby
|
1701
|
+
# Discord documentation "Create Lobby"
|
1702
|
+
def create_lobby(body)
|
1703
|
+
json_request(:post, discord("/lobbies"), body:)
|
1704
|
+
end
|
1705
|
+
|
1706
|
+
##
|
1707
|
+
# @param lobby_id [#to_s] Lobby ID
|
1708
|
+
# @macro rResponse
|
1709
|
+
#
|
1710
|
+
# @see https://discord.com/developers/docs/resources/lobby#get-lobby
|
1711
|
+
# Discord documentation "Get Lobby"
|
1712
|
+
def get_lobby(lobby_id)
|
1713
|
+
json_request(:get, discord("/lobbies/#{lobby_id}"))
|
1714
|
+
end
|
1715
|
+
|
1716
|
+
##
|
1717
|
+
# @param lobby_id [#to_s] Lobby ID
|
1718
|
+
# @macro pBody
|
1719
|
+
# @macro rResponse
|
1720
|
+
#
|
1721
|
+
# @see https://discord.com/developers/docs/resources/lobby#modify-lobby
|
1722
|
+
# Discord documentation "Modify Lobby"
|
1723
|
+
def modify_lobby(lobby_id, body)
|
1724
|
+
json_request(:patch, discord("/lobbies/#{lobby_id}"), body:)
|
1725
|
+
end
|
1726
|
+
|
1727
|
+
##
|
1728
|
+
# @param lobby_id [#to_s] Lobby ID
|
1729
|
+
# @macro rResponse
|
1730
|
+
#
|
1731
|
+
# @see https://discord.com/developers/docs/resources/lobby#delete-lobby
|
1732
|
+
# Discord documentation "Delete Lobby"
|
1733
|
+
def delete_lobby(lobby_id)
|
1734
|
+
json_request(:delete, discord("/lobbies/#{lobby_id}"))
|
1735
|
+
end
|
1736
|
+
|
1737
|
+
##
|
1738
|
+
# @param lobby_id [#to_s] Lobby ID
|
1739
|
+
# @param user_id [#to_s] User ID
|
1740
|
+
# @macro pBody
|
1741
|
+
# @macro rResponse
|
1742
|
+
#
|
1743
|
+
# @see https://discord.com/developers/docs/resources/lobby#add-a-member-to-a-lobby
|
1744
|
+
# Discord documentation "Add a Member to a Lobby"
|
1745
|
+
def add_member_to_lobby(lobby_id, user_id, body = "")
|
1746
|
+
json_request(:put, discord("/lobbies/#{lobby_id}/members/#{user_id}"), body:)
|
1747
|
+
end
|
1748
|
+
|
1749
|
+
##
|
1750
|
+
# @param lobby_id [#to_s] Lobby ID
|
1751
|
+
# @param user_id [#to_s] User ID
|
1752
|
+
# @macro rResponse
|
1753
|
+
#
|
1754
|
+
# @see https://discord.com/developers/docs/resources/lobby#remove-a-member-from-a-lobby
|
1755
|
+
# Discord documentation "Remove a Member from a Lobby"
|
1756
|
+
def remove_member_from_lobby(lobby_id, user_id)
|
1757
|
+
json_request(:delete, discord("/lobbies/#{lobby_id}/members/#{user_id}"))
|
1758
|
+
end
|
1759
|
+
|
1760
|
+
##
|
1761
|
+
# @param lobby_id [#to_s] Lobby ID
|
1762
|
+
# @macro rResponse
|
1763
|
+
#
|
1764
|
+
# @see https://discord.com/developers/docs/resources/lobby#leave-lobby
|
1765
|
+
# Discord documentation "Leave Lobby"
|
1766
|
+
def leave_lobby(lobby_id)
|
1767
|
+
json_request(:delete, discord("/lobbies/#{lobby_id}/members/@me"))
|
1768
|
+
end
|
1769
|
+
|
1770
|
+
##
|
1771
|
+
# @param lobby_id [#to_s] Lobby ID
|
1772
|
+
# @macro pBody
|
1773
|
+
# @macro rResponse
|
1774
|
+
#
|
1775
|
+
# @see https://discord.com/developers/docs/resources/lobby#link-channel-to-lobby
|
1776
|
+
# Discord documentation "Link Channel to Lobby"
|
1777
|
+
def link_channel_to_lobby(lobby_id, body)
|
1778
|
+
json_request(:patch, discord("/lobbies/#{lobby_id}/channel-linking"), body:)
|
1779
|
+
end
|
1780
|
+
|
1781
|
+
##
|
1782
|
+
# @param lobby_id [#to_s] Lobby ID
|
1783
|
+
# @macro rResponse
|
1784
|
+
#
|
1785
|
+
# @see https://discord.com/developers/docs/resources/lobby#unlink-channel-from-lobby
|
1786
|
+
# Discord documentation "Unlink Channel from Lobby"
|
1787
|
+
def unlink_channel_from_lobby(lobby_id)
|
1788
|
+
json_request(:patch, discord("/lobbies/#{lobby_id}/channel-linking"))
|
1789
|
+
end
|
1790
|
+
|
1791
|
+
### }}} Lobby
|
1792
|
+
|
1793
|
+
### Message {{{
|
1794
|
+
|
1795
|
+
##
|
1796
|
+
# @param channel_id [#to_s] Channel ID
|
1797
|
+
# @macro pQuery
|
1798
|
+
# @macro rResponse
|
1799
|
+
#
|
1800
|
+
# @see https://discord.com/developers/docs/resources/message#get-channel-messages
|
1801
|
+
# Discord documentation "Get Channel Messages"
|
1802
|
+
def get_channel_messages(channel_id, query = {})
|
1803
|
+
json_request(:get, discord("/channels/#{channel_id}/messages"), query:)
|
1804
|
+
end
|
1805
|
+
|
1806
|
+
##
|
1807
|
+
# @param channel_id [#to_s] Channel ID
|
1808
|
+
# @param message_id [#to_s] Message ID
|
1809
|
+
# @macro rResponse
|
1810
|
+
#
|
1811
|
+
# @see https://discord.com/developers/docs/resources/message#get-channel-message
|
1812
|
+
# Discord documentation "Get Channel Message"
|
1813
|
+
def get_channel_message(channel_id, message_id)
|
1814
|
+
json_request(:get, discord("/channels/#{channel_id}/messages/#{message_id}"))
|
1815
|
+
end
|
1816
|
+
|
1817
|
+
##
|
1818
|
+
# @param channel_id [#to_s] Channel ID
|
1819
|
+
# @macro pBody
|
1820
|
+
# @macro rResponse
|
1821
|
+
#
|
1822
|
+
# @see https://discord.com/developers/docs/resources/message#create-message
|
1823
|
+
# Discord documentation "Create Message"
|
1824
|
+
def create_message(channel_id, body)
|
1825
|
+
json_request(:post, discord("/channels/#{channel_id}/messages"), body:)
|
1826
|
+
end
|
1827
|
+
|
1828
|
+
##
|
1829
|
+
# @param channel_id [#to_s] Channel ID
|
1830
|
+
# @param message_id [#to_s] Message ID
|
1831
|
+
#
|
1832
|
+
# @macro rResponse
|
1833
|
+
#
|
1834
|
+
# @see https://discord.com/developers/docs/resources/message#crosspost-message
|
1835
|
+
# Discord documentation "Crosspost Message"
|
1836
|
+
def crosspost_message(channel_id, message_id)
|
1837
|
+
json_request(:post, discord("/channels/#{channel_id}/messages/#{message_id}/crosspost"))
|
1838
|
+
end
|
1839
|
+
|
1840
|
+
##
|
1841
|
+
# @param channel_id [#to_s] Channel ID
|
1842
|
+
# @param message_id [#to_s] Message ID
|
1843
|
+
# @param emoji [#to_s]
|
1844
|
+
# @macro rResponse
|
1845
|
+
#
|
1846
|
+
# @see https://discord.com/developers/docs/resources/message#create-reaction
|
1847
|
+
# Discord documentation "Create Reaction"
|
1848
|
+
def create_reaction(channel_id, message_id, emoji)
|
1849
|
+
json_request(:put, discord("/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/@me"))
|
1850
|
+
end
|
1851
|
+
|
1852
|
+
##
|
1853
|
+
# @param channel_id [#to_s] Channel ID
|
1854
|
+
# @param message_id [#to_s] Message ID
|
1855
|
+
# @param emoji [#to_s] Emoji
|
1856
|
+
# @macro rResponse
|
1857
|
+
#
|
1858
|
+
# @see https://discord.com/developers/docs/resources/message#delete-own-reaction
|
1859
|
+
# Discord documentation "Delete Own Reaction"
|
1860
|
+
def delete_own_reaction(channel_id, message_id, emoji)
|
1861
|
+
json_request(:delete, discord("/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/@me"))
|
1862
|
+
end
|
1863
|
+
|
1864
|
+
##
|
1865
|
+
# @param channel_id [#to_s] Channel ID
|
1866
|
+
# @param message_id [#to_s] Message ID
|
1867
|
+
# @param emoji [#to_s] Emoji
|
1868
|
+
# @param user_id [#to_s] User ID
|
1869
|
+
# @macro rResponse
|
1870
|
+
#
|
1871
|
+
# @see https://discord.com/developers/docs/resources/message#delete-user-reaction
|
1872
|
+
# Discord documentation "Delete User Reaction"
|
1873
|
+
def delete_user_reaction(channel_id, message_id, emoji, user_id)
|
1874
|
+
json_request(:delete, discord("/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/#{user_id}"))
|
1875
|
+
end
|
1876
|
+
|
1877
|
+
##
|
1878
|
+
# @param channel_id [#to_s] Channel ID
|
1879
|
+
# @param message_id [#to_s] Message ID
|
1880
|
+
# @param emoji [#to_s] Emoji
|
1881
|
+
# @macro pQuery
|
1882
|
+
# @macro rResponse
|
1883
|
+
#
|
1884
|
+
# @see https://discord.com/developers/docs/resources/message#get-reactions
|
1885
|
+
# Discord documentation "Get Reactions"
|
1886
|
+
def get_reactions(channel_id, message_id, emoji, query = {})
|
1887
|
+
json_request(:get, discord("/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}"), query:)
|
1888
|
+
end
|
1889
|
+
|
1890
|
+
##
|
1891
|
+
# @param channel_id [#to_s] Channel ID
|
1892
|
+
# @param message_id [#to_s] Message ID
|
1893
|
+
# @macro rResponse
|
1894
|
+
#
|
1895
|
+
# @see https://discord.com/developers/docs/resources/message#delete-all-reactions
|
1896
|
+
# Discord documentation "Delete All Reactions"
|
1897
|
+
def delete_all_reactions(channel_id, message_id)
|
1898
|
+
json_request(:delete, discord("/channels/#{channel_id}/messages/#{message_id}/reactions"))
|
1899
|
+
end
|
1900
|
+
|
1901
|
+
##
|
1902
|
+
# @param channel_id [#to_s] Channel ID
|
1903
|
+
# @param message_id [#to_s] Message ID
|
1904
|
+
# @param emoji [#to_s]
|
1905
|
+
# @macro rResponse
|
1906
|
+
#
|
1907
|
+
# @see https://discord.com/developers/docs/resources/message#delete-all-reactions-for-emoji
|
1908
|
+
# Discord documentation "Delete All Reactions for Emoji"
|
1909
|
+
def delete_all_reactions_for_emoji(channel_id, message_id, emoji)
|
1910
|
+
json_request(:delete, discord("/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}"))
|
1911
|
+
end
|
1912
|
+
|
1913
|
+
##
|
1914
|
+
# @param channel_id [#to_s] Channel ID
|
1915
|
+
# @param message_id [#to_s] Message ID
|
1916
|
+
# @macro pBody
|
1917
|
+
# @macro rResponse
|
1918
|
+
#
|
1919
|
+
# @see https://discord.com/developers/docs/resources/message#edit-message
|
1920
|
+
# Discord documentation "Edit Message"
|
1921
|
+
def edit_message(channel_id, message_id, body)
|
1922
|
+
json_request(:patch, discord("/channels/#{channel_id}/messages/#{message_id}"), body:)
|
1923
|
+
end
|
1924
|
+
|
1925
|
+
##
|
1926
|
+
# @param channel_id [#to_s] Channel ID
|
1927
|
+
# @param message_id [#to_s] Message ID
|
1928
|
+
# @macro rResponse
|
1929
|
+
#
|
1930
|
+
# @see https://discord.com/developers/docs/resources/message#delete-message
|
1931
|
+
# Discord documentation "Delete Message"
|
1932
|
+
def delete_message(channel_id, message_id)
|
1933
|
+
json_request(:delete, discord("/channels/#{channel_id}/messages/#{message_id}"))
|
1934
|
+
end
|
1935
|
+
|
1936
|
+
##
|
1937
|
+
# @param channel_id [#to_s] Channel ID
|
1938
|
+
# @macro pBody
|
1939
|
+
# @macro rResponse
|
1940
|
+
#
|
1941
|
+
# @see https://discord.com/developers/docs/resources/message#bulk-delete-messages
|
1942
|
+
# Discord documentation "Bulk Delete Messages"
|
1943
|
+
def bulk_delete_messages(channel_id, body)
|
1944
|
+
json_request(:post, discord("/channels/#{channel_id}/messages/bulk-delete"), body:)
|
1945
|
+
end
|
1946
|
+
|
1947
|
+
### }}} Message
|
1948
|
+
|
1949
|
+
### Poll {{{
|
1950
|
+
|
1951
|
+
##
|
1952
|
+
# @param channel_id [#to_s] Channel ID
|
1953
|
+
# @param message_id [#to_s] Message ID
|
1954
|
+
# @param answer_id [#to_s] Answer ID
|
1955
|
+
# @macro pQuery
|
1956
|
+
# @macro rResponse
|
1957
|
+
#
|
1958
|
+
# @see https://discord.com/developers/docs/resources/poll#get-answer-voters
|
1959
|
+
# Discord documentation "Get Answer Voters"
|
1960
|
+
def get_answer_voters(channel_id, message_id, answer_id, query = {})
|
1961
|
+
json_request(:get, discord("/channels/#{channel_id}/polls/#{message_id}/answers/#{answer_id}"), query:)
|
1962
|
+
end
|
1963
|
+
|
1964
|
+
##
|
1965
|
+
# @param channel_id [#to_s] Channel ID
|
1966
|
+
# @param message_id [#to_s] Message ID
|
1967
|
+
# @macro rResponse
|
1968
|
+
#
|
1969
|
+
# @see https://discord.com/developers/docs/resources/poll#end-poll
|
1970
|
+
# Discord documentation "End Poll"
|
1971
|
+
def end_poll(channel_id, message_id)
|
1972
|
+
json_request(:post, discord("/channels/#{channel_id}/polls/#{message_id}/expire"))
|
1973
|
+
end
|
1974
|
+
|
1975
|
+
### }}} Poll
|
1976
|
+
|
1977
|
+
### SKU {{{
|
1978
|
+
|
1979
|
+
##
|
1980
|
+
# @param application_id [#to_s] Application ID
|
1981
|
+
# @macro rResponse
|
1982
|
+
#
|
1983
|
+
# @see https://discord.com/developers/docs/resources/sku#list-skus
|
1984
|
+
# Discord documentation "List SKUs"
|
1985
|
+
def list_skus(application_id)
|
1986
|
+
json_request(:get, discord("/applications/#{application_id}/skus"))
|
1987
|
+
end
|
1988
|
+
|
1989
|
+
### }}} SKU
|
1990
|
+
|
1991
|
+
### Soundboard {{{
|
1992
|
+
|
1993
|
+
##
|
1994
|
+
# @param channel_id [#to_s] Channel ID
|
1995
|
+
# @macro pBody
|
1996
|
+
# @macro rResponse
|
1997
|
+
#
|
1998
|
+
# @see https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound
|
1999
|
+
# Discord documentation "Send Soundboard Sound"
|
2000
|
+
def send_soundboard_sound(channel_id, body)
|
2001
|
+
json_request(:post, discord("/channels/#{channel_id}/send-soundboard-sound"), body:)
|
2002
|
+
end
|
2003
|
+
|
2004
|
+
##
|
2005
|
+
# @macro rResponse
|
2006
|
+
#
|
2007
|
+
# @see https://discord.com/developers/docs/resources/soundboard#list-default-soundboard-sounds
|
2008
|
+
# Discord documentation "List Default Soundboard Sounds"
|
2009
|
+
def list_default_soundboard_sounds
|
2010
|
+
json_request(:get, discord("/soundboard-default-sounds"))
|
2011
|
+
end
|
2012
|
+
|
2013
|
+
##
|
2014
|
+
# @param guild_id [#to_s] Guild ID
|
2015
|
+
# @macro rResponse
|
2016
|
+
#
|
2017
|
+
# @see https://discord.com/developers/docs/resources/soundboard#list-guild-soundboard-sounds
|
2018
|
+
# Discord documentation "List Guild Soundboard Sounds"
|
2019
|
+
def list_guild_soundboard_sounds(guild_id)
|
2020
|
+
json_request(:get, discord("/guilds/#{guild_id}/soundboard-sounds"))
|
2021
|
+
end
|
2022
|
+
|
2023
|
+
##
|
2024
|
+
# @param guild_id [#to_s] Guild ID
|
2025
|
+
# @param sound_id [#to_s] Sound ID
|
2026
|
+
# @macro rResponse
|
2027
|
+
#
|
2028
|
+
# @see https://discord.com/developers/docs/resources/soundboard#get-guild-soundboard-sound
|
2029
|
+
# Discord documentation "Get Guild Soundboard Sound"
|
2030
|
+
def get_guild_soundboard_sound(guild_id, sound_id)
|
2031
|
+
json_request(:get, discord("/guilds/#{guild_id}/soundboard-sounds/#{sound_id}"))
|
2032
|
+
end
|
2033
|
+
|
2034
|
+
##
|
2035
|
+
# @param guild_id [#to_s] Guild ID
|
2036
|
+
# @macro pBody
|
2037
|
+
# @macro rResponse
|
2038
|
+
#
|
2039
|
+
# @see https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound
|
2040
|
+
# Discord documentation "Create Guild Soundboard Sound"
|
2041
|
+
def create_guild_soundboard_sound(guild_id, body)
|
2042
|
+
json_request(:post, discord("/guilds/#{guild_id}/soundboard-sounds"), body:)
|
2043
|
+
end
|
2044
|
+
|
2045
|
+
##
|
2046
|
+
# @param guild_id [#to_s] Guild ID
|
2047
|
+
# @param sound_id [#to_s] Sound ID
|
2048
|
+
# @macro pBody
|
2049
|
+
# @macro rResponse
|
2050
|
+
#
|
2051
|
+
# @see https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound
|
2052
|
+
# Discord documentation "Modify Guild Soundboard Sound"
|
2053
|
+
def modify_guild_soundboard_sound(guild_id, sound_id, body)
|
2054
|
+
json_request(:patch, discord("/guilds/#{guild_id}/soundboard-sounds/#{sound_id}"), body:)
|
2055
|
+
end
|
2056
|
+
|
2057
|
+
##
|
2058
|
+
# @param guild_id [#to_s] Guild ID
|
2059
|
+
# @param sound_id [#to_s] Sound ID
|
2060
|
+
# @macro rResponse
|
2061
|
+
#
|
2062
|
+
# @see https://discord.com/developers/docs/resources/soundboard#delete-guild-soundboard-sound
|
2063
|
+
# Discord documentation "Delete Guild Soundboard Sound"
|
2064
|
+
def delete_guild_soundboard_sound(guild_id, sound_id)
|
2065
|
+
json_request(:delete, discord("/guilds/#{guild_id}/soundboard-sounds/#{sound_id}"))
|
2066
|
+
end
|
2067
|
+
|
2068
|
+
### }}} Soundboard
|
2069
|
+
|
2070
|
+
### Stage Instance {{{
|
2071
|
+
|
2072
|
+
##
|
2073
|
+
# @macro pBody
|
2074
|
+
# @macro rResponse
|
2075
|
+
#
|
2076
|
+
# @see https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
|
2077
|
+
# Discord documentation "Create Stage Instance"
|
2078
|
+
def create_stage_instance(body)
|
2079
|
+
json_request(:post, discord("/stage-instances"), body:)
|
2080
|
+
end
|
2081
|
+
|
2082
|
+
##
|
2083
|
+
# @param channel_id [#to_s] Channel ID
|
2084
|
+
# @macro rResponse
|
2085
|
+
#
|
2086
|
+
# @see https://discord.com/developers/docs/resources/stage-instance#get-stage-instance
|
2087
|
+
# Discord documentation "Get Stage Instance"
|
2088
|
+
def get_stage_instance(channel_id)
|
2089
|
+
json_request(:get, discord("/stage-instances/#{channel_id}"))
|
2090
|
+
end
|
2091
|
+
|
2092
|
+
##
|
2093
|
+
# @param channel_id [#to_s] Channel ID
|
2094
|
+
# @macro pBody
|
2095
|
+
# @macro rResponse
|
2096
|
+
#
|
2097
|
+
# @see https://discord.com/developers/docs/resources/stage-instance#modify-stage-instance
|
2098
|
+
# Discord documentation "Modify Stage Instance"
|
2099
|
+
def modify_stage_instance(channel_id, body)
|
2100
|
+
json_request(:patch, discord("/stage-instances/#{channel_id}"), body:)
|
2101
|
+
end
|
2102
|
+
|
2103
|
+
##
|
2104
|
+
# @param channel_id [#to_s] Channel ID
|
2105
|
+
# @macro rResponse
|
2106
|
+
#
|
2107
|
+
# @see https://discord.com/developers/docs/resources/stage-instance#delete-stage-instance
|
2108
|
+
# Discord documentation "Delete Stage Instance"
|
2109
|
+
def delete_stage_instance(channel_id)
|
2110
|
+
json_request(:delete, discord("/stage-instances/#{channel_id}"))
|
2111
|
+
end
|
2112
|
+
|
2113
|
+
### }}} Stage Instance
|
2114
|
+
|
2115
|
+
### Sticker {{{
|
2116
|
+
|
2117
|
+
##
|
2118
|
+
# @param sticker_id [#to_s] Sticker ID
|
2119
|
+
# @macro rResponse
|
2120
|
+
#
|
2121
|
+
# @see https://discord.com/developers/docs/resources/sticker#get-sticker
|
2122
|
+
# Discord documentation "Get Sticker"
|
2123
|
+
def get_sticker(sticker_id)
|
2124
|
+
json_request(:get, discord("/stickers/#{sticker_id}"))
|
2125
|
+
end
|
2126
|
+
|
2127
|
+
##
|
2128
|
+
# @macro rResponse
|
2129
|
+
#
|
2130
|
+
# @see https://discord.com/developers/docs/resources/sticker#list-sticker-packs
|
2131
|
+
# Discord documentation "List Sticker Packs"
|
2132
|
+
def list_sticker_packs
|
2133
|
+
json_request(:get, discord("/sticker-packs"))
|
2134
|
+
end
|
2135
|
+
|
2136
|
+
##
|
2137
|
+
# @param pack_id [#to_s] Sticker Pack ID
|
2138
|
+
# @macro rResponse
|
2139
|
+
#
|
2140
|
+
# @see https://discord.com/developers/docs/resources/sticker#get-sticker-pack
|
2141
|
+
# Discord documentation "Get Sticker Pack"
|
2142
|
+
def get_sticker_pack(pack_id)
|
2143
|
+
json_request(:get, discord("/sticker-packs/#{pack_id}"))
|
2144
|
+
end
|
2145
|
+
|
2146
|
+
##
|
2147
|
+
# @param guild_id [#to_s] Guild ID
|
2148
|
+
# @macro rResponse
|
2149
|
+
#
|
2150
|
+
# @see https://discord.com/developers/docs/resources/sticker#list-guild-stickers
|
2151
|
+
# Discord documentation "List Guild Stickers"
|
2152
|
+
def list_guild_stickers(guild_id)
|
2153
|
+
json_request(:get, discord("/guilds/#{guild_id}/stickers"))
|
2154
|
+
end
|
2155
|
+
|
2156
|
+
##
|
2157
|
+
# @param guild_id [#to_s] Guild ID
|
2158
|
+
# @param sticker_id [#to_s] Sticker ID
|
2159
|
+
# @macro rResponse
|
2160
|
+
#
|
2161
|
+
# @see https://discord.com/developers/docs/resources/sticker#get-guild-sticker
|
2162
|
+
# Discord documentation "Get Guild Sticker"
|
2163
|
+
def get_guild_sticker(guild_id, sticker_id)
|
2164
|
+
json_request(:get, discord("/guilds/#{guild_id}/stickers/#{sticker_id}"))
|
2165
|
+
end
|
2166
|
+
|
2167
|
+
##
|
2168
|
+
# @param guild_id [#to_s] Guild ID
|
2169
|
+
# @macro pBody
|
2170
|
+
# @macro rResponse
|
2171
|
+
#
|
2172
|
+
# @see https://discord.com/developers/docs/resources/sticker#create-guild-sticker
|
2173
|
+
# Discord documentation "Create Guild Sticker"
|
2174
|
+
def create_guild_sticker(guild_id, body)
|
2175
|
+
json_request(:post, discord("/guilds/#{guild_id}/stickers"), body:)
|
2176
|
+
end
|
2177
|
+
|
2178
|
+
##
|
2179
|
+
# @param guild_id [#to_s] Guild ID
|
2180
|
+
# @param sticker_id [#to_s] Sticker ID
|
2181
|
+
# @macro pBody
|
2182
|
+
# @macro rResponse
|
2183
|
+
#
|
2184
|
+
# @see https://discord.com/developers/docs/resources/sticker#modify-guild-sticker
|
2185
|
+
# Discord documentation "Modify Guild Sticker"
|
2186
|
+
def modify_guild_sticker(guild_id, sticker_id, body)
|
2187
|
+
json_request(:patch, discord("/guilds/#{guild_id}/stickers/#{sticker_id}"), body:)
|
2188
|
+
end
|
2189
|
+
|
2190
|
+
##
|
2191
|
+
# @param guild_id [#to_s] Guild ID
|
2192
|
+
# @param sticker_id [#to_s] Sticker ID
|
2193
|
+
# @macro rResponse
|
2194
|
+
#
|
2195
|
+
# @see https://discord.com/developers/docs/resources/sticker#delete-guild-sticker
|
2196
|
+
# Discord documentation "Delete Guild Sticker"
|
2197
|
+
def delete_guild_sticker(guild_id, sticker_id)
|
2198
|
+
json_request(:delete, discord("/guilds/#{guild_id}/stickers/#{sticker_id}"))
|
2199
|
+
end
|
2200
|
+
|
2201
|
+
### }}} Sticker
|
2202
|
+
|
2203
|
+
### Subscription {{{
|
2204
|
+
|
2205
|
+
##
|
2206
|
+
# @param sku_id [#to_s] SKU ID
|
2207
|
+
# @macro pQuery
|
2208
|
+
# @macro rResponse
|
2209
|
+
#
|
2210
|
+
# @see https://discord.com/developers/docs/resources/subscription#list-sku-subscriptions
|
2211
|
+
# Discord documentation "List SKU Subscriptions"
|
2212
|
+
def list_sku_subscriptions(sku_id, query = {})
|
2213
|
+
json_request(:get, discord("/skus/#{sku_id}/subscriptions"), query:)
|
2214
|
+
end
|
2215
|
+
|
2216
|
+
##
|
2217
|
+
# @param sku_id [#to_s] SKU ID
|
2218
|
+
# @param subscription_id [#to_s] Subscription ID
|
2219
|
+
# @macro rResponse
|
2220
|
+
#
|
2221
|
+
# @see https://discord.com/developers/docs/resources/subscription#get-sku-subscription
|
2222
|
+
# Discord documentation "Get SKU Subscription"
|
2223
|
+
def get_sku_subscription(sku_id, subscription_id)
|
2224
|
+
json_request(:get, discord("/skus/#{sku_id}/subscriptions/#{subscription_id}"))
|
2225
|
+
end
|
2226
|
+
|
2227
|
+
### }}} Subscription
|
2228
|
+
|
2229
|
+
### User {{{
|
2230
|
+
|
2231
|
+
##
|
2232
|
+
# @macro rResponse
|
2233
|
+
#
|
2234
|
+
# @see https://discord.com/developers/docs/resources/user#get-current-user
|
2235
|
+
# Discord documentation "Get Current User"
|
2236
|
+
def get_current_user
|
2237
|
+
json_request(:get, discord("/users/@me"))
|
2238
|
+
end
|
2239
|
+
|
2240
|
+
##
|
2241
|
+
# @param user_id [#to_s] User ID
|
2242
|
+
# @macro rResponse
|
2243
|
+
#
|
2244
|
+
# @see https://discord.com/developers/docs/resources/user#get-user
|
2245
|
+
# Discord documentation "Get User"
|
2246
|
+
def get_user(user_id)
|
2247
|
+
json_request(:get, discord("/users/#{user_id}"))
|
2248
|
+
end
|
2249
|
+
|
2250
|
+
##
|
2251
|
+
# @macro pBody
|
2252
|
+
# @macro rResponse
|
2253
|
+
#
|
2254
|
+
# @see https://discord.com/developers/docs/resources/user#modify-current-user
|
2255
|
+
# Discord documentation "Modify Current User"
|
2256
|
+
def modify_current_user(body)
|
2257
|
+
json_request(:patch, discord("/users/@me"), body:)
|
2258
|
+
end
|
2259
|
+
|
2260
|
+
##
|
2261
|
+
# @macro pQuery
|
2262
|
+
# @macro rResponse
|
2263
|
+
#
|
2264
|
+
# @see https://discord.com/developers/docs/resources/user#get-current-user-guilds
|
2265
|
+
# Discord documentation "Get Current User Guilds"
|
2266
|
+
def get_current_user_guilds(query = {})
|
2267
|
+
json_request(:get, discord("/users/@me/guilds"), query:)
|
2268
|
+
end
|
2269
|
+
|
2270
|
+
##
|
2271
|
+
# @param guild_id [#to_s] Guild ID
|
2272
|
+
# @macro rResponse
|
2273
|
+
#
|
2274
|
+
# @see https://discord.com/developers/docs/resources/user#get-current-user-guild-member
|
2275
|
+
# Discord documentation "Get Current User Guild Member"
|
2276
|
+
def get_current_user_guild_member(guild_id)
|
2277
|
+
json_request(:get, discord("/users/@me/guilds/#{guild_id}/member"))
|
2278
|
+
end
|
2279
|
+
|
2280
|
+
##
|
2281
|
+
# @param guild_id [#to_s] Guild ID
|
2282
|
+
# @macro rResponse
|
2283
|
+
#
|
2284
|
+
# @see https://discord.com/developers/docs/resources/user#leave-guild
|
2285
|
+
# Discord documentation "Leave Guild"
|
2286
|
+
def leave_guild(guild_id)
|
2287
|
+
json_request(:delete, discord("/users/@me/guilds/#{guild_id}"))
|
2288
|
+
end
|
2289
|
+
|
2290
|
+
##
|
2291
|
+
# @macro pBody
|
2292
|
+
# @macro rResponse
|
2293
|
+
#
|
2294
|
+
# @see https://discord.com/developers/docs/resources/user#create-dm
|
2295
|
+
# Discord documentation "Create DM"
|
2296
|
+
def create_dm(body)
|
2297
|
+
json_request(:post, discord("/users/@me/channels"), body:)
|
2298
|
+
end
|
2299
|
+
|
2300
|
+
##
|
2301
|
+
# @macro pBody
|
2302
|
+
# @macro rResponse
|
2303
|
+
#
|
2304
|
+
# @see https://discord.com/developers/docs/resources/user#create-group-dm
|
2305
|
+
# Discord documentation "Create Group DM"
|
2306
|
+
def create_group_dm(body)
|
2307
|
+
json_request(:post, discord("/users/@me/channels"), body:)
|
2308
|
+
end
|
2309
|
+
|
2310
|
+
##
|
2311
|
+
# @macro rResponse
|
2312
|
+
#
|
2313
|
+
# @see https://discord.com/developers/docs/resources/user#get-current-user-connections
|
2314
|
+
# Discord documentation "Get Current User Connections"
|
2315
|
+
def get_current_user_connections
|
2316
|
+
json_request(:get, discord("/users/@me/connections"))
|
2317
|
+
end
|
2318
|
+
|
2319
|
+
##
|
2320
|
+
# @param application_id [#to_s] Application ID
|
2321
|
+
# @macro rResponse
|
2322
|
+
#
|
2323
|
+
# @see https://discord.com/developers/docs/resources/user#get-current-user-application-role-connection
|
2324
|
+
# Discord documentation "Get Current User Application Role Connection"
|
2325
|
+
def get_current_user_application_role_connection(application_id)
|
2326
|
+
json_request(:get, discord("/users/@me/applications/#{application_id}/role-connections"))
|
2327
|
+
end
|
2328
|
+
|
2329
|
+
##
|
2330
|
+
# @param application_id [#to_s] Application ID
|
2331
|
+
# @macro pBody
|
2332
|
+
# @macro rResponse
|
2333
|
+
#
|
2334
|
+
# @see https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection
|
2335
|
+
# Discord documentation "Update Current User Application Role Connection"
|
2336
|
+
def update_current_user_application_role_connection(application_id, body)
|
2337
|
+
json_request(:put, discord("/users/@me/applications/#{application_id}/role-connection"), body:)
|
2338
|
+
end
|
2339
|
+
|
2340
|
+
### }}} User
|
2341
|
+
|
2342
|
+
### Voice {{{
|
2343
|
+
|
2344
|
+
##
|
2345
|
+
# @macro rResponse
|
2346
|
+
#
|
2347
|
+
# @see https://discord.com/developers/docs/resources/voice#list-voice-regions
|
2348
|
+
# Discord documentation "List Voice Regions"
|
2349
|
+
def list_voice_regions
|
2350
|
+
json_request(:get, discord("/voice/regions"))
|
2351
|
+
end
|
2352
|
+
|
2353
|
+
##
|
2354
|
+
# @param guild_id [#to_s] Guild ID
|
2355
|
+
# @macro rResponse
|
2356
|
+
#
|
2357
|
+
# @see https://discord.com/developers/docs/resources/voice#get-current-user-voice-state
|
2358
|
+
# Discord documentation "Get Current User Voice State"
|
2359
|
+
def get_current_user_voice_state(guild_id)
|
2360
|
+
json_request(:get, discord("/guilds/#{guild_id}/voice-states/@me"))
|
2361
|
+
end
|
2362
|
+
|
2363
|
+
##
|
2364
|
+
# @param guild_id [#to_s] Guild ID
|
2365
|
+
# @param user_id [#to_s] User ID
|
2366
|
+
# @macro rResponse
|
2367
|
+
#
|
2368
|
+
# @see https://discord.com/developers/docs/resources/voice#get-user-voice-state
|
2369
|
+
# Discord documentation "Get User Voice State"
|
2370
|
+
def get_user_voice_state(guild_id, user_id)
|
2371
|
+
json_request(:get, discord("/guilds/#{guild_id}/voice-states/#{user_id}"))
|
2372
|
+
end
|
2373
|
+
|
2374
|
+
##
|
2375
|
+
# @param guild_id [#to_s] Guild ID
|
2376
|
+
# @macro pBody
|
2377
|
+
# @macro rResponse
|
2378
|
+
#
|
2379
|
+
# @see https://discord.com/developers/docs/resources/voice#modify-current-user-voice-state
|
2380
|
+
# Discord documentation "Modify Current User Voice State"
|
2381
|
+
def modify_current_user_voice_state(guild_id, body)
|
2382
|
+
json_request(:patch, discord("/guilds/#{guild_id}/voice-states/@me"), body:)
|
2383
|
+
end
|
2384
|
+
|
2385
|
+
##
|
2386
|
+
# @param guild_id [#to_s] Guild ID
|
2387
|
+
# @param user_id [#to_s] User ID
|
2388
|
+
# @macro pBody
|
2389
|
+
# @macro rResponse
|
2390
|
+
#
|
2391
|
+
# @see https://discord.com/developers/docs/resources/voice#modify-user-voice-state
|
2392
|
+
# Discord documentation "Modify User Voice State"
|
2393
|
+
def modify_user_voice_state(guild_id, user_id, body)
|
2394
|
+
json_request(:patch, discord("/guilds/#{guild_id}/voice-states/#{user_id}"), body:)
|
2395
|
+
end
|
2396
|
+
|
2397
|
+
### }}} Voice
|
2398
|
+
|
2399
|
+
### Webhook {{{
|
2400
|
+
|
2401
|
+
##
|
2402
|
+
# @param channel_id [#to_s] Channel ID
|
2403
|
+
# @macro pBody
|
2404
|
+
# @macro rResponse
|
2405
|
+
#
|
2406
|
+
# @see https://discord.com/developers/docs/resources/webhook#create-webhook
|
2407
|
+
# Discord documentation "Create Webhook"
|
2408
|
+
def create_webhook(channel_id, body)
|
2409
|
+
json_request(:post, discord("/channels/#{channel_id}/webhooks"), body:)
|
2410
|
+
end
|
2411
|
+
|
2412
|
+
##
|
2413
|
+
# @param channel_id [#to_s] Channel ID
|
2414
|
+
# @macro rResponse
|
2415
|
+
#
|
2416
|
+
# @see https://discord.com/developers/docs/resources/webhook#get-channel-webhooks
|
2417
|
+
# Discord documentation "Get Channel Webhooks"
|
2418
|
+
def get_channel_webhooks(channel_id)
|
2419
|
+
json_request(:get, discord("/channels/#{channel_id}/webhooks"))
|
2420
|
+
end
|
2421
|
+
|
2422
|
+
##
|
2423
|
+
# @param guild_id [#to_s] Guild ID
|
2424
|
+
# @macro rResponse
|
2425
|
+
#
|
2426
|
+
# @see https://discord.com/developers/docs/resources/webhook#get-guild-webhooks
|
2427
|
+
# Discord documentation "Get Guild Webhooks"
|
2428
|
+
def get_guild_webhooks(guild_id)
|
2429
|
+
json_request(:get, discord("/guilds/#{guild_id}/webhooks"))
|
2430
|
+
end
|
2431
|
+
|
2432
|
+
##
|
2433
|
+
# @param webhook_id [#to_s] Webhook ID
|
2434
|
+
# @macro rResponse
|
2435
|
+
#
|
2436
|
+
# @see https://discord.com/developers/docs/resources/webhook#get-webhook
|
2437
|
+
# Discord documentation "Get Webhook"
|
2438
|
+
def get_webhook(webhook_id)
|
2439
|
+
json_request(:get, discord("/webhooks/#{webhook_id}"))
|
2440
|
+
end
|
2441
|
+
|
2442
|
+
##
|
2443
|
+
# @param webhook_id [#to_s] Webhook ID
|
2444
|
+
# @param webhook_token [#to_s] Webhook Token
|
2445
|
+
# @macro rResponse
|
2446
|
+
#
|
2447
|
+
# @see https://discord.com/developers/docs/resources/webhook#get-webhook-with-token
|
2448
|
+
# Discord documentation "Get Webhook with Token"
|
2449
|
+
def get_webhook_with_token(webhook_id, webhook_token)
|
2450
|
+
json_request(:get, discord("/webhooks/#{webhook_id}/#{webhook_token}"))
|
2451
|
+
end
|
2452
|
+
|
2453
|
+
##
|
2454
|
+
# @param webhook_id [#to_s] Webhook ID
|
2455
|
+
# @macro pBody
|
2456
|
+
# @macro rResponse
|
2457
|
+
#
|
2458
|
+
# @see https://discord.com/developers/docs/resources/webhook#modify-webhook
|
2459
|
+
# Discord documentation "Modify Webhook"
|
2460
|
+
def modify_webhook(webhook_id, body)
|
2461
|
+
json_request(:patch, discord("/webhooks/#{webhook_id}"), body:)
|
2462
|
+
end
|
2463
|
+
|
2464
|
+
##
|
2465
|
+
# @param webhook_id [#to_s] Webhook ID
|
2466
|
+
# @param webhook_token [#to_s] Webhook Token
|
2467
|
+
# @macro pBody
|
2468
|
+
# @macro rResponse
|
2469
|
+
#
|
2470
|
+
# @see https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token
|
2471
|
+
# Discord documentation "Modify Webhook with Token"
|
2472
|
+
def modify_webhook_with_token(webhook_id, webhook_token, body)
|
2473
|
+
json_request(:patch, discord("/webhooks/#{webhook_id}/#{webhook_token}"), body:)
|
2474
|
+
end
|
2475
|
+
|
2476
|
+
##
|
2477
|
+
# @param webhook_id [#to_s] Webhook ID
|
2478
|
+
# @macro rResponse
|
2479
|
+
#
|
2480
|
+
# @see https://discord.com/developers/docs/resources/webhook#delete-webhook
|
2481
|
+
# Discord documentation "Delete Webhook"
|
2482
|
+
def delete_webhook(webhook_id)
|
2483
|
+
json_request(:delete, discord("/webhooks/#{webhook_id}"))
|
2484
|
+
end
|
2485
|
+
|
2486
|
+
##
|
2487
|
+
# @param webhook_id [#to_s] Webhook ID
|
2488
|
+
# @param webhook_token [#to_s] Webhook Token
|
2489
|
+
# @macro rResponse
|
2490
|
+
#
|
2491
|
+
# @see https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token
|
2492
|
+
# Discord documentation "Delete Webhook with Token"
|
2493
|
+
def delete_webhook_with_token(webhook_id, webhook_token)
|
2494
|
+
json_request(:delete, discord("/webhooks/#{webhook_id}/#{webhook_token}"))
|
2495
|
+
end
|
2496
|
+
|
2497
|
+
##
|
2498
|
+
# @param webhook_id [#to_s] Webhook ID
|
2499
|
+
# @param webhook_token [#to_s] Webhook Token
|
2500
|
+
# @macro pBody
|
2501
|
+
# @macro pQuery
|
2502
|
+
# @macro rResponse
|
2503
|
+
#
|
2504
|
+
# @see https://discord.com/developers/docs/resources/webhook#execute-webhook
|
2505
|
+
# Discord documentation "Execute Webhook"
|
2506
|
+
def execute_webhook(webhook_id, webhook_token, body, query = {})
|
2507
|
+
json_request(:post, discord("/webhooks/#{webhook_id}/#{webhook_token}"), body:, query:)
|
2508
|
+
end
|
2509
|
+
|
2510
|
+
##
|
2511
|
+
# @param webhook_id [#to_s] Webhook ID
|
2512
|
+
# @param webhook_token [#to_s] Webhook Token
|
2513
|
+
# @macro pQuery
|
2514
|
+
# @macro rResponse
|
2515
|
+
#
|
2516
|
+
# @see https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook
|
2517
|
+
# Discord documentation "Execute Slack-Compatible Webhook"
|
2518
|
+
def execute_slack_compatible_webhook(webhook_id, webhook_token, query = {})
|
2519
|
+
json_request(:post, discord("/webhooks/#{webhook_id}/#{webhook_token}/slack"), query:)
|
2520
|
+
end
|
2521
|
+
|
2522
|
+
##
|
2523
|
+
# @param webhook_id [#to_s] Webhook ID
|
2524
|
+
# @param webhook_token [#to_s] Webhook Token
|
2525
|
+
# @macro pQuery
|
2526
|
+
# @macro rResponse
|
2527
|
+
#
|
2528
|
+
# @see https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook
|
2529
|
+
# Discord documentation "Execute GitHub-Compatible Webhook
|
2530
|
+
def execute_github_compatible_webhook(webhook_id, webhook_token, query = {})
|
2531
|
+
json_request(:post, discord("/webhooks/#{webhook_id}/#{webhook_token}/github"), query:)
|
2532
|
+
end
|
2533
|
+
|
2534
|
+
##
|
2535
|
+
# @param webhook_id [#to_s] Webhook ID
|
2536
|
+
# @param webhook_token [#to_s] Webhook Token
|
2537
|
+
# @param message_id [#to_s] Message ID
|
2538
|
+
# @macro pQuery
|
2539
|
+
# @macro rResponse
|
2540
|
+
#
|
2541
|
+
# @see https://discord.com/developers/docs/resources/webhook#get-webhook-message
|
2542
|
+
# Discord documentation "Get Webhook Message"
|
2543
|
+
def get_webhook_message(webhook_id, webhook_token, message_id, query = {})
|
2544
|
+
json_request(:get, discord("/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}"), query:)
|
2545
|
+
end
|
2546
|
+
|
2547
|
+
##
|
2548
|
+
# @param webhook_id [#to_s] Webhook ID
|
2549
|
+
# @param webhook_token [#to_s] Webhook Token
|
2550
|
+
# @param message_id [#to_s] Message ID
|
2551
|
+
# @macro pBody
|
2552
|
+
# @macro pQuery
|
2553
|
+
# @macro rResponse
|
2554
|
+
#
|
2555
|
+
# @see https://discord.com/developers/docs/resources/webhook#edit-webhook-message
|
2556
|
+
# Discord documentation "Edit Webhook Message"
|
2557
|
+
def edit_webhook_message(webhook_id, webhook_token, message_id, body, query = {})
|
2558
|
+
json_request(:patch, discord("/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}"), body:, query:)
|
2559
|
+
end
|
2560
|
+
|
2561
|
+
##
|
2562
|
+
# @param webhook_id [#to_s] Webhook ID
|
2563
|
+
# @param webhook_token [#to_s] Webhook Token
|
2564
|
+
# @param message_id [#to_s] Message ID
|
2565
|
+
# @macro rResponse
|
2566
|
+
#
|
2567
|
+
# @see https://discord.com/developers/docs/resources/webhook#delete-webhook-message
|
2568
|
+
# Discord documentation "Delete Webhook Message"
|
2569
|
+
def delete_webhook_message(webhook_id, webhook_token, message_id)
|
2570
|
+
json_request(:delete, discord("/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}"))
|
2571
|
+
end
|
2572
|
+
|
2573
|
+
### }}} Webhook
|
2574
|
+
|
2575
|
+
### OAuth2 {{{
|
2576
|
+
|
2577
|
+
##
|
2578
|
+
# @param user [#to_s] HTTP basic authorization username
|
2579
|
+
# @param pass [#to_s] HTTP basic authorization password
|
2580
|
+
# @macro pQuery
|
2581
|
+
# @macro rResponse
|
2582
|
+
def oauth2_request_token(user, pass, query)
|
2583
|
+
net_request(
|
2584
|
+
:post,
|
2585
|
+
discord("/oauth2/token"),
|
2586
|
+
body: URI.encode_www_form(query),
|
2587
|
+
headers: {
|
2588
|
+
"Authorization" => "Basic " + base64_strictencode("#{user}:#{pass}"),
|
2589
|
+
"Content-Type" => "application/x-www-form-urlencoded"
|
2590
|
+
}
|
2591
|
+
)
|
2592
|
+
end
|
2593
|
+
|
2594
|
+
##
|
2595
|
+
# @param user [#to_s] HTTP basic authorization username
|
2596
|
+
# @param pass [#to_s] HTTP basic authorization password
|
2597
|
+
# @macro pQuery
|
2598
|
+
# @macro rResponse
|
2599
|
+
#
|
2600
|
+
# @see https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-token-revocation-example
|
2601
|
+
# Discord documentation "Token Revocation example"
|
2602
|
+
def oauth2_revoke_token(user, pass, query)
|
2603
|
+
net_request(
|
2604
|
+
:post,
|
2605
|
+
discord("/oauth2/token/revoke"),
|
2606
|
+
body: URI.encode_www_form(query),
|
2607
|
+
headers: {
|
2608
|
+
"Authorization" => "Basic " + base64_strictencode("#{user}:#{pass}"),
|
2609
|
+
"Content-Type" => "application/x-www-form-urlencoded"
|
2610
|
+
}
|
2611
|
+
)
|
2612
|
+
end
|
2613
|
+
|
2614
|
+
##
|
2615
|
+
# Get the URL for starting the OAuth2 Authorization flow.
|
2616
|
+
#
|
2617
|
+
# @macro pQuery
|
2618
|
+
# @return [URI] OAuth2 Authorization URL, with query parameters added.
|
2619
|
+
#
|
2620
|
+
# @see https://discord.com/developers/docs/topics/oauth2#authorization-code-grant
|
2621
|
+
# Discord documentation "Authorization Code Grant"
|
2622
|
+
def get_authorize_url(query = {})
|
2623
|
+
uri = URI(discord("/oauth2/authorize", prefix: ""))
|
2624
|
+
uri.query = URI.encode_www_form(query)
|
2625
|
+
uri
|
2626
|
+
end
|
2627
|
+
|
2628
|
+
##
|
2629
|
+
# Get the URL for installing an application.
|
2630
|
+
#
|
2631
|
+
# @macro pQuery
|
2632
|
+
# @return [URI] Application installation URL, with query parameters added.
|
2633
|
+
#
|
2634
|
+
# @see https://discord.com/developers/docs/resources/application#install-links
|
2635
|
+
# Discord documentation "Install Links"
|
2636
|
+
def get_install_url(query = {}) = get_authorize_url(query)
|
2637
|
+
|
2638
|
+
### }}} OAuth2
|
2639
|
+
|
2640
|
+
private
|
2641
|
+
|
2642
|
+
def base64_strictencode(input) = [input].pack("m0")
|
2643
|
+
|
2644
|
+
def discord(path, prefix: "/api/v10")
|
2645
|
+
[LibDiscord::DISCORD_BASE_URL, prefix, path].join
|
2646
|
+
end
|
2647
|
+
|
2648
|
+
def net_request(verb, path, body: nil, query: {}, headers: {})
|
2649
|
+
uri = URI(path)
|
2650
|
+
uri.query = URI.encode_www_form(query)
|
2651
|
+
headers = @default_headers.merge(headers).compact
|
2652
|
+
|
2653
|
+
@logger.info("lib_discord") { "> #{verb.upcase} #{uri}" }
|
2654
|
+
@logger.debug("lib_discord") do
|
2655
|
+
headers_str = headers.map { |name, value| "#{name}: #{value}" }
|
2656
|
+
"Request headers\n#{headers_str.sort.join("\n")}\n\n" \
|
2657
|
+
"#{body || "( empty body )"}"
|
2658
|
+
end
|
2659
|
+
|
2660
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
2661
|
+
http.use_ssl = uri.instance_of?(URI::HTTPS)
|
2662
|
+
|
2663
|
+
resp = case verb
|
2664
|
+
when :get, :delete
|
2665
|
+
http.public_send(verb, uri.request_uri, headers)
|
2666
|
+
when :post, :put, :patch
|
2667
|
+
http.public_send(verb, uri.request_uri, body.to_s, headers)
|
2668
|
+
else
|
2669
|
+
raise "Invalid HTTP request verb: #{verb}"
|
2670
|
+
end
|
2671
|
+
|
2672
|
+
@logger.info("lib_discord") { "< #{resp.code}" }
|
2673
|
+
@logger.debug("lib_discord") do
|
2674
|
+
headers_str = []
|
2675
|
+
resp.each_capitalized_name do |name|
|
2676
|
+
headers_str << "#{name}: #{resp[name]}"
|
2677
|
+
end
|
2678
|
+
"Response headers\n#{headers_str.sort.join("\n")}\n\n" \
|
2679
|
+
"#{resp.body || "( empty body )"}"
|
2680
|
+
end
|
2681
|
+
|
2682
|
+
parsed = case resp["Content-Type"]
|
2683
|
+
when "application/json"
|
2684
|
+
JSON.parse(resp.body)
|
2685
|
+
end
|
2686
|
+
|
2687
|
+
Response.new(
|
2688
|
+
success?: resp.code.start_with?("2"),
|
2689
|
+
body: resp.body,
|
2690
|
+
parsed:,
|
2691
|
+
code: resp.code,
|
2692
|
+
message: resp.message
|
2693
|
+
)
|
2694
|
+
end
|
2695
|
+
|
2696
|
+
def json_request(verb, path, body: nil, query: {}, headers: {})
|
2697
|
+
headers = {
|
2698
|
+
"Content-Type" => "application/json"
|
2699
|
+
}.merge(headers).compact
|
2700
|
+
|
2701
|
+
net_request(verb, path, body: body&.to_json, query:, headers:)
|
2702
|
+
end
|
2703
|
+
end
|
2704
|
+
|
2705
|
+
##
|
2706
|
+
# A {Response} is returned from any {Client} public instance method call in
|
2707
|
+
# which the HTTP request sent to Discord receives a response.
|
2708
|
+
#
|
2709
|
+
# @!attribute [r] success?
|
2710
|
+
# @return [Boolean] +true+ if the HTTP response code is 2xx, +false+
|
2711
|
+
# otherwise.
|
2712
|
+
# @!attribute [r] body
|
2713
|
+
# @return [String] raw HTTP response body.
|
2714
|
+
# @!attribute [r] parsed
|
2715
|
+
# @return [Object, nil] object representation of the HTTP response body
|
2716
|
+
# parsed with +JSON.parse+ if the HTTP response's content-type is
|
2717
|
+
# +application/json+, +nil+ otherwise.
|
2718
|
+
# @see https://ruby-doc.org/3.4.1/exts/json/JSON.html#method-i-parse
|
2719
|
+
# JSON#parse
|
2720
|
+
# @!attribute [r] code
|
2721
|
+
# @return [String] HTTP response code.
|
2722
|
+
# @!attribute [r] message
|
2723
|
+
# @return [String] HTTP response message.
|
2724
|
+
# @see https://ruby-doc.org/3.4.1/stdlibs/net/Net/HTTPResponse.html
|
2725
|
+
# Net::HTTPResponse
|
2726
|
+
Response = Struct.new(
|
2727
|
+
:success?,
|
2728
|
+
:body,
|
2729
|
+
:parsed,
|
2730
|
+
:code,
|
2731
|
+
:message,
|
2732
|
+
keyword_init: true
|
2733
|
+
)
|
2734
|
+
end
|
2735
|
+
|
2736
|
+
# ex: foldmethod=marker
|