Module: Discordrb::API::Server
- Defined in:
- lib/discordrb/api/server.rb
Overview
API calls for Server
Class Method Summary collapse
-
.add_emoji(token, server_id, image, name, roles = [], reason = nil) ⇒ Object
Adds a custom emoji.
-
.add_member(token, server_id, user_id, access_token, nick = nil, roles = [], mute = false, deaf = false) ⇒ Object
Adds a member to a server with an OAuth2 Bearer token that has been granted
guilds.join
https://discord.com/developers/docs/resources/guild#add-guild-member. -
.add_member_role(token, server_id, user_id, role_id, reason = nil) ⇒ Object
Adds a single role to a member https://discord.com/developers/docs/resources/guild#add-guild-member-role.
-
.audit_logs(token, server_id, limit, user_id = nil, action_type = nil, before = nil) ⇒ Object
Gets a server's audit logs https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log.
-
.ban_user(token, server_id, user_id, message_days, reason = nil) ⇒ Object
Ban a user from a server and delete their messages from the last message_days days https://discord.com/developers/docs/resources/guild#create-guild-ban.
-
.bans(token, server_id, limit = nil, before = nil, after = nil) ⇒ Object
Get a server's banned users https://discord.com/developers/docs/resources/guild#get-guild-bans.
-
.begin_prune(token, server_id, days, reason = nil) ⇒ Object
Begin server prune https://discord.com/developers/docs/resources/guild#begin-guild-prune.
-
.channels(token, server_id) ⇒ Object
Get a server's channels list https://discord.com/developers/docs/resources/guild#get-guild-channels.
-
.create(token, name, region = :'eu-central') ⇒ Object
Create a server https://discord.com/developers/docs/resources/guild#create-guild.
-
.create_channel(token, server_id, name, type, topic, bitrate, user_limit, permission_overwrites, parent_id, nsfw, rate_limit_per_user, position, reason = nil) ⇒ Object
Create a channel https://discord.com/developers/docs/resources/guild#create-guild-channel.
-
.create_integration(token, server_id, type, id, reason = nil) ⇒ Object
Create a server integration https://discord.com/developers/docs/resources/guild#create-guild-integration.
-
.create_role(token, server_id, name, colour, hoist, mentionable, packed_permissions, reason = nil) ⇒ Object
Create a role (parameters such as name and colour if not set can be set by update_role afterwards) Permissions are the Discord defaults; allowed: invite creation, reading/sending messages, sending TTS messages, embedding links, sending files, reading the history, mentioning everybody, connecting to voice, speaking and voice activity (push-to-talk isn't mandatory) https://discord.com/developers/docs/resources/guild#get-guild-roles.
-
.delete(token, server_id) ⇒ Object
Delete a server https://discord.com/developers/docs/resources/guild#delete-guild.
-
.delete_emoji(token, server_id, emoji_id, reason = nil) ⇒ Object
Deletes a custom emoji https://discord.com/developers/docs/resources/emoji#delete-guild-emoji.
-
.delete_integration(token, server_id, integration_id, reason = nil) ⇒ Object
Delete a server integration https://discord.com/developers/docs/resources/guild#delete-guild-integration.
- .delete_role(token, server_id, role_id, reason = nil) ⇒ Object
-
.edit_emoji(token, server_id, emoji_id, name, roles = nil, reason = nil) ⇒ Object
Changes an emoji name and/or roles.
-
.integrations(token, server_id) ⇒ Object
Get server integrations https://discord.com/developers/docs/resources/guild#get-guild-integrations.
-
.invites(token, server_id) ⇒ Object
Get invites from server https://discord.com/developers/docs/resources/guild#get-guild-invites.
-
.modify_widget(token, server_id, enabled, channel_id, reason = nil) ⇒ Object
(also: modify_embed)
Modify a server's widget settings https://discord.com/developers/docs/resources/guild#modify-guild-widget.
-
.prune_count(token, server_id, days) ⇒ Object
Get server prune count https://discord.com/developers/docs/resources/guild#get-guild-prune-count.
-
.regions(token, server_id) ⇒ Object
Available voice regions for this server https://discord.com/developers/docs/resources/guild#get-guild-voice-regions.
-
.remove_member(token, server_id, user_id, reason = nil) ⇒ Object
Remove user from server https://discord.com/developers/docs/resources/guild#remove-guild-member.
-
.remove_member_role(token, server_id, user_id, role_id, reason = nil) ⇒ Object
Removes a single role from a member https://discord.com/developers/docs/resources/guild#remove-guild-member-role.
-
.resolve(token, server_id, with_counts = nil) ⇒ Object
Get a server's data https://discord.com/developers/docs/resources/guild#get-guild.
-
.resolve_member(token, server_id, user_id) ⇒ Object
Get a member's data https://discord.com/developers/docs/resources/guild#get-guild-member.
-
.resolve_members(token, server_id, limit, after = nil) ⇒ Object
Gets members from the server https://discord.com/developers/docs/resources/guild#list-guild-members.
-
.roles(token, server_id) ⇒ Object
Get server roles https://discord.com/developers/docs/resources/guild#get-guild-roles.
-
.sync_integration(token, server_id, integration_id) ⇒ Object
Sync an integration https://discord.com/developers/docs/resources/guild#sync-guild-integration.
-
.transfer_ownership(token, server_id, user_id, reason = nil) ⇒ Object
Transfer server ownership https://discord.com/developers/docs/resources/guild#modify-guild.
-
.unban_user(token, server_id, user_id, reason = nil) ⇒ Object
Unban a user from a server https://discord.com/developers/docs/resources/guild#remove-guild-ban.
-
.update(token, server_id, name, region, icon, afk_channel_id, afk_timeout, splash, default_message_notifications, verification_level, explicit_content_filter, system_channel_id, reason = nil) ⇒ Object
Update a server https://discord.com/developers/docs/resources/guild#modify-guild.
-
.update_channel_positions(token, server_id, positions) ⇒ Object
Update a channels position https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions.
-
.update_integration(token, server_id, integration_id, expire_behavior, expire_grace_period, enable_emoticons) ⇒ Object
Update integration from server https://discord.com/developers/docs/resources/guild#modify-guild-integration.
-
.update_member(token, server_id, user_id, nick: :undef, roles: :undef, mute: :undef, deaf: :undef, channel_id: :undef, communication_disabled_until: :undef, reason: nil) ⇒ Object
Update a user properties https://discord.com/developers/docs/resources/guild#modify-guild-member.
-
.update_role(token, server_id, role_id, name, colour, hoist = false, mentionable = false, packed_permissions = 104_324_161, reason = nil, icon = :undef) ⇒ Object
Update a role Permissions are the Discord defaults; allowed: invite creation, reading/sending messages, sending TTS messages, embedding links, sending files, reading the history, mentioning everybody, connecting to voice, speaking and voice activity (push-to-talk isn't mandatory) https://discord.com/developers/docs/resources/guild#batch-modify-guild-role.
-
.update_role_positions(token, server_id, roles) ⇒ Object
Update role positions https://discord.com/developers/docs/resources/guild#modify-guild-role-positions.
-
.webhooks(token, server_id) ⇒ Object
Get server webhooks https://discord.com/developers/docs/resources/webhook#get-guild-webhooks.
-
.widget(token, server_id) ⇒ Object
(also: embed)
Retrieves a server's widget information https://discord.com/developers/docs/resources/guild#get-guild-widget.
Class Method Details
.add_emoji(token, server_id, image, name, roles = [], reason = nil) ⇒ Object
Adds a custom emoji. https://discord.com/developers/docs/resources/emoji#create-guild-emoji
481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/discordrb/api/server.rb', line 481 def add_emoji(token, server_id, image, name, roles = [], reason = nil) Discordrb::API.request( :guilds_sid_emojis, server_id, :post, "#{Discordrb::API.api_base}/guilds/#{server_id}/emojis", { image: image, name: name, roles: roles }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.add_member(token, server_id, user_id, access_token, nick = nil, roles = [], mute = false, deaf = false) ⇒ Object
Adds a member to a server with an OAuth2 Bearer token that has been granted guilds.join
https://discord.com/developers/docs/resources/guild#add-guild-member
548 549 550 551 552 553 554 555 556 557 558 |
# File 'lib/discordrb/api/server.rb', line 548 def add_member(token, server_id, user_id, access_token, nick = nil, roles = [], mute = false, deaf = false) Discordrb::API.request( :guilds_sid_members_uid, server_id, :put, "#{Discordrb::API.api_base}/guilds/#{server_id}/members/#{user_id}", { access_token: access_token, nick: nick, roles: roles, mute: mute, deaf: deaf }.to_json, content_type: :json, Authorization: token ) end |
.add_member_role(token, server_id, user_id, role_id, reason = nil) ⇒ Object
Adds a single role to a member https://discord.com/developers/docs/resources/guild#add-guild-member-role
309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/discordrb/api/server.rb', line 309 def add_member_role(token, server_id, user_id, role_id, reason = nil) Discordrb::API.request( :guilds_sid_members_uid_roles_rid, server_id, :put, "#{Discordrb::API.api_base}/guilds/#{server_id}/members/#{user_id}/roles/#{role_id}", nil, Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.audit_logs(token, server_id, limit, user_id = nil, action_type = nil, before = nil) ⇒ Object
Gets a server's audit logs https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
374 375 376 377 378 379 380 381 382 |
# File 'lib/discordrb/api/server.rb', line 374 def audit_logs(token, server_id, limit, user_id = nil, action_type = nil, before = nil) Discordrb::API.request( :guilds_sid_auditlogs, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/audit-logs?limit=#{limit}#{"&user_id=#{user_id}" if user_id}#{"&action_type=#{action_type}" if action_type}#{"&before=#{before}" if before}", Authorization: token ) end |
.ban_user(token, server_id, user_id, message_days, reason = nil) ⇒ Object
Ban a user from a server and delete their messages from the last message_days days https://discord.com/developers/docs/resources/guild#create-guild-ban
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/discordrb/api/server.rb', line 192 def ban_user(token, server_id, user_id, , reason = nil) reason = URI.encode_www_form_component(reason) if reason Discordrb::API.request( :guilds_sid_bans_uid, server_id, :put, "#{Discordrb::API.api_base}/guilds/#{server_id}/bans/#{user_id}?delete_message_days=#{}&reason=#{reason}", nil, Authorization: token ) end |
.bans(token, server_id, limit = nil, before = nil, after = nil) ⇒ Object
Get a server's banned users https://discord.com/developers/docs/resources/guild#get-guild-bans
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/discordrb/api/server.rb', line 179 def bans(token, server_id, limit = nil, before = nil, after = nil) query_string = URI.encode_www_form({ limit: limit, before: before, after: after }.compact) Discordrb::API.request( :guilds_sid_bans, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/bans?#{query_string}", Authorization: token ) end |
.begin_prune(token, server_id, days, reason = nil) ⇒ Object
Begin server prune https://discord.com/developers/docs/resources/guild#begin-guild-prune
348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/discordrb/api/server.rb', line 348 def begin_prune(token, server_id, days, reason = nil) Discordrb::API.request( :guilds_sid_prune, server_id, :post, "#{Discordrb::API.api_base}/guilds/#{server_id}/prune", { days: days }, Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.channels(token, server_id) ⇒ Object
Get a server's channels list https://discord.com/developers/docs/resources/guild#get-guild-channels
77 78 79 80 81 82 83 84 85 |
# File 'lib/discordrb/api/server.rb', line 77 def channels(token, server_id) Discordrb::API.request( :guilds_sid_channels, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/channels", Authorization: token ) end |
.create(token, name, region = :'eu-central') ⇒ Object
Create a server https://discord.com/developers/docs/resources/guild#create-guild
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/discordrb/api/server.rb', line 9 def create(token, name, region = :'eu-central') Discordrb::API.request( :guilds, nil, :post, "#{Discordrb::API.api_base}/guilds", { name: name, region: region.to_s }.to_json, Authorization: token, content_type: :json ) end |
.create_channel(token, server_id, name, type, topic, bitrate, user_limit, permission_overwrites, parent_id, nsfw, rate_limit_per_user, position, reason = nil) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/discordrb/api/server.rb', line 89 def create_channel(token, server_id, name, type, topic, bitrate, user_limit, , parent_id, nsfw, rate_limit_per_user, position, reason = nil) Discordrb::API.request( :guilds_sid_channels, server_id, :post, "#{Discordrb::API.api_base}/guilds/#{server_id}/channels", { name: name, type: type, topic: topic, bitrate: bitrate, user_limit: user_limit, permission_overwrites: , parent_id: parent_id, nsfw: nsfw, rate_limit_per_user: rate_limit_per_user, position: position }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.create_integration(token, server_id, type, id, reason = nil) ⇒ Object
Create a server integration https://discord.com/developers/docs/resources/guild#create-guild-integration
398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/discordrb/api/server.rb', line 398 def create_integration(token, server_id, type, id, reason = nil) Discordrb::API.request( :guilds_sid_integrations, server_id, :post, "#{Discordrb::API.api_base}/guilds/#{server_id}/integrations", { type: type, id: id }, Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.create_role(token, server_id, name, colour, hoist, mentionable, packed_permissions, reason = nil) ⇒ Object
Create a role (parameters such as name and colour if not set can be set by update_role afterwards) Permissions are the Discord defaults; allowed: invite creation, reading/sending messages, sending TTS messages, embedding links, sending files, reading the history, mentioning everybody, connecting to voice, speaking and voice activity (push-to-talk isn't mandatory) https://discord.com/developers/docs/resources/guild#get-guild-roles
234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/discordrb/api/server.rb', line 234 def create_role(token, server_id, name, colour, hoist, mentionable, , reason = nil) Discordrb::API.request( :guilds_sid_roles, server_id, :post, "#{Discordrb::API.api_base}/guilds/#{server_id}/roles", { color: colour, name: name, hoist: hoist, mentionable: mentionable, permissions: }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.delete(token, server_id) ⇒ Object
Delete a server https://discord.com/developers/docs/resources/guild#delete-guild
65 66 67 68 69 70 71 72 73 |
# File 'lib/discordrb/api/server.rb', line 65 def delete(token, server_id) Discordrb::API.request( :guilds_sid, server_id, :delete, "#{Discordrb::API.api_base}/guilds/#{server_id}", Authorization: token ) end |
.delete_emoji(token, server_id, emoji_id, reason = nil) ⇒ Object
Deletes a custom emoji https://discord.com/developers/docs/resources/emoji#delete-guild-emoji
511 512 513 514 515 516 517 518 519 520 |
# File 'lib/discordrb/api/server.rb', line 511 def delete_emoji(token, server_id, emoji_id, reason = nil) Discordrb::API.request( :guilds_sid_emojis_eid, server_id, :delete, "#{Discordrb::API.api_base}/guilds/#{server_id}/emojis/#{emoji_id}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.delete_integration(token, server_id, integration_id, reason = nil) ⇒ Object
Delete a server integration https://discord.com/developers/docs/resources/guild#delete-guild-integration
426 427 428 429 430 431 432 433 434 435 |
# File 'lib/discordrb/api/server.rb', line 426 def delete_integration(token, server_id, integration_id, reason = nil) Discordrb::API.request( :guilds_sid_integrations_iid, server_id, :delete, "#{Discordrb::API.api_base}/guilds/#{server_id}/integrations/#{integration_id}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.delete_role(token, server_id, role_id, reason = nil) ⇒ Object
296 297 298 299 300 301 302 303 304 305 |
# File 'lib/discordrb/api/server.rb', line 296 def delete_role(token, server_id, role_id, reason = nil) Discordrb::API.request( :guilds_sid_roles_rid, server_id, :delete, "#{Discordrb::API.api_base}/guilds/#{server_id}/roles/#{role_id}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.edit_emoji(token, server_id, emoji_id, name, roles = nil, reason = nil) ⇒ Object
Changes an emoji name and/or roles. https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/discordrb/api/server.rb', line 496 def edit_emoji(token, server_id, emoji_id, name, roles = nil, reason = nil) Discordrb::API.request( :guilds_sid_emojis_eid, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}/emojis/#{emoji_id}", { name: name, roles: roles }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.integrations(token, server_id) ⇒ Object
Get server integrations https://discord.com/developers/docs/resources/guild#get-guild-integrations
386 387 388 389 390 391 392 393 394 |
# File 'lib/discordrb/api/server.rb', line 386 def integrations(token, server_id) Discordrb::API.request( :guilds_sid_integrations, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/integrations", Authorization: token ) end |
.invites(token, server_id) ⇒ Object
Get invites from server https://discord.com/developers/docs/resources/guild#get-guild-invites
362 363 364 365 366 367 368 369 370 |
# File 'lib/discordrb/api/server.rb', line 362 def invites(token, server_id) Discordrb::API.request( :guilds_sid_invites, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/invites", Authorization: token ) end |
.modify_widget(token, server_id, enabled, channel_id, reason = nil) ⇒ Object Also known as: modify_embed
Modify a server's widget settings https://discord.com/developers/docs/resources/guild#modify-guild-widget
465 466 467 468 469 470 471 472 473 474 475 476 |
# File 'lib/discordrb/api/server.rb', line 465 def (token, server_id, enabled, channel_id, reason = nil) Discordrb::API.request( :guilds_sid_embed, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}/widget", { enabled: enabled, channel_id: channel_id }.to_json, Authorization: token, 'X-Audit-Log-Reason': reason, content_type: :json ) end |
.prune_count(token, server_id, days) ⇒ Object
Get server prune count https://discord.com/developers/docs/resources/guild#get-guild-prune-count
336 337 338 339 340 341 342 343 344 |
# File 'lib/discordrb/api/server.rb', line 336 def prune_count(token, server_id, days) Discordrb::API.request( :guilds_sid_prune, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/prune?days=#{days}", Authorization: token ) end |
.regions(token, server_id) ⇒ Object
Available voice regions for this server https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
524 525 526 527 528 529 530 531 532 |
# File 'lib/discordrb/api/server.rb', line 524 def regions(token, server_id) Discordrb::API.request( :guilds_sid_regions, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/regions", Authorization: token ) end |
.remove_member(token, server_id, user_id, reason = nil) ⇒ Object
Remove user from server https://discord.com/developers/docs/resources/guild#remove-guild-member
165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/discordrb/api/server.rb', line 165 def remove_member(token, server_id, user_id, reason = nil) Discordrb::API.request( :guilds_sid_members_uid, server_id, :delete, "#{Discordrb::API.api_base}/guilds/#{server_id}/members/#{user_id}", Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.remove_member_role(token, server_id, user_id, role_id, reason = nil) ⇒ Object
Removes a single role from a member https://discord.com/developers/docs/resources/guild#remove-guild-member-role
323 324 325 326 327 328 329 330 331 332 |
# File 'lib/discordrb/api/server.rb', line 323 def remove_member_role(token, server_id, user_id, role_id, reason = nil) Discordrb::API.request( :guilds_sid_members_uid_roles_rid, server_id, :delete, "#{Discordrb::API.api_base}/guilds/#{server_id}/members/#{user_id}/roles/#{role_id}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.resolve(token, server_id, with_counts = nil) ⇒ Object
Get a server's data https://discord.com/developers/docs/resources/guild#get-guild
23 24 25 26 27 28 29 30 31 |
# File 'lib/discordrb/api/server.rb', line 23 def resolve(token, server_id, with_counts = nil) Discordrb::API.request( :guilds_sid, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}#{'?with_counts=true' if with_counts}", Authorization: token ) end |
.resolve_member(token, server_id, user_id) ⇒ Object
Get a member's data https://discord.com/developers/docs/resources/guild#get-guild-member
118 119 120 121 122 123 124 125 126 |
# File 'lib/discordrb/api/server.rb', line 118 def resolve_member(token, server_id, user_id) Discordrb::API.request( :guilds_sid_members_uid, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/members/#{user_id}", Authorization: token ) end |
.resolve_members(token, server_id, limit, after = nil) ⇒ Object
Gets members from the server https://discord.com/developers/docs/resources/guild#list-guild-members
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/discordrb/api/server.rb', line 130 def resolve_members(token, server_id, limit, after = nil) query_string = URI.encode_www_form({ limit: limit, after: after }.compact) Discordrb::API.request( :guilds_sid_members, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/members?#{query_string}", Authorization: token ) end |
.roles(token, server_id) ⇒ Object
Get server roles https://discord.com/developers/docs/resources/guild#get-guild-roles
219 220 221 222 223 224 225 226 227 |
# File 'lib/discordrb/api/server.rb', line 219 def roles(token, server_id) Discordrb::API.request( :guilds_sid_roles, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/roles", Authorization: token ) end |
.sync_integration(token, server_id, integration_id) ⇒ Object
Sync an integration https://discord.com/developers/docs/resources/guild#sync-guild-integration
439 440 441 442 443 444 445 446 447 448 |
# File 'lib/discordrb/api/server.rb', line 439 def sync_integration(token, server_id, integration_id) Discordrb::API.request( :guilds_sid_integrations_iid_sync, server_id, :post, "#{Discordrb::API.api_base}/guilds/#{server_id}/integrations/#{integration_id}/sync", nil, Authorization: token ) end |
.transfer_ownership(token, server_id, user_id, reason = nil) ⇒ Object
Transfer server ownership https://discord.com/developers/docs/resources/guild#modify-guild
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/discordrb/api/server.rb', line 50 def transfer_ownership(token, server_id, user_id, reason = nil) Discordrb::API.request( :guilds_sid, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}", { owner_id: user_id }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.unban_user(token, server_id, user_id, reason = nil) ⇒ Object
Unban a user from a server https://discord.com/developers/docs/resources/guild#remove-guild-ban
206 207 208 209 210 211 212 213 214 215 |
# File 'lib/discordrb/api/server.rb', line 206 def unban_user(token, server_id, user_id, reason = nil) Discordrb::API.request( :guilds_sid_bans_uid, server_id, :delete, "#{Discordrb::API.api_base}/guilds/#{server_id}/bans/#{user_id}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.update(token, server_id, name, region, icon, afk_channel_id, afk_timeout, splash, default_message_notifications, verification_level, explicit_content_filter, system_channel_id, reason = nil) ⇒ Object
Update a server https://discord.com/developers/docs/resources/guild#modify-guild
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/discordrb/api/server.rb', line 35 def update(token, server_id, name, region, icon, afk_channel_id, afk_timeout, splash, , verification_level, explicit_content_filter, system_channel_id, reason = nil) Discordrb::API.request( :guilds_sid, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}", { name: name, region: region, icon: icon, afk_channel_id: afk_channel_id, afk_timeout: afk_timeout, splash: splash, default_message_notifications: , verification_level: verification_level, explicit_content_filter: explicit_content_filter, system_channel_id: system_channel_id }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.update_channel_positions(token, server_id, positions) ⇒ Object
Update a channels position https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/discordrb/api/server.rb', line 104 def update_channel_positions(token, server_id, positions) Discordrb::API.request( :guilds_sid_channels, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}/channels", positions.to_json, Authorization: token, content_type: :json ) end |
.update_integration(token, server_id, integration_id, expire_behavior, expire_grace_period, enable_emoticons) ⇒ Object
Update integration from server https://discord.com/developers/docs/resources/guild#modify-guild-integration
412 413 414 415 416 417 418 419 420 421 422 |
# File 'lib/discordrb/api/server.rb', line 412 def update_integration(token, server_id, integration_id, expire_behavior, expire_grace_period, enable_emoticons) Discordrb::API.request( :guilds_sid_integrations_iid, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}/integrations/#{integration_id}", { expire_behavior: expire_behavior, expire_grace_period: expire_grace_period, enable_emoticons: enable_emoticons }.to_json, Authorization: token, content_type: :json ) end |
.update_member(token, server_id, user_id, nick: :undef, roles: :undef, mute: :undef, deaf: :undef, channel_id: :undef, communication_disabled_until: :undef, reason: nil) ⇒ Object
Update a user properties https://discord.com/developers/docs/resources/guild#modify-guild-member
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/discordrb/api/server.rb', line 143 def update_member(token, server_id, user_id, nick: :undef, roles: :undef, mute: :undef, deaf: :undef, channel_id: :undef, communication_disabled_until: :undef, reason: nil) Discordrb::API.request( :guilds_sid_members_uid, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}/members/#{user_id}", { roles: roles, nick: nick, mute: mute, deaf: deaf, channel_id: channel_id, communication_disabled_until: communication_disabled_until }.reject { |_, v| v == :undef }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.update_role(token, server_id, role_id, name, colour, hoist = false, mentionable = false, packed_permissions = 104_324_161, reason = nil, icon = :undef) ⇒ Object
Update a role Permissions are the Discord defaults; allowed: invite creation, reading/sending messages, sending TTS messages, embedding links, sending files, reading the history, mentioning everybody, connecting to voice, speaking and voice activity (push-to-talk isn't mandatory) https://discord.com/developers/docs/resources/guild#batch-modify-guild-role
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/discordrb/api/server.rb', line 253 def update_role(token, server_id, role_id, name, colour, hoist = false, mentionable = false, = 104_324_161, reason = nil, icon = :undef) data = { color: colour, name: name, hoist: hoist, mentionable: mentionable, permissions: } if icon != :undef && icon path_method = %i[original_filename path local_path].find { |meth| icon.respond_to?(meth) } raise ArgumentError, 'File object must respond to original_filename, path, or local path.' unless path_method raise ArgumentError, 'File must respond to read' unless icon.respond_to? :read mime_type = MIME::Types.type_for(icon.__send__(path_method)).first&.to_s || 'image/jpeg' data[:icon] = "data:#{mime_type};base64,#{Base64.encode64(icon.read).strip}" elsif icon.nil? data[:icon] = nil end Discordrb::API.request( :guilds_sid_roles_rid, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}/roles/#{role_id}", data.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.update_role_positions(token, server_id, roles) ⇒ Object
Update role positions https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/discordrb/api/server.rb', line 282 def update_role_positions(token, server_id, roles) Discordrb::API.request( :guilds_sid_roles, server_id, :patch, "#{Discordrb::API.api_base}/guilds/#{server_id}/roles", roles.to_json, Authorization: token, content_type: :json ) end |
.webhooks(token, server_id) ⇒ Object
Get server webhooks https://discord.com/developers/docs/resources/webhook#get-guild-webhooks
536 537 538 539 540 541 542 543 544 |
# File 'lib/discordrb/api/server.rb', line 536 def webhooks(token, server_id) Discordrb::API.request( :guilds_sid_webhooks, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/webhooks", Authorization: token ) end |
.widget(token, server_id) ⇒ Object Also known as: embed
Retrieves a server's widget information https://discord.com/developers/docs/resources/guild#get-guild-widget
452 453 454 455 456 457 458 459 460 |
# File 'lib/discordrb/api/server.rb', line 452 def (token, server_id) Discordrb::API.request( :guilds_sid_embed, server_id, :get, "#{Discordrb::API.api_base}/guilds/#{server_id}/widget", Authorization: token ) end |