Class: LibDiscord::Guild

Inherits:
Resource show all
Defined in:
lib/lib_discord/guild.rb

Overview

Guild Resource

Do not instantiate a Guild directly. Instead request one from an instance of Client.

client = LibDiscord::Client.new("Bot auth.token")
g = client["guild"]

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from LibDiscord::Resource

Instance Method Details

#add_guild_member(guild_id:, user_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



231
232
233
# File 'lib/lib_discord/guild.rb', line 231

def add_guild_member(guild_id:, user_id:, json:)
  send_request(:put, "/guilds/#{guild_id}/members/#{user_id}", json:)
end

#add_guild_member_role(guild_id:, user_id:, role_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



308
309
310
# File 'lib/lib_discord/guild.rb', line 308

def add_guild_member_role(guild_id:, user_id:, role_id:)
  send_request(:put, "/guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}")
end

#begin_guild_prune(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



577
578
579
# File 'lib/lib_discord/guild.rb', line 577

def begin_guild_prune(guild_id:, json:)
  send_request(:post, "/guilds/#{guild_id}/prune", json:)
end

#bulk_guild_ban(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



438
439
440
# File 'lib/lib_discord/guild.rb', line 438

def bulk_guild_ban(guild_id:, json:)
  send_request(:post, "/guilds/#{guild_id}/bulk-ban", json:)
end

#create_guild(json:) ⇒ Response

