disrb 0.1.2.2 → 0.1.3
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/CHANGELOG.md +88 -0
- data/README.md +16 -5
- data/lib/disrb/application_commands.rb +401 -0
- data/lib/disrb/guild.rb +439 -59
- data/lib/disrb/logger.rb +69 -32
- data/lib/disrb/message.rb +157 -27
- data/lib/disrb/user.rb +74 -7
- data/lib/disrb.rb +218 -397
- metadata +17 -1
data/lib/disrb/guild.rb
CHANGED
|
@@ -1,37 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
# The class that contains everything that interacts with the Discord API.
|
|
3
|
+
# Class that contains functions that allow interacting with the Discord API.
|
|
5
4
|
class DiscordApi
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
output[:name] = name
|
|
11
|
-
unless region.nil?
|
|
12
|
-
@logger.warn('The "region" parameter has been deprecated and should not be used!')
|
|
13
|
-
output[:region] = region
|
|
14
|
-
end
|
|
15
|
-
output[:icon] = icon unless icon.nil?
|
|
16
|
-
output[:verification_level] = verification_level unless verification_level.nil?
|
|
17
|
-
output[:default_message_notifications] = default_message_notifications unless default_message_notifications.nil?
|
|
18
|
-
output[:explicit_content_filter] = explicit_content_filter unless explicit_content_filter.nil?
|
|
19
|
-
output[:roles] = roles unless roles.nil?
|
|
20
|
-
output[:channels] = channels unless channels.nil?
|
|
21
|
-
output[:afk_channel_id] = afk_channel_id unless afk_channel_id.nil?
|
|
22
|
-
output[:afk_timeout] = afk_timeout unless afk_timeout.nil?
|
|
23
|
-
output[:system_channel_id] = system_channel_id unless system_channel_id.nil?
|
|
24
|
-
output[:system_channel_flags] = system_channel_flags unless system_channel_flags.nil?
|
|
25
|
-
url = "#{@base_url}/guilds"
|
|
26
|
-
data = JSON.generate(output)
|
|
27
|
-
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
|
28
|
-
response = DiscordApi.post(url, data, headers)
|
|
29
|
-
return response if response.status == 200
|
|
30
|
-
|
|
31
|
-
@logger.error("Could not create guild. Response: #{response.body}")
|
|
32
|
-
response
|
|
33
|
-
end
|
|
34
|
-
|
|
5
|
+
# Gets a guild object with the specified guild ID. See https://discord.com/developers/docs/resources/guild#get-guild
|
|
6
|
+
# @param guild_id [String] ID (as a string) of the guild to get.
|
|
7
|
+
# @param with_counts [TrueClass, FalseClass, nil] Whether to include approximate member and presence counts.
|
|
8
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
35
9
|
def get_guild(guild_id, with_counts = nil)
|
|
36
10
|
query_string_hash = {}
|
|
37
11
|
query_string_hash[:with_counts] = with_counts unless with_counts.nil?
|
|
@@ -45,6 +19,10 @@ class DiscordApi
|
|
|
45
19
|
response
|
|
46
20
|
end
|
|
47
21
|
|
|
22
|
+
# Gets the guild preview object for the specified guild ID.
|
|
23
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-preview
|
|
24
|
+
# @param guild_id [String] ID (as a string) of the guild to get the preview for.
|
|
25
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
48
26
|
def get_guild_preview(guild_id)
|
|
49
27
|
url = URI("#{@base_url}/guilds/#{guild_id}/preview")
|
|
50
28
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -55,6 +33,40 @@ class DiscordApi
|
|
|
55
33
|
response
|
|
56
34
|
end
|
|
57
35
|
|
|
36
|
+
# Modifies a guild with the specified guild ID. See https://discord.com/developers/docs/resources/guild#modify-guild
|
|
37
|
+
#
|
|
38
|
+
# If none of the optional parameters are provided (guild modifications), the function will log a warning and return
|
|
39
|
+
# nil.
|
|
40
|
+
# @param name [String, nil] The new name of the guild.
|
|
41
|
+
# @param region [String, nil] Guild voice region ID. [DEPRECATED]
|
|
42
|
+
# @param verification_level [Integer, nil] The new verification level of the guild.
|
|
43
|
+
# @param default_message_notifications [Integer, nil] Default message notification level.
|
|
44
|
+
# @param explicit_content_filter [Integer, nil] Explicit content filter level.
|
|
45
|
+
# @param afk_channel_id [String, nil] ID (as a string) of the afk channel.
|
|
46
|
+
# @param afk_timeout [Integer, nil] AFK timeout in seconds. Can be set to; 60, 300, 900, 1800 or 3600.
|
|
47
|
+
# @param icon [String, nil] BASE64-encoded image data to be set as the guild icon.
|
|
48
|
+
# See https://discord.com/developers/docs/reference#image-data. Set this parameter as the Data URI scheme
|
|
49
|
+
# (as a string).
|
|
50
|
+
# @param splash [String, nil] BASE64-encoded image data to be set as the guild splash.
|
|
51
|
+
# See https://discord.com/developers/docs/reference#image-data. Set this parameter as the Data URI scheme
|
|
52
|
+
# (as a string).
|
|
53
|
+
# @param discovery_splash [String, nil] BASE64-encoded image data to be set as the guild discovery splash.
|
|
54
|
+
# See https://discord.com/developers/docs/reference#image-data. Set this parameter as the Data URI scheme
|
|
55
|
+
# (as a string).
|
|
56
|
+
# @param banner [String, nil] BASE64-encoded image data to be set as the guild banner.
|
|
57
|
+
# See https://discord.com/developers/docs/reference#image-data. Set this parameter as the Data URI scheme
|
|
58
|
+
# (as a string).
|
|
59
|
+
# @param system_channel_id [String, nil] ID (as a string) of the channel to be used for guild system messages.
|
|
60
|
+
# @param system_channel_flags [Integer, nil] System channel flags.
|
|
61
|
+
# @param rules_channel_id [String, nil] ID (as a string) of the channel to be used for rules and/or guidelines.
|
|
62
|
+
# @param public_updates_channel_id [String, nil] ID (as a string) of the channel to be used for public updates.
|
|
63
|
+
# @param preferred_locale [String, nil] The preferred locale of a Community guild, default "en-US".
|
|
64
|
+
# @param features [Array, nil] An array of enabled guild features (strings).
|
|
65
|
+
# @param description [String, nil] The description of the guild.
|
|
66
|
+
# @param premium_progress_bar_enabled [TrueClass, FalseClass, nil] Whether the guild's boost progress bar is enabled.
|
|
67
|
+
# @param safety_alerts_channel_id [String, nil] ID (as a string) of the channel to be used for safety alerts.
|
|
68
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if no
|
|
69
|
+
# modifications were provided.
|
|
58
70
|
def modify_guild(guild_id, name: nil, region: nil, verification_level: nil, default_message_notifications: nil,
|
|
59
71
|
explicit_content_filter: nil, afk_channel_id: nil, afk_timeout: nil, icon: nil, owner_id: nil,
|
|
60
72
|
splash: nil, discovery_splash: nil, banner: nil, system_channel_id: nil,
|
|
@@ -111,6 +123,10 @@ class DiscordApi
|
|
|
111
123
|
response
|
|
112
124
|
end
|
|
113
125
|
|
|
126
|
+
# Returns a list of guild channel objects for every channel in the specified guild. Doesn't include threads.
|
|
127
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-channels
|
|
128
|
+
# @param guild_id [String] ID (as a string) of the guild to get the channels for.
|
|
129
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
114
130
|
def get_guild_channels(guild_id)
|
|
115
131
|
url = "#{@base_url}/guilds/#{guild_id}/channels"
|
|
116
132
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -121,6 +137,32 @@ class DiscordApi
|
|
|
121
137
|
response
|
|
122
138
|
end
|
|
123
139
|
|
|
140
|
+
# Creates a new channel in the specified guild. Returns the created channel object.
|
|
141
|
+
# See https://discord.com/developers/docs/resources/guild#create-guild-channel
|
|
142
|
+
# @param guild_id [String] ID (as a string) of the guild to create the channel in.
|
|
143
|
+
# @param name [String] Name of the new channel (1-100 characters)
|
|
144
|
+
# @param topic [String, nil] The channel topic (a.k.a. description) (0-1024 characters)
|
|
145
|
+
# @param bitrate [Integer, nil] Bitrate of the voice or stage channel in bits, min 8000
|
|
146
|
+
# @param user_limit [Integer, nil] User limit of the voice channel
|
|
147
|
+
# @param rate_limit_per_user [Integer, nil] Amount of seconds a user has to wait before sending another message
|
|
148
|
+
# (0-21600)
|
|
149
|
+
# @param position [Integer, nil] Sorting position of the channel (Channels with the same position are sorted by ID)
|
|
150
|
+
# @param permission_overwrites [Array, nil] Array of partial overwrite objects; the channel's permission overwrites
|
|
151
|
+
# @param parent_id [String, nil] ID (as a string) of the parent category for a channel
|
|
152
|
+
# @param nsfw [TrueClass, FalseClass, nil] Whether the channel is NSFW
|
|
153
|
+
# @param rtc_region [String, nil] Channel voice region ID (as string) of the voice or stage channel,
|
|
154
|
+
# set to \"auto\" for automatic region selection
|
|
155
|
+
# @param video_quality_mode [Integer, nil] The camera video quality mode of the voice channel
|
|
156
|
+
# @param default_auto_archive_duration [Integer, nil] The default duration that the clients use for newly created
|
|
157
|
+
# threads in the channel, in minutes, to automatically archive the thread after recent activity
|
|
158
|
+
# @param default_reaction_emoji [Hash, nil] Default reaction object; Emoji to show in the add reaction button on a
|
|
159
|
+
# thread in a forum or media channel
|
|
160
|
+
# @param available_tags [Array, nil] Array of tag objects; set of tags that can be used in a forum or media channel
|
|
161
|
+
# @param default_sort_order [Integer, nil] The default sort order type used to order posts in forum and media channels
|
|
162
|
+
# @param default_forum_layout [Integer, nil] The default forum layout view used to display posts in forum channels
|
|
163
|
+
# @param default_thread_rate_limit_per_user [Integer, nil] The initial rate_limit_per_user to set on newly created
|
|
164
|
+
# threads in a channel. This field is copied to the thread at creation time and does not live update.
|
|
165
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
124
166
|
def create_guild_channel(guild_id, name, type: nil, topic: nil, bitrate: nil, user_limit: nil,
|
|
125
167
|
rate_limit_per_user: nil, position: nil, permission_overwrites: nil, parent_id: nil,
|
|
126
168
|
nsfw: nil, rtc_region: nil, video_quality_mode: nil, default_auto_archive_duration: nil,
|
|
@@ -137,7 +179,13 @@ class DiscordApi
|
|
|
137
179
|
output[:permission_overwrites] = permission_overwrites unless permission_overwrites.nil?
|
|
138
180
|
output[:parent_id] = parent_id unless parent_id.nil?
|
|
139
181
|
output[:nsfw] = nsfw unless nsfw.nil?
|
|
140
|
-
|
|
182
|
+
unless rtc_region.nil?
|
|
183
|
+
output[:rtc_region] = if rtc_region == 'auto'
|
|
184
|
+
nil
|
|
185
|
+
else
|
|
186
|
+
rtc_region
|
|
187
|
+
end
|
|
188
|
+
end
|
|
141
189
|
output[:video_quality_mode] = video_quality_mode unless video_quality_mode.nil?
|
|
142
190
|
output[:default_auto_archive_duration] = default_auto_archive_duration unless default_auto_archive_duration.nil?
|
|
143
191
|
output[:default_reaction_emoji] = default_reaction_emoji unless default_reaction_emoji.nil?
|
|
@@ -158,17 +206,53 @@ class DiscordApi
|
|
|
158
206
|
response
|
|
159
207
|
end
|
|
160
208
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
209
|
+
# Modify the positions of a set of channel objects for the guild. Returns 204 No Content on success.
|
|
210
|
+
# See https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
|
|
211
|
+
# @param guild_id [String] ID (as a string) of the guild to modify the channel positions for.
|
|
212
|
+
# @param data [Hash] A hash where the keys are channel IDs (as symbols) and the values are another hash formed of keys
|
|
213
|
+
# that are either:
|
|
214
|
+
# - :position (Integer) sorting position of the channel (channels with the same position are sorted by ID)
|
|
215
|
+
# - :lock_permissions (TrueClass, FalseClass) whether to sync the permission overwrites with the new parent
|
|
216
|
+
# category, if moving to a different one. If this is provided but :parent_id isnt, this will be dropped from the
|
|
217
|
+
# request
|
|
218
|
+
# - :parent_id (String) ID (as a string) of the new parent category for a channel
|
|
219
|
+
# Example:
|
|
220
|
+
# { :1395365491005980814 => { :position => 0, :lock_permissions => false, :parent_id => "1395365491005980825" },
|
|
221
|
+
# 1389464920227319879 => { :position => 1 }}
|
|
222
|
+
#
|
|
223
|
+
# If no modifications are provided for a channel, that channel will be dropped, please note that :lock_permissions
|
|
224
|
+
# can be dropped, and this affects if it gets dropped
|
|
225
|
+
#
|
|
226
|
+
# And if the entire data hash is empty (after dropping channels with no modifications), the entire function will be
|
|
227
|
+
# skipped and will return nil
|
|
228
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if no
|
|
229
|
+
# modifications were provided
|
|
230
|
+
def modify_guild_channel_positions(guild_id, data)
|
|
231
|
+
output = []
|
|
232
|
+
data.each do |channel_id, modification|
|
|
233
|
+
channel_modification = {}
|
|
234
|
+
channel_modification[:id] = channel_id
|
|
235
|
+
channel_modification[:position] = modification[:position] if modification.include?(:position)
|
|
236
|
+
channel_modification[:lock_permissions] = modification[:lock_permissions] if modification
|
|
237
|
+
.include?(:lock_permissions)
|
|
238
|
+
channel_modification[:parent_id] = modification[:parent_id] if modification.include?(:parent_id)
|
|
239
|
+
if (channel_modification.keys - %i[id lock_permissions position]).empty? &&
|
|
240
|
+
!channel_modification.key?(:parent_id)
|
|
241
|
+
@logger.warn('lock_permissions has been specified, but parent_id hasn\'t. Dropping lock_permissions from ' \
|
|
242
|
+
'data.')
|
|
243
|
+
channel_modification.delete(:lock_permissions)
|
|
244
|
+
end
|
|
245
|
+
if channel_modification.empty?
|
|
246
|
+
@logger.warn("No channel position modifications provided for channel with ID #{channel_id}. Skipping channel" \
|
|
247
|
+
' position modification.')
|
|
248
|
+
else
|
|
249
|
+
output << channel_modification
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
if output.empty?
|
|
253
|
+
@logger.warn("No channel position modifications provided for guild with ID #{guild_id}. Skipping function.")
|
|
165
254
|
return nil
|
|
166
255
|
end
|
|
167
|
-
output = {}
|
|
168
|
-
output[:id] = channel_id
|
|
169
|
-
output[:position] = position unless position.nil?
|
|
170
|
-
output[:lock_permissions] = lock_permissions unless lock_permissions.nil?
|
|
171
|
-
output[:parent_id] = parent_id unless parent_id.nil?
|
|
172
256
|
url = "#{@base_url}/guilds/#{guild_id}/channels"
|
|
173
257
|
data = JSON.generate(output)
|
|
174
258
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
|
@@ -179,6 +263,9 @@ class DiscordApi
|
|
|
179
263
|
response
|
|
180
264
|
end
|
|
181
265
|
|
|
266
|
+
# Returns a list of active threads in the specified guild.See https://discord.com/developers/docs/resources/guild#list-active-guild-threads
|
|
267
|
+
# @param guild_id [String] ID (as a string) of the guild to list active threads for.
|
|
268
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
182
269
|
def list_active_guild_threads(guild_id)
|
|
183
270
|
url = "#{@base_url}/guilds/#{guild_id}/threads/active"
|
|
184
271
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -189,6 +276,10 @@ class DiscordApi
|
|
|
189
276
|
response
|
|
190
277
|
end
|
|
191
278
|
|
|
279
|
+
# Returns a guild member object for the specified user in the specified guild. See https://discord.com/developers/docs/resources/guild#get-guild-member
|
|
280
|
+
# @param guild_id [String] ID (as a string) of the guild to get the member from.
|
|
281
|
+
# @param user_id [String] ID (as a string) of the user to get the member object for.
|
|
282
|
+
# @return [Faraday::Response] The response from the DiscordApi as a Faraday::Response object.
|
|
192
283
|
def get_guild_member(guild_id, user_id)
|
|
193
284
|
url = "#{@base_url}/guilds/#{guild_id}/members/#{user_id}"
|
|
194
285
|
headers = { 'Authorization' => @authorization_header }
|
|
@@ -200,6 +291,11 @@ class DiscordApi
|
|
|
200
291
|
response
|
|
201
292
|
end
|
|
202
293
|
|
|
294
|
+
# Returns an array of guild member objects for the specified guild. See https://discord.com/developers/docs/resources/guild#list-guild-members
|
|
295
|
+
# @param guild_id [String] ID (as a string) of the guild to list the members for.
|
|
296
|
+
# @param limit [Integer, nil] Maximum number of members to return (1-100). Default: 1
|
|
297
|
+
# @param after [String, nil] Get users after this user ID (as a string)
|
|
298
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
203
299
|
def list_guild_members(guild_id, limit: nil, after: nil)
|
|
204
300
|
query_string_hash = {}
|
|
205
301
|
query_string_hash[:limit] = limit unless limit.nil?
|
|
@@ -214,6 +310,11 @@ class DiscordApi
|
|
|
214
310
|
response
|
|
215
311
|
end
|
|
216
312
|
|
|
313
|
+
# Returns an array of guild member objects whose username/nickname match the query. See https://discord.com/developers/docs/resources/guild#search-guild-members
|
|
314
|
+
# @param guild_id [String] ID (as a string) of the guild to search the members in
|
|
315
|
+
# @param query [String] Query string to match usernames and nicknames against.
|
|
316
|
+
# @param limit [Integer, nil] Maximum number of members to return (1-1000). Default: 1
|
|
317
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
217
318
|
def search_guild_members(guild_id, query, limit = nil)
|
|
218
319
|
query_string_hash = {}
|
|
219
320
|
query_string_hash[:query] = query
|
|
@@ -228,6 +329,17 @@ class DiscordApi
|
|
|
228
329
|
response
|
|
229
330
|
end
|
|
230
331
|
|
|
332
|
+
# Adds a user to the specified guild. Returns 201 Created with the body being the Guild Member object of the added
|
|
333
|
+
# user or 204 No Content if the user is already in the guild. See https://discord.com/developers/docs/resources/guild#add-guild-member
|
|
334
|
+
# @param guild_id [String] ID (as a string) of the guild to add the user to
|
|
335
|
+
# @param user_id [String] ID (as a string) of the user to add to the guild
|
|
336
|
+
# @param access_token [String] A valid OAuth2 access token with the guilds.join scope created by the user you want to
|
|
337
|
+
# add to the guild for the bot that is adding the user
|
|
338
|
+
# @param roles [Array, nil] Array of role IDs (as strings) the user will be assigned
|
|
339
|
+
# @param nick [String, nil] String to set the user's nickname to
|
|
340
|
+
# @param mute [TrueClass, FalseClass, nil] Whether the user is muted in voice channels
|
|
341
|
+
# @param deaf [TrueClass, FalseClass, nil] Whether the user is deafened in voice channels
|
|
342
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
231
343
|
def add_guild_member(guild_id, user_id, access_token, nick: nil, roles: nil, mute: nil, deaf: nil)
|
|
232
344
|
output = {}
|
|
233
345
|
output[:access_token] = access_token
|
|
@@ -249,6 +361,25 @@ class DiscordApi
|
|
|
249
361
|
response
|
|
250
362
|
end
|
|
251
363
|
|
|
364
|
+
# Modifies a user in the specified guild. Returns 200 OK with the new Guild Member object.
|
|
365
|
+
# See https://discord.com/developers/docs/resources/guild#modify-guild-member
|
|
366
|
+
#
|
|
367
|
+
# If none of the optional parameters are provided (member modifications), the function will log a warning, no request
|
|
368
|
+
# will be made to Discord, and the function will return nil. (note that audit_reason doesn't count)
|
|
369
|
+
# @param guild_id [String] ID (as a string) of the guild to modify the member in
|
|
370
|
+
# @param user_id [String] ID (as a string) of the user to modify
|
|
371
|
+
# @param nick [String, nil] Value to set the user's nickname to.
|
|
372
|
+
# @param roles [Array, nil] Array of role IDs (as strings) the user will be assigned.
|
|
373
|
+
# @param mute [TrueClass, FalseClass, nil] Whether the user is muted in voice channels.
|
|
374
|
+
# @param deaf [TrueClass, FalseClass, nil] Whether the user is deafened in voice channels.
|
|
375
|
+
# @param channel_id [String, nil] ID (as a string) of the ID of a voice channel to move the user to (if the user is in
|
|
376
|
+
# a voice channel).
|
|
377
|
+
# @param communication_disabled_until [String, FalseClass, nil] When the user's timeout will expire (up to 28 days in
|
|
378
|
+
# the future) in ISO8601 format, or false to remove timeout.
|
|
379
|
+
# @param flags [Integer, nil] New guild member flags.
|
|
380
|
+
# @param audit_reason [String, nil] Reason for the modification, shows up on the audit log entry.
|
|
381
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if no
|
|
382
|
+
# modifications were provided.
|
|
252
383
|
def modify_guild_member(guild_id, user_id, nick: nil, roles: nil, mute: nil, deaf: nil, channel_id: nil,
|
|
253
384
|
communication_disabled_until: nil, flags: nil, audit_reason: nil)
|
|
254
385
|
if args[2..-2].all?(&:nil?)
|
|
@@ -262,7 +393,11 @@ class DiscordApi
|
|
|
262
393
|
output[:mute] = mute unless mute.nil?
|
|
263
394
|
output[:deaf] = deaf unless deaf.nil?
|
|
264
395
|
output[:channel_id] = channel_id unless channel_id.nil?
|
|
265
|
-
|
|
396
|
+
if communication_disabled_until == false
|
|
397
|
+
output[:communication_disabled_until] = nil
|
|
398
|
+
elsif !communication_disabled_until.nil?
|
|
399
|
+
output[:communication_disabled_until] = communication_disabled_until
|
|
400
|
+
end
|
|
266
401
|
output[:flags] = flags unless flags.nil?
|
|
267
402
|
url = "#{@base_url}/guilds/#{guild_id}/members/#{user_id}"
|
|
268
403
|
data = JSON.generate(output)
|
|
@@ -276,15 +411,33 @@ class DiscordApi
|
|
|
276
411
|
response
|
|
277
412
|
end
|
|
278
413
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
414
|
+
# Modifies the current member in the specified guild. Returns 200 OK with the new Guild Member object.
|
|
415
|
+
# See https://discord.com/developers/docs/resources/guild#modify-current-member
|
|
416
|
+
#
|
|
417
|
+
# If none of the optional parameters are provided (member modifications), the function will log a warning,
|
|
418
|
+
# no request will be made to Discord, and the function will return nil. (note that audit_reason doesn't count)
|
|
419
|
+
# @param guild_id [String] ID (as a string) of the guild to modify the current member in
|
|
420
|
+
# @param nick [String, nil] Value to set the user's name to in the guild.
|
|
421
|
+
# @param banner [String, nil] Data URI scheme with BASE64-encoded image data to set as the user's banner in the guild.
|
|
422
|
+
# See https://discord.com/developers/docs/reference#image-data
|
|
423
|
+
# @param avatar [String, nil] Data URI scheme with BASE64-encoded image data to set as the user's avatar in the guild.
|
|
424
|
+
# See https://discord.com/developers/docs/reference#image-data
|
|
425
|
+
# @param bio [String, nil] Value to set the user's bio to in the guild.
|
|
426
|
+
# @param audit_reason [String, nil] Reason for the modification, shows up on the audit log entry.
|
|
427
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if no
|
|
428
|
+
# modifications were provided.
|
|
429
|
+
def modify_current_member(guild_id, nick: nil, banner: nil, avatar: nil, bio: nil, audit_reason: nil)
|
|
284
430
|
output = {}
|
|
285
431
|
output[:nick] = nick unless nick.nil?
|
|
432
|
+
output[:banner] = banner unless banner.nil?
|
|
433
|
+
output[:avatar] = avatar unless avatar.nil?
|
|
434
|
+
output[:bio] = bio unless bio.nil?
|
|
286
435
|
url = "#{@base_url}/guilds/#{guild_id}/members/@me"
|
|
287
436
|
data = JSON.generate(output)
|
|
437
|
+
if data.empty?
|
|
438
|
+
@logger.warn("No modifications for current member in guild ID #{guild_id} provided. Skipping.")
|
|
439
|
+
return nil
|
|
440
|
+
end
|
|
288
441
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
|
289
442
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
|
290
443
|
response = DiscordApi.patch(url, data, headers)
|
|
@@ -294,12 +447,15 @@ class DiscordApi
|
|
|
294
447
|
response
|
|
295
448
|
end
|
|
296
449
|
|
|
297
|
-
|
|
450
|
+
# THIS ENDPOINT HAS BEEN DEPRECATED AND SHOULD NOT BE USED, PLEASE USE {DiscordApi#modify_current_member} INSTEAD!
|
|
451
|
+
# Modifies the current user's nickname in the specified guild. Returns 200 OK with the new nickname.
|
|
452
|
+
# See https://discord.com/developers/docs/resources/guild#modify-current-user-nick
|
|
453
|
+
# @param guild_id [String] ID (as a string) of the guild to modify the current user's nickname in
|
|
454
|
+
# @param nick [String] Value to set the user's nickname to in the specified guild.
|
|
455
|
+
# @param audit_reason [String, nil] Reason for the modification, shows up on the audit log entry.
|
|
456
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
457
|
+
def modify_current_user_nick(guild_id, nick, audit_reason: nil)
|
|
298
458
|
@logger.warn('The "Modify Current User Nick" endpoint has been deprecated and should not be used!')
|
|
299
|
-
if nick.nil?
|
|
300
|
-
@logger.warn("No modifications for current user nick in guild ID #{guild_id} provided. Skipping.")
|
|
301
|
-
return nil
|
|
302
|
-
end
|
|
303
459
|
output = {}
|
|
304
460
|
output[:nick] = nick unless nick.nil?
|
|
305
461
|
url = "#{@base_url}/guilds/#{guild_id}/users/@me/nick"
|
|
@@ -313,6 +469,13 @@ class DiscordApi
|
|
|
313
469
|
response
|
|
314
470
|
end
|
|
315
471
|
|
|
472
|
+
# Adds a role to a guild member. Returns 204 No Content on success.
|
|
473
|
+
# See https://discord.com/developers/docs/resources/guild#add-guild-member-role
|
|
474
|
+
# @param guild_id [String] ID (as a string) of the guild to add the role to the member in
|
|
475
|
+
# @param user_id [String] ID (as a string) of the user to add the role to
|
|
476
|
+
# @param role_id [String] ID (as a string) of the role to add to the user
|
|
477
|
+
# @param audit_reason [String, nil] Reason for the modification, shows up on the audit log entry.
|
|
478
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
316
479
|
def add_guild_member_role(guild_id, user_id, role_id, audit_reason = nil)
|
|
317
480
|
url = "#{@base_url}/guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}"
|
|
318
481
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -325,6 +488,13 @@ class DiscordApi
|
|
|
325
488
|
response
|
|
326
489
|
end
|
|
327
490
|
|
|
491
|
+
# Removes a role from a guild member. Returns 204 No Content on success.
|
|
492
|
+
# See https://discord.com/developers/docs/resources/guild#remove-guild-member-role
|
|
493
|
+
# @param guild_id [String] ID (as a string) of the guild to remove the role from the member in
|
|
494
|
+
# @param user_id [String] ID (as a string) of the user to remove the role from
|
|
495
|
+
# @param role_id [String] ID (as a string) of the role to remove from the user
|
|
496
|
+
# @param audit_reason [String, nil] Reason for the modification, shows up on the audit log entry.
|
|
497
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
328
498
|
def remove_guild_member_role(guild_id, user_id, role_id, audit_reason = nil)
|
|
329
499
|
url = "#{@base_url}/guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}"
|
|
330
500
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -337,6 +507,12 @@ class DiscordApi
|
|
|
337
507
|
response
|
|
338
508
|
end
|
|
339
509
|
|
|
510
|
+
# Removes a member from a guild. Returns 204 No Content on success.
|
|
511
|
+
# See https://discord.com/developers/docs/resources/guild#remove-guild-member
|
|
512
|
+
# @param guild_id [String] ID (as a string) of the guild to remove the member from
|
|
513
|
+
# @param user_id [String] ID (as a string) of the user to remove from the guild
|
|
514
|
+
# @param audit_reason [String, nil] Reason for the kick, shows up on the audit log entry.
|
|
515
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
340
516
|
def remove_guild_member(guild_id, user_id, audit_reason = nil)
|
|
341
517
|
url = "#{@base_url}/guilds/#{guild_id}/members/#{user_id}"
|
|
342
518
|
headers = { 'Authorization' => @authorization_header }
|
|
@@ -348,6 +524,13 @@ class DiscordApi
|
|
|
348
524
|
response
|
|
349
525
|
end
|
|
350
526
|
|
|
527
|
+
# Returns a list of ban objects for users banned from the specified guild.
|
|
528
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-bans
|
|
529
|
+
# @param guild_id [String] ID (as a string) of the guild to get the bans from.
|
|
530
|
+
# @param limit [Integer, nil] Maximum number of bans to return (1-1000)
|
|
531
|
+
# @param before [String, nil] Get bans before this user ID (as a string)
|
|
532
|
+
# @param after [String, nil] Get bans after this user ID (as a string)
|
|
533
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
351
534
|
def get_guild_bans(guild_id, limit: nil, before: nil, after: nil)
|
|
352
535
|
query_string_hash = {}
|
|
353
536
|
query_string_hash[:limit] = limit unless limit.nil?
|
|
@@ -363,6 +546,11 @@ class DiscordApi
|
|
|
363
546
|
response
|
|
364
547
|
end
|
|
365
548
|
|
|
549
|
+
# Returns a ban object for the specified user in the specified guild. Returns 404 Not Found if the user is not banned.
|
|
550
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-ban
|
|
551
|
+
# @param guild_id [String] ID (as a string) of the guild to get the ban from
|
|
552
|
+
# @param user_id [String] ID (as a string) of the user to get the ban object for
|
|
553
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
366
554
|
def get_guild_ban(guild_id, user_id)
|
|
367
555
|
url = "#{@base_url}/guilds/#{guild_id}/bans/#{user_id}"
|
|
368
556
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -378,6 +566,15 @@ class DiscordApi
|
|
|
378
566
|
response
|
|
379
567
|
end
|
|
380
568
|
|
|
569
|
+
# Bans the specified user from the specified guild. Returns 204 No Content on success.
|
|
570
|
+
# See https://discord.com/developers/docs/resources/guild#create-guild-ban
|
|
571
|
+
# @param guild_id [String] ID (as a string) of the guild to ban the user from
|
|
572
|
+
# @param user_id [String] ID (as a string) of the user to ban from the guild
|
|
573
|
+
# @param delete_message_days [Integer, nil] Number of days to delete messages for (0-7) (DEPRECATED, use
|
|
574
|
+
# delete_message_seconds instead)
|
|
575
|
+
# @param delete_message_seconds [Integer, nil] Number of seconds to delete messages for (0-604800) (604800s=7d)
|
|
576
|
+
# @param audit_reason [String, nil] Reason for the ban, shows up on the audit log entry.
|
|
577
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
381
578
|
def create_guild_ban(guild_id, user_id, delete_message_days: nil, delete_message_seconds: nil, audit_reason: nil)
|
|
382
579
|
output = {}
|
|
383
580
|
unless delete_message_days.nil?
|
|
@@ -397,6 +594,12 @@ class DiscordApi
|
|
|
397
594
|
response
|
|
398
595
|
end
|
|
399
596
|
|
|
597
|
+
# Unbans the specified user from the specified guild. Returns 204 No Content on success.
|
|
598
|
+
# See https://discord.com/developers/docs/resources/guild#remove-guild-ban
|
|
599
|
+
# @param guild_id [String] ID (as a string) of the guild to unban the user from
|
|
600
|
+
# @param user_id [String] ID (as a string) of the user to unban from the guild
|
|
601
|
+
# @param audit_reason [String, nil] Reason for the unban, shows up on the audit log entry.
|
|
602
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
400
603
|
def remove_guild_ban(guild_id, user_id, audit_reason = nil)
|
|
401
604
|
url = "#{@base_url}/guilds/#{guild_id}/bans/#{user_id}"
|
|
402
605
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -409,6 +612,14 @@ class DiscordApi
|
|
|
409
612
|
response
|
|
410
613
|
end
|
|
411
614
|
|
|
615
|
+
# Ban up to 200 users from a guild in a single request. Returns 200 OK with an array of the banned user IDs and the
|
|
616
|
+
# users that couldn't be banned if atleast one user has been banned successfully.
|
|
617
|
+
# See https://discord.com/developers/docs/resources/guild#bulk-guild-ban
|
|
618
|
+
# @param guild_id [String] ID (as a string) of the guild to bulk ban users from
|
|
619
|
+
# @param user_ids [Array] Array of user IDs (as strings) to ban from the specified guild (max 200)
|
|
620
|
+
# @param delete_message_seconds [Integer, nil] Number of seconds to delete messages for (0-604800) (604800s=7d)
|
|
621
|
+
# @param audit_reason [String, nil] Reason for the bulk ban, shows up on the audit log entry.
|
|
622
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object
|
|
412
623
|
def bulk_guild_ban(guild_id, user_ids, delete_message_seconds: nil, audit_reason: nil)
|
|
413
624
|
output = {}
|
|
414
625
|
output[:user_ids] = user_ids unless user_ids.nil?
|
|
@@ -428,6 +639,10 @@ class DiscordApi
|
|
|
428
639
|
response
|
|
429
640
|
end
|
|
430
641
|
|
|
642
|
+
# Returns a list of role objects for the specified guild.
|
|
643
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-roles
|
|
644
|
+
# @param guild_id [String] ID (as a string) of the guild to get the roles from.
|
|
645
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
431
646
|
def get_guild_roles(guild_id)
|
|
432
647
|
url = "#{@base_url}/guilds/#{guild_id}/roles"
|
|
433
648
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -438,6 +653,11 @@ class DiscordApi
|
|
|
438
653
|
response
|
|
439
654
|
end
|
|
440
655
|
|
|
656
|
+
# Returns the role object for the specified role in the specified guild.
|
|
657
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-role
|
|
658
|
+
# @param guild_id [String] ID (as a string) of the guild to get the role from.
|
|
659
|
+
# @param role_id [String] ID (as a string) of the role to get.
|
|
660
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
441
661
|
def get_guild_role(guild_id, role_id)
|
|
442
662
|
url = "#{@base_url}/guilds/#{guild_id}/roles/#{role_id}"
|
|
443
663
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -448,6 +668,21 @@ class DiscordApi
|
|
|
448
668
|
response
|
|
449
669
|
end
|
|
450
670
|
|
|
671
|
+
# Creates a new role in the specified guild. Returns 200 OK with the new role object.
|
|
672
|
+
# See https://discord.com/developers/docs/resources/guild#create-guild-role
|
|
673
|
+
# @param guild_id [String] ID (as a string) of the guild to create the role in
|
|
674
|
+
# @param name [String, nil] Name of the role (default: "new role")
|
|
675
|
+
# @param permissions [String, nil] Bitwise value of the permissions for the role (default: @everyone permissions)
|
|
676
|
+
# @param color [Integer, nil] (DEPRECATED, USE colors INSTEAD) RGB color value for the role (default: 0)
|
|
677
|
+
# @param colors [Hash, nil] Role colors object
|
|
678
|
+
# @param hoist [TrueClass, FalseClass, nil] Whether the role should be displayed separately in the sidebar
|
|
679
|
+
# (default: false)
|
|
680
|
+
# @param icon [String, nil] URI-encoded base64 image data for the role icon (default: nil)
|
|
681
|
+
# @param unicode_emoji [String, nil] The role's unicode emoji as a standard emoji (default: nil)
|
|
682
|
+
# @param mentionable [TrueClass, FalseClass, nil] Whether the role should be able to be mentioned by @everyone
|
|
683
|
+
# (default: false)
|
|
684
|
+
# @param audit_reason [String, nil] Reason for the creation, shows up on the audit log entry.
|
|
685
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
451
686
|
def create_guild_role(guild_id, name: nil, permissions: nil, color: nil, colors: nil, hoist: nil, icon: nil,
|
|
452
687
|
unicode_emoji: nil, mentionable: nil, audit_reason: nil)
|
|
453
688
|
output = {}
|
|
@@ -473,16 +708,24 @@ class DiscordApi
|
|
|
473
708
|
response
|
|
474
709
|
end
|
|
475
710
|
|
|
476
|
-
|
|
477
|
-
|
|
711
|
+
# Modifies the position of a set of role objects in the specified guild. Returns 200 OK with an array of all of the
|
|
712
|
+
# modified role objects on success.
|
|
713
|
+
# See https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
|
|
714
|
+
# @param guild_id [String] ID (as a string) of the guild to modify the role positions in
|
|
715
|
+
# @param role_positions [Array] Array of objects (hashes) with "id" and "position" keys
|
|
716
|
+
# with "id" being the role ID (as a string) and "position" being the sorting position of the role
|
|
717
|
+
# (roles with the same position are sorted by id), if this array is empty, a warning will be logged
|
|
718
|
+
# and the function will be skipped, return nil. (no request will be made to discord)
|
|
719
|
+
# @param audit_reason [String, nil] Reason for the modification, shows up on the audit log entry.
|
|
720
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if
|
|
721
|
+
# role_positions was empty.
|
|
722
|
+
def modify_guild_role_positions(guild_id, role_positions, audit_reason: nil)
|
|
723
|
+
if role_positions.empty?
|
|
478
724
|
@logger.warn("No role positions provided for guild with ID #{guild_id}. Skipping function.")
|
|
479
725
|
return nil
|
|
480
726
|
end
|
|
481
|
-
output = {}
|
|
482
|
-
output[:id] = id
|
|
483
|
-
output[:position] = position unless position.nil?
|
|
484
727
|
url = "#{@base_url}/guilds/#{guild_id}/roles"
|
|
485
|
-
data = JSON.generate(
|
|
728
|
+
data = JSON.generate(role_positions)
|
|
486
729
|
headers = { 'Authorization': @authorization_header, 'Content-Type': 'application/json' }
|
|
487
730
|
headers['X-Audit-Log-Reason'] = audit_reason unless audit_reason.nil?
|
|
488
731
|
response = DiscordApi.patch(url, data, headers)
|
|
@@ -492,6 +735,21 @@ class DiscordApi
|
|
|
492
735
|
response
|
|
493
736
|
end
|
|
494
737
|
|
|
738
|
+
# Modifies a guild role. Returns 200 OK with the modified role object, or nil if no modifications were provided.
|
|
739
|
+
# See https://discord.com/developers/docs/resources/guild#modify-guild-role
|
|
740
|
+
# @param guild_id [String] ID (as a string) of the guild the role to modify is in
|
|
741
|
+
# @param role_id [String] ID (as a string) of the role to modify
|
|
742
|
+
# @param name [String, nil] New name of the role
|
|
743
|
+
# @param permissions [String, nil] New bitwise value of the permissions for the role
|
|
744
|
+
# @param color [Integer, nil] (DEPRECATED, USE colors INSTEAD) New RGB color value for the role
|
|
745
|
+
# @param colors [Hash, nil] New role colors object
|
|
746
|
+
# @param hoist [TrueClass, FalseClass, nil] Whether the role should be displayed separately in the sidebar
|
|
747
|
+
# @param icon [String, nil] URI-encoded base64 image data for the role icon
|
|
748
|
+
# @param unicode_emoji [String, nil] The role's unicode emoji as a standard emoji
|
|
749
|
+
# @param mentionable [TrueClass, FalseClass, nil] Whether the role should be able to be mentioned by @everyone
|
|
750
|
+
# @param audit_reason [String, nil] Reason for the modification, shows up on the audit log entry.
|
|
751
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if no
|
|
752
|
+
# modifications were provided.
|
|
495
753
|
def modify_guild_role(guild_id, role_id, name: nil, permissions: nil, color: nil, hoist: nil, icon: nil,
|
|
496
754
|
unicode_emoji: nil, mentionable: nil, audit_reason: nil)
|
|
497
755
|
if args[2..-2].all?(&:nil?)
|
|
@@ -519,6 +777,12 @@ class DiscordApi
|
|
|
519
777
|
response
|
|
520
778
|
end
|
|
521
779
|
|
|
780
|
+
# Modifies the MFA level required for a guild. Returns 200 OK on success.
|
|
781
|
+
# @param guild_id [String] ID (as a string) of the guild to modify the MFA level for
|
|
782
|
+
# @param level [Integer] The MFA level to set for the guild, can be 0 (no MFA required) or 1 (MFA required for
|
|
783
|
+
# administrative actions)
|
|
784
|
+
# @param audit_reason [String, nil] Reason for the modification, shows up on the audit log entry.
|
|
785
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
522
786
|
def modify_guild_mfa_level(guild_id, level, audit_reason = nil)
|
|
523
787
|
output = {}
|
|
524
788
|
output[:level] = level
|
|
@@ -533,6 +797,12 @@ class DiscordApi
|
|
|
533
797
|
response
|
|
534
798
|
end
|
|
535
799
|
|
|
800
|
+
# Deletes a guild role. Returns 204 No Content on success.
|
|
801
|
+
# See https://discord.com/developers/docs/resources/guild#delete-guild-role
|
|
802
|
+
# @param guild_id [String] ID (as a string) of the guild the role to delete is in
|
|
803
|
+
# @param role_id [String] ID (as a string) of the role to delete
|
|
804
|
+
# @param audit_reason [String, nil] Reason for the deletion of the role, shows up in the audit log
|
|
805
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
536
806
|
def delete_guild_role(guild_id, role_id, audit_reason = nil)
|
|
537
807
|
url = "#{@base_url}/guilds/#{guild_id}/roles/#{role_id}"
|
|
538
808
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -544,6 +814,13 @@ class DiscordApi
|
|
|
544
814
|
response
|
|
545
815
|
end
|
|
546
816
|
|
|
817
|
+
# Returns a JSON object with a 'pruned' key indicating the number of members that would be removed in a prune
|
|
818
|
+
# operation with status code 200 OK. See https://discord.com/developers/docs/resources/guild#get-guild-prune-count
|
|
819
|
+
# @param guild_id [String] ID (as a string) of the guild to get the prune count for
|
|
820
|
+
# @param days [Integer, nil] Number of days to count prune for (1-30)
|
|
821
|
+
# @param include_roles [String, nil] Comma-delimited list of role IDs (as strings), these roles will also be included
|
|
822
|
+
# in the prune count
|
|
823
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
547
824
|
def get_guild_prune_count(guild_id, days: nil, include_roles: nil)
|
|
548
825
|
query_string_hash = {}
|
|
549
826
|
query_string_hash[:days] = days unless days.nil?
|
|
@@ -558,6 +835,18 @@ class DiscordApi
|
|
|
558
835
|
response
|
|
559
836
|
end
|
|
560
837
|
|
|
838
|
+
# Begins a guild prune operation. Returns 200 OK with a JSON object containing a 'pruned' key
|
|
839
|
+
# (optional, enabled by default) indicating the number of members that were removed on success.
|
|
840
|
+
# See https://discord.com/developers/docs/resources/guild#begin-guild-prune
|
|
841
|
+
# @param guild_id [String] ID (as a string) of the guild to start the guild prune in
|
|
842
|
+
# @param days [Integer, nil] Number of days to prune for (1-30)
|
|
843
|
+
# @param compute_prune_count [TrueClass, FalseClass, nil] Whether to return the 'pruned' key in the response
|
|
844
|
+
# @param include_roles [Array, nil] Array of role IDs (as strings), these roles will also be included in the prune
|
|
845
|
+
# operation
|
|
846
|
+
# @param reason [String, nil] (DEPRECATED, use audit_reason instead) Reason for the prune, shows up on the audit log
|
|
847
|
+
# entry.
|
|
848
|
+
# @param audit_reason [String, nil] Reason for the prune, shows up on the audit log entry.
|
|
849
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
561
850
|
def begin_guild_prune(guild_id, days: nil, compute_prune_count: nil, include_roles: nil, reason: nil,
|
|
562
851
|
audit_reason: nil)
|
|
563
852
|
output = {}
|
|
@@ -579,6 +868,10 @@ class DiscordApi
|
|
|
579
868
|
response
|
|
580
869
|
end
|
|
581
870
|
|
|
871
|
+
# Returns a list of voice region objects for the specified guild with status code 200 OK on success.
|
|
872
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
|
|
873
|
+
# @param guild_id [String] ID (as a string) of the guild to get the voice regions from
|
|
874
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
582
875
|
def get_guild_voice_regions(guild_id)
|
|
583
876
|
url = "#{@base_url}/guilds/#{guild_id}/regions"
|
|
584
877
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -589,6 +882,10 @@ class DiscordApi
|
|
|
589
882
|
response
|
|
590
883
|
end
|
|
591
884
|
|
|
885
|
+
# Returns a list of invite objects for the specified guild with status code 200 OK on success.
|
|
886
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-invites
|
|
887
|
+
# @param guild_id [String] ID (as a string) of the guild to get the invites from
|
|
888
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
592
889
|
def get_guild_invites(guild_id)
|
|
593
890
|
url = "#{@base_url}/guilds/#{guild_id}/invites"
|
|
594
891
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -599,6 +896,10 @@ class DiscordApi
|
|
|
599
896
|
response
|
|
600
897
|
end
|
|
601
898
|
|
|
899
|
+
# Returns a list of integration objects for the specified guild with status code 200 OK on success.
|
|
900
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-integrations
|
|
901
|
+
# @param guild_id [String] ID (as a string) of the guild to get the integrations from
|
|
902
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
602
903
|
def get_guild_integrations(guild_id)
|
|
603
904
|
url = "#{@base_url}/guilds/#{guild_id}/integrations"
|
|
604
905
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -614,6 +915,12 @@ class DiscordApi
|
|
|
614
915
|
response
|
|
615
916
|
end
|
|
616
917
|
|
|
918
|
+
# Deletes a guild integration. Returns 204 No Content on success.
|
|
919
|
+
# See https://discord.com/developers/docs/resources/guild#delete-guild-integration
|
|
920
|
+
# @param guild_id [String] ID (as a string) of the guild containing the integration to delete
|
|
921
|
+
# @param integration_id [String] ID (as a string) of the integration to delete
|
|
922
|
+
# @param audit_reason [String, nil] Reason for the deletion, shows up on the audit log entry.
|
|
923
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
617
924
|
def delete_guild_integration(guild_id, integration_id, audit_reason = nil)
|
|
618
925
|
url = "#{@base_url}/guilds/#{guild_id}/integrations/#{integration_id}"
|
|
619
926
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -625,6 +932,10 @@ class DiscordApi
|
|
|
625
932
|
response
|
|
626
933
|
end
|
|
627
934
|
|
|
935
|
+
# Returns the guild widget settings object for the specified guild with status code 200 OK on success.
|
|
936
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-widget-settings
|
|
937
|
+
# @param guild_id [String] ID (as a string) of the guild to get the widget settings from
|
|
938
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
628
939
|
def get_guild_widget_settings(guild_id)
|
|
629
940
|
url = "#{@base_url}/guilds/#{guild_id}/widget"
|
|
630
941
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -635,6 +946,14 @@ class DiscordApi
|
|
|
635
946
|
response
|
|
636
947
|
end
|
|
637
948
|
|
|
949
|
+
# Modifies the guild widget settings for the specified guild. Returns the updated guild widget settings object
|
|
950
|
+
# with status code 200 OK on success.
|
|
951
|
+
# See https://discord.com/developers/docs/resources/guild#modify-guild-widget
|
|
952
|
+
# @param guild_id [String] ID (as a string) of the guild to modify the widget settings for
|
|
953
|
+
# @param enabled [TrueClass, FalseClass] Whether the guild widget is enabled
|
|
954
|
+
# @param channel_id [String] ID (as a string) of the channel to show in the widget
|
|
955
|
+
# @param audit_reason [String] Reason for the modification, shows up on the audit log entry.
|
|
956
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
638
957
|
def modify_guild_widget(guild_id, enabled, channel_id, audit_reason: nil)
|
|
639
958
|
output = {}
|
|
640
959
|
output[:enabled] = enabled
|
|
@@ -650,7 +969,11 @@ class DiscordApi
|
|
|
650
969
|
response
|
|
651
970
|
end
|
|
652
971
|
|
|
653
|
-
|
|
972
|
+
# Returns the widget object for the specified guild with status code 200 OK on success.
|
|
973
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-widget
|
|
974
|
+
# @param guild_id [String] ID (as a string) of the guild to get the widget from
|
|
975
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
976
|
+
def get_guild_widget(guild_id)
|
|
654
977
|
url = "#{@base_url}/guilds/#{guild_id}/widget.json"
|
|
655
978
|
headers = { 'Authorization': @authorization_header }
|
|
656
979
|
response = DiscordApi.get(url, headers)
|
|
@@ -660,6 +983,10 @@ class DiscordApi
|
|
|
660
983
|
response
|
|
661
984
|
end
|
|
662
985
|
|
|
986
|
+
# Returns a partial invite object for guilds with that feature enabled with status code 200 OK on success.
|
|
987
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-vanity-url
|
|
988
|
+
# @param guild_id [String] ID (as a string) of the guild to get the vanity URL from
|
|
989
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
663
990
|
def get_guild_vanity_url(guild_id)
|
|
664
991
|
url = "#{@base_url}/guilds/#{guild_id}/vanity-url"
|
|
665
992
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -670,6 +997,18 @@ class DiscordApi
|
|
|
670
997
|
response
|
|
671
998
|
end
|
|
672
999
|
|
|
1000
|
+
# Returns the widget image (PNG) for the specified guild.
|
|
1001
|
+
# Only one of the style convenience booleans (shield, banner1, banner2, banner3, banner4) can be true; if more than
|
|
1002
|
+
# one is specified the function logs an error and returns nil. If none are true, the default style is used (shield).
|
|
1003
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-widget-image
|
|
1004
|
+
# @param guild_id [String] ID (as a string) of the guild to get the widget image for.
|
|
1005
|
+
# @param shield [TrueClass, FalseClass] Whether to request the "shield" style widget image.
|
|
1006
|
+
# @param banner1 [TrueClass, FalseClass] Whether to request the "banner1" style widget image.
|
|
1007
|
+
# @param banner2 [TrueClass, FalseClass] Whether to request the "banner2" style widget image.
|
|
1008
|
+
# @param banner3 [TrueClass, FalseClass] Whether to request the "banner3" style widget image.
|
|
1009
|
+
# @param banner4 [TrueClass, FalseClass] Whether to request the "banner4" style widget image.
|
|
1010
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object containing the
|
|
1011
|
+
# PNG image data, or nil if more than one style was specified.
|
|
673
1012
|
def get_guild_widget_image(guild_id, shield: false, banner1: false, banner2: false, banner3: false, banner4: false)
|
|
674
1013
|
options = { shield: shield, banner1: banner1, banner2: banner2, banner3: banner3, banner4: banner4 }
|
|
675
1014
|
true_keys = options.select { |_k, v| v }.keys
|
|
@@ -695,6 +1034,10 @@ class DiscordApi
|
|
|
695
1034
|
response
|
|
696
1035
|
end
|
|
697
1036
|
|
|
1037
|
+
# Returns the welcome screen object for the specified guild.
|
|
1038
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
|
|
1039
|
+
# @param guild_id [String] ID (as a string) of the guild to get the welcome screen for.
|
|
1040
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
698
1041
|
def get_guild_welcome_screen(guild_id)
|
|
699
1042
|
url = "#{@base_url}/guilds/#{guild_id}/welcome-screen"
|
|
700
1043
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -705,6 +1048,17 @@ class DiscordApi
|
|
|
705
1048
|
response
|
|
706
1049
|
end
|
|
707
1050
|
|
|
1051
|
+
# Modifies the welcome screen for the specified guild. Returns the updated welcome screen object on success.
|
|
1052
|
+
# If none of the optional parameters are specified (modifications, except audit_reason),
|
|
1053
|
+
# the function logs a warning and returns nil.
|
|
1054
|
+
# See https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
|
|
1055
|
+
# @param guild_id [String] ID (as a string) of the guild to modify the welcome screen for.
|
|
1056
|
+
# @param enabled [TrueClass, FalseClass, nil] Whether the welcome screen is enabled.
|
|
1057
|
+
# @param welcome_channels [Array, nil] Array of welcome channel objects (hashes) to set.
|
|
1058
|
+
# @param description [String, nil] Description text for the welcome screen.
|
|
1059
|
+
# @param audit_reason [String, nil] Reason for the modification (appears in audit log entry).
|
|
1060
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if no
|
|
1061
|
+
# modifications were provided.
|
|
708
1062
|
def modify_guild_welcome_screen(guild_id, enabled: nil, welcome_channels: nil, description: nil,
|
|
709
1063
|
audit_reason: nil)
|
|
710
1064
|
if args[1..-2].all?(&:nil?)
|
|
@@ -727,6 +1081,10 @@ class DiscordApi
|
|
|
727
1081
|
response
|
|
728
1082
|
end
|
|
729
1083
|
|
|
1084
|
+
# Returns the onboarding object for the specified guild.
|
|
1085
|
+
# See https://discord.com/developers/docs/resources/guild#get-guild-onboarding
|
|
1086
|
+
# @param guild_id [String] ID (as a string) of the guild to get onboarding for.
|
|
1087
|
+
# @return [Faraday::Response] The response from the Discord API as a Faraday::Response object.
|
|
730
1088
|
def get_guild_onboarding(guild_id)
|
|
731
1089
|
url = "#{@base_url}/guilds/#{guild_id}/onboarding"
|
|
732
1090
|
headers = { 'Authorization': @authorization_header }
|
|
@@ -737,6 +1095,18 @@ class DiscordApi
|
|
|
737
1095
|
response
|
|
738
1096
|
end
|
|
739
1097
|
|
|
1098
|
+
# Modifies the onboarding configuration for the specified guild. Returns the updated onboarding object on success.
|
|
1099
|
+
# If none of the optional parameters are specified (modifications, except audit_reason),
|
|
1100
|
+
# the function logs a warning and returns nil.
|
|
1101
|
+
# See https://discord.com/developers/docs/resources/guild#modify-guild-onboarding
|
|
1102
|
+
# @param guild_id [String] ID (as a string) of the guild to modify onboarding for.
|
|
1103
|
+
# @param prompts [Array, nil] Array of prompt objects to set.
|
|
1104
|
+
# @param default_channel_ids [Array, nil] Array of channel IDs (as strings) considered default for onboarding.
|
|
1105
|
+
# @param enabled [TrueClass, FalseClass, nil] Whether onboarding is enabled in the guild.
|
|
1106
|
+
# @param mode [Integer, nil] The onboarding mode to set.
|
|
1107
|
+
# @param audit_reason [String, nil] Reason for the modification (appears in audit log entry).
|
|
1108
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if no
|
|
1109
|
+
# modifications were provided.
|
|
740
1110
|
def modify_guild_onboarding(guild_id, prompts: nil, default_channel_ids: nil, enabled: nil, mode: nil,
|
|
741
1111
|
audit_reason: nil)
|
|
742
1112
|
if args[1..-2].all?(&:nil?)
|
|
@@ -760,6 +1130,16 @@ class DiscordApi
|
|
|
760
1130
|
response
|
|
761
1131
|
end
|
|
762
1132
|
|
|
1133
|
+
# Modifies the incident actions for a guild (e.g. temporarily disabling invites or direct messages).
|
|
1134
|
+
# If none of the optional parameters are specified (modifications), the function logs a warning and returns nil.
|
|
1135
|
+
# See https://discord.com/developers/docs/resources/guild#modify-guild-incident-actions
|
|
1136
|
+
# @param guild_id [String] ID (as a string) of the guild to modify incident actions for.
|
|
1137
|
+
# @param invites_disabled_until [String, FalseClass, nil] ISO8601 timestamp until which invites are disabled,
|
|
1138
|
+
# false to clear, or nil to leave unchanged.
|
|
1139
|
+
# @param dms_disabled_until [String, FalseClass, nil] ISO8601 timestamp until which DMs are disabled,
|
|
1140
|
+
# false to clear, or nil to leave unchanged.
|
|
1141
|
+
# @return [Faraday::Response, nil] The response from the Discord API as a Faraday::Response object, or nil if no
|
|
1142
|
+
# modifications were provided.
|
|
763
1143
|
def modify_guild_incident_actions(guild_id, invites_disabled_until: nil, dms_disabled_until: nil)
|
|
764
1144
|
if args[1..].all?(&:nil?)
|
|
765
1145
|
@logger.warn("No modifications for guild incident actions with guild ID #{guild_id} provided. " \
|