Parameters:

  • json (#to_json)

    JSON serializable payload

Returns:

Raises:

See Also:



28
29
30
# File 'lib/lib_discord/guild.rb', line 28

def create_guild(json:)
  send_request(:post, "/guilds", json:)
end

#create_guild_ban(guild_id:, user_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



403
404
405
# File 'lib/lib_discord/guild.rb', line 403

def create_guild_ban(guild_id:, user_id:, json:)
  send_request(:put, "/guilds/#{guild_id}/bans/#{user_id}", json:)
end

#create_guild_channel(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



125
126
127
# File 'lib/lib_discord/guild.rb', line 125

def create_guild_channel(guild_id:, json:)
  send_request(:post, "/guilds/#{guild_id}/channels", json:)
end

#create_guild_role(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



470
471
472
# File 'lib/lib_discord/guild.rb', line 470

def create_guild_role(guild_id:, json:)
  send_request(:post, "/guilds/#{guild_id}/roles", json:)
end

#delete_guild(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



93
94
95
# File 'lib/lib_discord/guild.rb', line 93

def delete_guild(guild_id:)
  send_request(:delete, "/guilds/#{guild_id}")
end

#delete_guild_integration(guild_id:, integration_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



640
641
642
# File 'lib/lib_discord/guild.rb', line 640

def delete_guild_integration(guild_id:, integration_id:)
  send_request(:delete, "/guilds/#{guild_id}/integrations/#{integration_id}")
end

#delete_guild_role(guild_id:, role_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



542
543
544
# File 'lib/lib_discord/guild.rb', line 542

def delete_guild_role(guild_id:, role_id:)
  send_request(:delete, "/guilds/#{guild_id}/roles/#{role_id}")
end

#get_guild(guild_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



46
47
48
# File 'lib/lib_discord/guild.rb', line 46

def get_guild(guild_id:, params: {})
  send_request(:get, "/guilds/#{guild_id}", params:)
end

#get_guild_ban(guild_id:, user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



383
384
385
# File 'lib/lib_discord/guild.rb', line 383

def get_guild_ban(guild_id:, user_id:)
  send_request(:get, "/guilds/#{guild_id}/bans/#{user_id}")
end

#get_guild_bans(guild_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



365
366
367
# File 'lib/lib_discord/guild.rb', line 365

def get_guild_bans(guild_id:, params: {})
  send_request(:get, "/guilds/#{guild_id}/bans", params:)
end

#get_guild_channels(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



108
109
110
# File 'lib/lib_discord/guild.rb', line 108

def get_guild_channels(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/channels")
end

#get_guild_integrations(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



622
623
624
# File 'lib/lib_discord/guild.rb', line 622

def get_guild_integrations(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/integrations")
end

#get_guild_invites(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



607
608
609
# File 'lib/lib_discord/guild.rb', line 607

def get_guild_invites(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/invites")
end

#get_guild_member(guild_id:, user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



175
176
177
# File 'lib/lib_discord/guild.rb', line 175

def get_guild_member(guild_id:, user_id:)
  send_request(:get, "/guilds/#{guild_id}/members/#{user_id}")
end

#get_guild_onboarding(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



772
773
774
# File 'lib/lib_discord/guild.rb', line 772

def get_guild_onboarding(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/onboarding")
end

#get_guild_preview(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



61
62
63
# File 'lib/lib_discord/guild.rb', line 61

def get_guild_preview(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/preview")
end

#get_guild_prune_count(guild_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



560
561
562
# File 'lib/lib_discord/guild.rb', line 560

def get_guild_prune_count(guild_id:, params: {})
  send_request(:get, "/guilds/#{guild_id}/prune", params:)
end

#get_guild_roles(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



453
454
455
# File 'lib/lib_discord/guild.rb', line 453

def get_guild_roles(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/roles")
end

#get_guild_vanity_url(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



702
703
704
# File 'lib/lib_discord/guild.rb', line 702

def get_guild_vanity_url(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/vanity-url")
end

#get_guild_voice_regions(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



592
593
594
# File 'lib/lib_discord/guild.rb', line 592

def get_guild_voice_regions(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/regions")
end

#get_guild_welcome_screen(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



740
741
742
# File 'lib/lib_discord/guild.rb', line 740

def get_guild_welcome_screen(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/welcome-screen")
end

#get_guild_widget(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



687
688
689
# File 'lib/lib_discord/guild.rb', line 687

def get_guild_widget(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/widget.json")
end

#get_guild_widget_image(guild_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



720
721
722
723
724
725
726
727
# File 'lib/lib_discord/guild.rb', line 720

def get_guild_widget_image(guild_id:, params: {})
  send_request(
    :get,
    "/guilds/#{guild_id}/widget.png",
    http_client: client,
    params:
  )
end

#get_guild_widget_settings(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



655
656
657
# File 'lib/lib_discord/guild.rb', line 655

def get_guild_widget_settings(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/widget")
end

#list_active_guild_threads(guild_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



157
158
159
# File 'lib/lib_discord/guild.rb', line 157

def list_active_guild_threads(guild_id:)
  send_request(:get, "/guilds/#{guild_id}/threads/active")
end

#list_guild_members(guild_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



193
194
195
# File 'lib/lib_discord/guild.rb', line 193

def list_guild_members(guild_id:, params: {})
  send_request(:get, "/guilds/#{guild_id}/members", params:)
end

#modify_current_member(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



268
269
270
# File 'lib/lib_discord/guild.rb', line 268

def modify_current_member(guild_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/members/@me", json:)
end

#modify_current_user_nick(guild_id:, json:) ⇒ Response

Deprecated.

Use #modify_current_member instead.

Parameters:

Returns:

Raises:

See Also:



287
288
289
# File 'lib/lib_discord/guild.rb', line 287

def modify_current_user_nick(guild_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/members/@me/nick", json:)
end

#modify_current_user_voice_state(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



806
807
808
# File 'lib/lib_discord/guild.rb', line 806

def modify_current_user_voice_state(guild_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/voice-states/@me", json:)
end

#modify_guild(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



78
79
80
# File 'lib/lib_discord/guild.rb', line 78

def modify_guild(guild_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}", json:)
end

#modify_guild_channel_positions(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



142
143
144
# File 'lib/lib_discord/guild.rb', line 142

def modify_guild_channel_positions(guild_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/channels", json:)
end

#modify_guild_member(guild_id:, user_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



251
252
253
# File 'lib/lib_discord/guild.rb', line 251

def modify_guild_member(guild_id:, user_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/members/#{user_id}", json:)
end

#modify_guild_mfa_level(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



524
525
526
# File 'lib/lib_discord/guild.rb', line 524

def modify_guild_mfa_level(guild_id:, json:)
  send_request(:post, "/guilds/#{guild_id}/mfa", json:)
end

#modify_guild_onboarding(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



789
790
791
# File 'lib/lib_discord/guild.rb', line 789

def modify_guild_onboarding(guild_id:, json:)
  send_request(:put, "/guilds/#{guild_id}/onboarding", json:)
end

#modify_guild_role(guild_id:, role_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



507
508
509
# File 'lib/lib_discord/guild.rb', line 507

def modify_guild_role(guild_id:, role_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/roles/#{role_id}", json:)
end

#modify_guild_role_positions(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



487
488
489
# File 'lib/lib_discord/guild.rb', line 487

def modify_guild_role_positions(guild_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/roles", json:)
end

#modify_guild_welcome_screen(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



757
758
759
# File 'lib/lib_discord/guild.rb', line 757

def modify_guild_welcome_screen(guild_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/welcome-screen", json:)
end

#modify_guild_widget(guild_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



672
673
674
# File 'lib/lib_discord/guild.rb', line 672

def modify_guild_widget(guild_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/widget", json:)
end

#modify_user_voice_state(guild_id:, user_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



826
827
828
# File 'lib/lib_discord/guild.rb', line 826

def modify_user_voice_state(guild_id:, user_id:, json:)
  send_request(:patch, "/guilds/#{guild_id}/voice-states/#{user_id}", json:)
end

#remove_guild_ban(guild_id:, user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



421
422
423
# File 'lib/lib_discord/guild.rb', line 421

def remove_guild_ban(guild_id:, user_id:)
  send_request(:delete, "/guilds/#{guild_id}/bans/#{user_id}")
end

#remove_guild_member(guild_id:, user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



347
348
349
# File 'lib/lib_discord/guild.rb', line 347

def remove_guild_member(guild_id:, user_id:)
  send_request(:delete, "/guilds/#{guild_id}/members/#{user_id}")
end

#remove_guild_member_role(guild_id:, user_id:, role_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



329
330
331
# File 'lib/lib_discord/guild.rb', line 329

def remove_guild_member_role(guild_id:, user_id:, role_id:)
  send_request(:delete, "/guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}")
end

#search_guild_members(guild_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



211
212
213
# File 'lib/lib_discord/guild.rb', line 211

def search_guild_members(guild_id:, params: {})
  send_request(:get, "/guilds/#{guild_id}/members/search", params:)
end