Class: Discorb::Guild

Inherits:
DiscordModel show all
Defined in:
lib/discorb/guild.rb

Overview

Represents a guild in the Discord.

Defined Under Namespace

Classes: Ban, VanityInvite, Widget

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #hash

Instance Attribute Details

#afk_timeout -> Integer (readonly)

Returns The AFK timeout of the guild.

Returns:

  • (Integer)

    The AFK timeout of the guild.



21
22
23
# File 'lib/discorb/guild.rb', line 21

def afk_timeout
  @afk_timeout
end

#approximate_member_count -> Integer (readonly)

Returns The approxmate amount of members in the guild.

Returns:

  • (Integer)

    The approxmate amount of members in the guild.



72
73
74
# File 'lib/discorb/guild.rb', line 72

def approximate_member_count
  @approximate_member_count
end

#approximate_presence_count -> Integer (readonly)

Returns The approxmate amount of non-offline members in the guild.

Returns:

  • (Integer)

    The approxmate amount of non-offline members in the guild.



74
75
76
# File 'lib/discorb/guild.rb', line 74

def approximate_presence_count
  @approximate_presence_count
end

#available -> Boolean (readonly) Also known as: available?

Returns Whether the guild is available.

Returns:

  • (Boolean)

    Whether the guild is available.



97
98
99
# File 'lib/discorb/guild.rb', line 97

def available
  @available
end

Returns:

  • (Discorb::Asset)

    The banner of the guild.

  • (nil)

    If the guild does not have a banner.



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

def banner
  @banner
end

#channels -> Discorb::Dictionary{Discorb::Snowflake => Discorb::GuildChannel} (readonly)

Returns A dictionary of channels in the guild.

Returns:



47
48
49
# File 'lib/discorb/guild.rb', line 47

def channels
  @channels
end

#default_message_notifications -> :all_messages, :only_mentions (readonly)

Returns The default message notification level of the guild.

Returns:

  • (:all_messages, :only_mentions)

    The default message notification level of the guild.



84
85
86
# File 'lib/discorb/guild.rb', line 84

def default_message_notifications
  @default_message_notifications
end

#description -> String (readonly)

Returns The description of the guild.

Returns:

  • (String)

    The description of the guild.



58
59
60
# File 'lib/discorb/guild.rb', line 58

def description
  @description
end

#discovery_splash -> Discorb::Asset (readonly)

Returns The discovery splash of the guild.

Returns:



15
16
17
# File 'lib/discorb/guild.rb', line 15

def discovery_splash
  @discovery_splash
end

#emojis -> Discorb::Dictionary{Discorb::Snowflake => Discorb::CustomEmoji} (readonly)

Returns A dictionary of custom emojis in the guild.

Returns:



25
26
27
# File 'lib/discorb/guild.rb', line 25

def emojis
  @emojis
end

#explicit_content_filter -> :disabled_in_text, ... (readonly)

Returns The explict content filter level of the guild.

Returns:

  • (:disabled_in_text, :members_without_roles, :all_members)

    The explict content filter level of the guild.



86
87
88
# File 'lib/discorb/guild.rb', line 86

def explicit_content_filter
  @explicit_content_filter
end

#features -> Array<Symbol> (readonly)

Returns features that are enabled in the guild.

Returns:

  • (Array<Symbol>)

    features that are enabled in the guild.

See Also:



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

def features
  @features
end

#icon -> Discorb::Asset (readonly)

Returns The icon of the guild.

Returns:



40
41
42
# File 'lib/discorb/guild.rb', line 40

def icon
  @icon
end

#id -> Discorb::Snowflake (readonly)

Returns ID of the guild.

Returns:



9
10
11
# File 'lib/discorb/guild.rb', line 9

def id
  @id
end

#joined_at -> Time (readonly)

Returns Time that representing when bot has joined the guild.

Returns:

  • (Time)

    Time that representing when bot has joined the guild.



34
35
36
# File 'lib/discorb/guild.rb', line 34

def joined_at
  @joined_at
end

#large -> Boolean (readonly) Also known as: large?

Returns Whether the guild is large.

Returns:

  • (Boolean)

    Whether the guild is large.



91
92
93
# File 'lib/discorb/guild.rb', line 91

def large
  @large
end

#max_presences -> Integer (readonly)

Returns Number of online members in the guild.

Returns:

  • (Integer)

    Number of online members in the guild.



53
54
55
# File 'lib/discorb/guild.rb', line 53

def max_presences
  @max_presences
end

#max_video_channel_users -> Integer (readonly)

Returns The maximum amount of users in a video channel.

Returns:

  • (Integer)

    The maximum amount of users in a video channel.



70
71
72
# File 'lib/discorb/guild.rb', line 70

def max_video_channel_users
  @max_video_channel_users
end

#member_count -> Integer (readonly)

Returns The amount of members in the guild.

Returns:

  • (Integer)

    The amount of members in the guild.



38
39
40
# File 'lib/discorb/guild.rb', line 38

def member_count
  @member_count
end

#members -> Discorb::Dictionary{Discorb::Snowflake => Discorb::Member} (readonly)

Note:

You must enable GUILD_MEMBERS intent to use this method.

Returns A dictionary of members in the guild.

Returns:



45
46
47
# File 'lib/discorb/guild.rb', line 45

def members
  @members
end

#mfa_level -> :none, :elevated (readonly)

Returns The MFA level of the guild.

Returns:

  • (:none, :elevated)

    The MFA level of the guild.



30
31
32
# File 'lib/discorb/guild.rb', line 30

def mfa_level
  @mfa_level
end

#name -> String (readonly)

Returns The name of the guild.

Returns:

  • (String)

    The name of the guild.



11
12
13
# File 'lib/discorb/guild.rb', line 11

def name
  @name
end

#nsfw_level -> :default, ... (readonly)

Returns The nsfw level of the guild.

Returns:

  • (:default, :explicit, :safe, :age_restricted)

    The nsfw level of the guild.



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

def nsfw_level
  @nsfw_level
end

#owner -> Boolean (readonly) Also known as: owner?

Returns Whether the client is the owner of the guild.

Returns:

  • (Boolean)

    Whether the client is the owner of the guild.



88
89
90
# File 'lib/discorb/guild.rb', line 88

def owner
  @owner
end

#owner_id -> Discorb::Snowflake (readonly)

Returns ID of the guild owner.

Returns:



17
18
19
# File 'lib/discorb/guild.rb', line 17

def owner_id
  @owner_id
end

#permissions -> Discorb::Permission (readonly)

Returns The bot's permission in the guild.

Returns:



19
20
21
# File 'lib/discorb/guild.rb', line 19

def permissions
  @permissions
end

#preferred_locale -> Symbol (readonly)

Note:

This modifies the language code, - will be replaced with _.

Returns The preffered language of the guild.

Returns:

  • (Symbol)

    The preffered language of the guild.



68
69
70
# File 'lib/discorb/guild.rb', line 68

def preferred_locale
  @preferred_locale
end

#premium_subscription_count -> Integer (readonly)

Returns The amount of premium subscriptions (Server Boosts) the guild has.

Returns:

  • (Integer)

    The amount of premium subscriptions (Server Boosts) the guild has.



65
66
67
# File 'lib/discorb/guild.rb', line 65

def premium_subscription_count
  @premium_subscription_count
end

#premium_tier -> Integer (readonly)

Returns The premium tier (Boost Level) of the guild.

Returns:

  • (Integer)

    The premium tier (Boost Level) of the guild.



63
64
65
# File 'lib/discorb/guild.rb', line 63

def premium_tier
  @premium_tier
end

#presences -> Discorb::Dictionary{Discorb::User => Discorb::Presence} (readonly)

Returns A dictionary of presence in the guild.

Returns:



51
52
53
# File 'lib/discorb/guild.rb', line 51

def presences
  @presences
end

#roles -> Discorb::Dictionary{Discorb::Snowflake => Discorb::Role} (readonly)

Returns A dictionary of roles in the guild.

Returns:



23
24
25
# File 'lib/discorb/guild.rb', line 23

def roles
  @roles
end

#scheduled_events -> Dictionary{Discorb::Snowflake => Discorb::ScheduledEvent} (readonly) Also known as: events

Returns A dictionary of scheduled events in the guild.

Returns:



100
101
102
# File 'lib/discorb/guild.rb', line 100

def scheduled_events
  @scheduled_events
end

#splash -> Discorb::Asset (readonly)

Returns The splash of the guild.

Returns:



13
14
15
# File 'lib/discorb/guild.rb', line 13

def splash
  @splash
end

#stage_instances -> Discorb::Dictionary{Discorb::Snowflake => Discorb::StageInstance} (readonly)

Returns A dictionary of stage instances in the guild.

Returns:



80
81
82
# File 'lib/discorb/guild.rb', line 80

def stage_instances
  @stage_instances
end

#system_channel_flags -> Discorb::Guild::SystemChannelFlag (readonly)

Returns The flag for the system channel.

Returns:

  • (Discorb::Guild::SystemChannelFlag)

    The flag for the system channel.



32
33
34
# File 'lib/discorb/guild.rb', line 32

def system_channel_flags
  @system_channel_flags
end

#threads -> Discorb::Dictionary{Discorb::Snowflake => Discorb::ThreadChannel} (readonly)

Returns A dictionary of threads in the guild.

Returns:



49
50
51
# File 'lib/discorb/guild.rb', line 49

def threads
  @threads
end

#unavailable -> Boolean (readonly)

Returns Whether the guild is unavailable.

Returns:

  • (Boolean)

    Whether the guild is unavailable.



36
37
38
# File 'lib/discorb/guild.rb', line 36

def unavailable
  @unavailable
end

#vanity_url_code -> String? (readonly)

Returns:

  • (String)

    The vanity invite URL for the guild.

  • (nil)

    If the guild does not have a vanity invite URL.



56
57
58
# File 'lib/discorb/guild.rb', line 56

def vanity_url_code
  @vanity_url_code
end

#verification_level -> :none, ... (readonly)

Returns The verification level of the guild.

Returns:

  • (:none, :low, :medium, :high, :very_high)

    The verification level of the guild.



82
83
84
# File 'lib/discorb/guild.rb', line 82

def verification_level
  @verification_level
end

#voice_states -> Discorb::Dictionary{Discorb::User => Discorb::VoiceState} (readonly)

Returns A dictionary of voice states in the guild.

Returns:



42
43
44
# File 'lib/discorb/guild.rb', line 42

def voice_states
  @voice_states
end

#welcome_screen -> Discorb::WelcomeScreen (readonly)

Returns The welcome screen of the guild.

Returns:



76
77
78
# File 'lib/discorb/guild.rb', line 76

def welcome_screen
  @welcome_screen
end

#widget_enabled -> Boolean (readonly) Also known as: widget_enabled?

Returns Whether the guild enabled the widget.

Returns:

  • (Boolean)

    Whether the guild enabled the widget.



94
95
96
# File 'lib/discorb/guild.rb', line 94

def widget_enabled
  @widget_enabled
end

Class Method Details

Returns a banner url from the guild's ID.

Parameters:

  • guild_id (#to_s)

    The ID of the guild.

  • style (:shield, :banner1, :banner2, :banner3, :banner4) (defaults to: "banner")

    The style of the banner.

Returns:

  • (String)

    The url of the banner.



1184
1185
1186
# File 'lib/discorb/guild.rb', line 1184

def banner(guild_id, style: "banner")
  "#{Discorb::API_BASE_URL}/guilds/#{guild_id}/widget.png&style=#{style}"
end

Instance Method Details

#afk_channel -> Object



139
140
141
# File 'lib/discorb/guild.rb', line 139

def afk_channel
  @client.channels[@afk_channel_id]
end

#ban_member(member, delete_message_days: 0, reason: nil) -> Async::Task<Discorb::Guild::Ban>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Ban a member from the guild.

Parameters:

  • member (Discorb::Member)

    The member to ban.

  • delete_message_days (Integer) (defaults to: 0)

    The number of days to delete messages.

  • reason (String) (defaults to: nil)

    The reason for banning the member.

Returns:

Raises:



785
786
787
788
789
790
791
792
# File 'lib/discorb/guild.rb', line 785

def ban_member(member, delete_message_days: 0, reason: nil)
  Async do
    _resp, data = @client.http.post(
      "/guilds/#{@id}/bans", { user: member.id, delete_message_days: delete_message_days }, audit_log_reason: reason,
    ).wait
    Ban.new(@client, self, data)
  end
end

#banned?(user) -> Async::Task<Boolean>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Checks the user was banned from the guild.

Parameters:

Returns:

  • (Async::Task<Boolean>)

    Whether the user was banned.

Raises:



768
769
770
771
772
# File 'lib/discorb/guild.rb', line 768

def banned?(user)
  Async do
    !fetch_ban(user).wait.nil?
  end
end

#create_category_channel(name, position: nil, permission_overwrites: nil, parent: nil, reason: nil) -> Async::Task<Discorb::CategoryChannel> Also known as: create_category

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Create a new category channel.

Parameters:

  • name (String)

    The name of the channel.

  • position (Integer) (defaults to: nil)

    The position of the channel.

  • permission_overwrites (Hash{Discorb::Role, Discorb::Member => Discorb::PermissionOverwrite}) (defaults to: nil)

    A list of permission overwrites.

  • parent (Discorb::CategoryChannel) (defaults to: nil)

    The parent of the channel.

  • reason (String) (defaults to: nil)

    The reason for creating the channel.

Returns:

Raises:



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/discorb/guild.rb', line 488

def create_category_channel(name, position: nil, permission_overwrites: nil, parent: nil, reason: nil)
  Async do
    payload = { type: CategoryChannel.channel_type }
    payload[:name] = name
    payload[:position] = position if position
    if permission_overwrites
      payload[:permission_overwrites] = permission_overwrites.map do |target, overwrite|
        {
          type: target.is_a?(Role) ? 0 : 1,
          id: target.id,
          allow: overwrite.allow_value,
          deny: overwrite.deny_value,
        }
      end
    end
    payload[:parent_id] = parent&.id
    _resp, data = @client.http.post(
      "/guilds/#{@id}/channels", payload, audit_log_reason: reason,
    ).wait
    Channel.make_channel(@client, data)
  end
end

#create_emoji(name, image, roles: []) -> Async::Task<Discorb::CustomEmoji>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Create a custom emoji.

Parameters:

  • name (#to_s)

    The name of the emoji.

  • image (Discorb::Image)

    The image of the emoji.

  • roles (Array<Discorb::Role>) (defaults to: [])

    A list of roles to give the emoji.

Returns:

Raises:



332
333
334
335
336
337
338
339
340
341
342
# File 'lib/discorb/guild.rb', line 332

def create_emoji(name, image, roles: [])
  _resp, data = @client.http.post(
    "/guilds/#{@id}/emojis",
    {
      name: name,
      image: image.to_s,
      roles: roles.map { |r| Discorb::Utils.try(r, :id) },
    }
  ).wait
  @emojis[data[:id]] = CustomEmoji.new(@client, self, data)
end

#create_news_channel(name, topic: nil, rate_limit_per_user: nil, slowmode: nil, position: nil, nsfw: nil, permission_overwrites: nil, parent: nil, reason: nil) -> Async::Task<Discorb::NewsChannel>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Create a new news channel.

Parameters:

  • name (String)

    The name of the channel.

  • topic (String) (defaults to: nil)

    The topic of the channel.

  • rate_limit_per_user (Integer) (defaults to: nil)

    The rate limit per user in the channel.

  • slowmode (Integer) (defaults to: nil)

    Alias for rate_limit_per_user.

  • position (Integer) (defaults to: nil)

    The position of the channel.

  • nsfw (Boolean) (defaults to: nil)

    Whether the channel is nsfw.

  • permission_overwrites (Hash{Discorb::Role, Discorb::Member => Discorb::PermissionOverwrite}) (defaults to: nil)

    A list of permission overwrites.

  • parent (Discorb::CategoryChannel) (defaults to: nil)

    The parent of the channel.

  • reason (String) (defaults to: nil)

    The reason for creating the channel.

Returns:

Raises:



568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# File 'lib/discorb/guild.rb', line 568

def create_news_channel(
  name, topic: nil, rate_limit_per_user: nil, slowmode: nil, position: nil, nsfw: nil, permission_overwrites: nil, parent: nil, reason: nil
)
  Async do
    payload = { type: NewsChannel.channel_type }
    payload[:name] = name
    payload[:topic] = topic if topic
    rate_limit_per_user ||= slowmode
    payload[:rate_limit_per_user] = rate_limit_per_user if rate_limit_per_user
    payload[:position] = position if position
    if permission_overwrites
      payload[:permission_overwrites] = permission_overwrites.map do |target, overwrite|
        {
          type: target.is_a?(Role) ? 0 : 1,
          id: target.id,
          allow: overwrite.allow_value,
          deny: overwrite.deny_value,
        }
      end
    end
    payload[:nsfw] = nsfw unless nsfw.nil?
    payload[:parent_id] = parent&.id
    _resp, data = @client.http.post(
      "/guilds/#{@id}/channels", payload, audit_log_reason: reason,
    ).wait
    Channel.make_channel(@client, data)
  end
end

#create_role(name = nil, color: nil, hoist: nil, mentionable: nil, reason: nil) -> Async::Task<Discorb::Role>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Create a role in the guild.

Parameters:

  • name (String) (defaults to: nil)

    The name of the role.

  • color (Discorb::Color) (defaults to: nil)

    The color of the role.

  • hoist (Boolean) (defaults to: nil)

    Whether the role should be hoisted.

  • mentionable (Boolean) (defaults to: nil)

    Whether the role should be mentionable.

  • reason (String) (defaults to: nil)

    The reason for creating the role.

Returns:

Raises:



835
836
837
838
839
840
841
842
843
844
845
846
847
# File 'lib/discorb/guild.rb', line 835

def create_role(name = nil, color: nil, hoist: nil, mentionable: nil, reason: nil)
  Async do
    payload = {}
    payload[:name] = name if name
    payload[:color] = color.to_i if color
    payload[:hoist] = hoist if hoist
    payload[:mentionable] = mentionable if mentionable
    _resp, data = @client.http.post(
      "/guilds/#{@id}/roles", payload, audit_log_reason: reason,
    ).wait
    Role.new(@client, self, data)
  end
end

#create_scheduled_event(type, name, description, start_time, end_time = nil, privacy_level: :guild_only, location: nil, channel: nil) -> Discorb::ScheduledEvent

Create a scheduled event for the guild.

Parameters:

  • type (:stage_instance, :voice, :external)

    The type of event to create.

  • name (String)

    The name of the event.

  • description (String)

    The description of the event.

  • start_time (Time)

    The start time of the event.

  • end_time (Time, nil) (defaults to: nil)

    The end time of the event. Defaults to nil.

  • channel (Discorb::Channel, Discorb::Snowflake, nil) (defaults to: nil)

    The channel to run the event in.

  • location (String, nil) (defaults to: nil)

    The location of the event. Defaults to nil.

  • privacy_level (:guild_only) (defaults to: :guild_only)

    The privacy level of the event. This must be :guild_only.

Returns:



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
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
279
280
# File 'lib/discorb/guild.rb', line 226

def create_scheduled_event(
  type,
  name,
  description,
  start_time,
  end_time = nil,
  privacy_level: :guild_only,
  location: nil,
  channel: nil
)
  Async do
    payload = case type
      when :stage_instance
        raise ArgumentError, "channel must be provided for stage_instance events" unless channel
        {
          name: name,
          description: description,
          scheduled_start_time: start_time.iso8601,
          scheduled_end_time: end_time&.iso8601,
          privacy_level: Discorb::ScheduledEvent.privacy_level.key(privacy_level),
          channel_id: channel&.id,
          entity_type: Discorb::ScheduledEvent.entity_type.key(:stage_instance),
        }
      when :voice
        raise ArgumentError, "channel must be provided for voice events" unless channel
        {
          name: name,
          description: description,
          scheduled_start_time: start_time.iso8601,
          scheduled_end_time: end_time&.iso8601,
          privacy_level: Discorb::ScheduledEvent.privacy_level.key(privacy_level),
          channel_id: channel&.id,
          entity_type: Discorb::ScheduledEvent.entity_type.key(:voice),
        }
      when :external
        raise ArgumentError, "location must be provided for external events" unless location
        raise ArgumentError, "end_time must be provided for external events" unless end_time
        {
          name: name,
          description: description,
          scheduled_start_time: start_time.iso8601,
          scheduled_end_time: end_time.iso8601,
          privacy_level: Discorb::ScheduledEvent.privacy_level.key(privacy_level),
          entity_type: Discorb::ScheduledEvent.entity_type.key(:external),
          entity_metadata: {
            location: location,
          },
        }
      else
        raise ArgumentError, "Invalid scheduled event type: #{type}"
      end
    _resp, event = @client.http.post("/guilds/#{@id}/scheduled-events", payload).wait
    Discorb::ScheduledEvent.new(@client, event)
  end
end

#create_stage_channel(name, bitrate: 64, position: nil, permission_overwrites: nil, parent: nil, reason: nil) -> Async::Task<Discorb::StageChannel>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Create a new stage channel.

Parameters:

  • name (String)

    The name of the channel.

  • bitrate (Integer) (defaults to: 64)

    The bitrate of the channel.

  • position (Integer) (defaults to: nil)

    The position of the channel.

  • permission_overwrites (Hash{Discorb::Role, Discorb::Member => Discorb::PermissionOverwrite}) (defaults to: nil)

    A list of permission overwrites.

  • parent (Discorb::CategoryChannel) (defaults to: nil)

    The parent of the channel.

  • reason (String) (defaults to: nil)

    The reason for creating the channel.

Returns:

Raises:



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/discorb/guild.rb', line 527

def create_stage_channel(name, bitrate: 64, position: nil, permission_overwrites: nil, parent: nil, reason: nil)
  Async do
    payload = { type: StageChannel.channel_type }
    payload[:name] = name
    payload[:bitrate] = bitrate * 1000 if bitrate
    payload[:position] = position if position
    if permission_overwrites
      payload[:permission_overwrites] = permission_overwrites.map do |target, overwrite|
        {
          type: target.is_a?(Role) ? 0 : 1,
          id: target.id,
          allow: overwrite.allow_value,
          deny: overwrite.deny_value,
        }
      end
    end
    payload[:parent_id] = parent&.id
    _resp, data = @client.http.post(
      "/guilds/#{@id}/channels", payload, audit_log_reason: reason,
    ).wait
    Channel.make_channel(@client, data)
  end
end

#create_template(name, description = nil, reason: nil) -> Async::Task<Discorb::GuildTemplate>

Create a new template in the guild.

Parameters:

  • name (String)

    The name of the template.

  • description (String) (defaults to: nil)

    The description of the template.

  • reason (String) (defaults to: nil)

    The reason for creating the template.

Returns:



1044
1045
1046
1047
1048
1049
1050
1051
# File 'lib/discorb/guild.rb', line 1044

def create_template(name, description = nil, reason: nil)
  Async do
    _resp, data = @client.http.post(
      "/guilds/#{@id}/templates", { name: name, description: description }, audit_log_reason: reason,
    ).wait
    GuildTemplate.new(@client, data)
  end
end

#create_text_channel(name, topic: nil, rate_limit_per_user: nil, slowmode: nil, position: nil, nsfw: nil, permission_overwrites: nil, parent: nil, reason: nil) -> Async::Task<Discorb::TextChannel>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Create a new text channel.

Parameters:

  • name (String)

    The name of the channel.

  • topic (String) (defaults to: nil)

    The topic of the channel.

  • rate_limit_per_user (Integer) (defaults to: nil)

    The rate limit per user in the channel.

  • slowmode (Integer) (defaults to: nil)

    Alias for rate_limit_per_user.

  • position (Integer) (defaults to: nil)

    The position of the channel.

  • nsfw (Boolean) (defaults to: nil)

    Whether the channel is nsfw.

  • permission_overwrites (Hash{Discorb::Role, Discorb::Member => Discorb::PermissionOverwrite}) (defaults to: nil)

    A list of permission overwrites.

  • parent (Discorb::CategoryChannel) (defaults to: nil)

    The parent of the channel.

  • reason (String) (defaults to: nil)

    The reason for creating the channel.

Returns:

Raises:



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/discorb/guild.rb', line 403

def create_text_channel(
  name, topic: nil, rate_limit_per_user: nil, slowmode: nil, position: nil, nsfw: nil, permission_overwrites: nil, parent: nil, reason: nil
)
  Async do
    payload = { type: TextChannel.channel_type }
    payload[:name] = name
    payload[:topic] = topic if topic
    rate_limit_per_user ||= slowmode
    payload[:rate_limit_per_user] = rate_limit_per_user if rate_limit_per_user
    payload[:nsfw] = nsfw if nsfw
    payload[:position] = position if position
    if permission_overwrites
      payload[:permission_overwrites] = permission_overwrites.map do |target, overwrite|
        {
          type: target.is_a?(Role) ? 0 : 1,
          id: target.id,
          allow: overwrite.allow_value,
          deny: overwrite.deny_value,
        }
      end
    end
    payload[:parent_id] = parent.id if parent
    _resp, data = @client.http.post(
      "/guilds/#{@id}/channels", payload, audit_log_reason: reason,
    ).wait
    payload[:parent_id] = parent&.id
    Channel.make_channel(@client, data)
  end
end

#create_voice_channel(name, bitrate: 64, user_limit: nil, position: nil, permission_overwrites: nil, parent: nil, reason: nil) -> Async::Task<Discorb::VoiceChannel>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Create a new voice channel.

Parameters:

  • name (String)

    The name of the channel.

  • bitrate (Integer) (defaults to: 64)

    The bitrate of the channel.

  • user_limit (Integer) (defaults to: nil)

    The user limit of the channel.

  • position (Integer) (defaults to: nil)

    The position of the channel.

  • permission_overwrites (Hash{Discorb::Role, Discorb::Member => Discorb::PermissionOverwrite}) (defaults to: nil)

    A list of permission overwrites.

  • parent (Discorb::CategoryChannel) (defaults to: nil)

    The parent of the channel.

  • reason (String) (defaults to: nil)

    The reason for creating the channel.

Returns:

Raises:



448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/discorb/guild.rb', line 448

def create_voice_channel(
  name, bitrate: 64, user_limit: nil, position: nil, permission_overwrites: nil, parent: nil, reason: nil
)
  Async do
    payload = { type: VoiceChannel.channel_type }
    payload[:name] = name
    payload[:bitrate] = bitrate * 1000 if bitrate
    payload[:user_limit] = user_limit if user_limit
    payload[:position] = position if position
    if permission_overwrites
      payload[:permission_overwrites] = permission_overwrites.map do |target, overwrite|
        {
          type: target.is_a?(Role) ? 0 : 1,
          id: target.id,
          allow: overwrite.allow_value,
          deny: overwrite.deny_value,
        }
      end
    end
    payload[:parent_id] = parent.id if parent
    _resp, data = @client.http.post(
      "/guilds/#{@id}/channels", payload, audit_log_reason: reason,
    ).wait
    payload[:parent_id] = parent&.id
    Channel.make_channel(@client, data)
  end
end

#edit_nickname(nickname, reason: nil) -> Object Also known as: edit_nick, modify_nickname

Change nickname of client member.

Parameters:

  • nickname (String)

    The nickname to set.

  • reason (String) (defaults to: nil)

    The reason for changing the nickname.



701
702
703
704
705
# File 'lib/discorb/guild.rb', line 701

def edit_nickname(nickname, reason: nil)
  Async do
    @client.http.patch("/guilds/#{@id}/members/@me/nick", { nick: nickname }, audit_log_reason: reason).wait
  end
end

#fetch_active_threads -> Async::Task<Array<Discorb::ThreadChannel>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch a list of active threads in the guild.

Returns:

Raises:



604
605
606
607
608
609
# File 'lib/discorb/guild.rb', line 604

def fetch_active_threads
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/threads/active").wait
    data[:threads].map { |t| Channel.make_thread(@client, t) }
  end
end

#fetch_audit_log -> Async::Task<Discorb::AuditLog>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch audit log of the guild.

Returns:

Raises:



365
366
367
368
369
370
# File 'lib/discorb/guild.rb', line 365

def fetch_audit_log
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/audit-logs").wait
    AuditLog.new(@client, data, self)
  end
end

#fetch_ban(user) -> Async::Task<Discorb::Guild::Ban>, Async::Task<nil>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch a ban in the guild.

Parameters:

Returns:

  • (Async::Task<Discorb::Guild::Ban>)

    The ban.

  • (Async::Task<nil>)

    If the ban is not found.

Raises:



749
750
751
752
753
754
755
756
757
# File 'lib/discorb/guild.rb', line 749

def fetch_ban(user)
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/bans/#{user.id}").wait
  rescue Discorb::NotFoundError
    nil
  else
    Ban.new(@client, self, data)
  end
end

#fetch_bans -> Async::Task<Array<Discorb::Guild::Ban>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch a list of bans in the guild.

Returns:

Raises:



732
733
734
735
736
737
# File 'lib/discorb/guild.rb', line 732

def fetch_bans
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/bans").wait
    data.map { |d| Ban.new(@client, self, d) }
  end
end

#fetch_channels -> Async::Task<Array<Discorb::Channel>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch channels of the guild.

Returns:

Raises:



379
380
381
382
383
384
# File 'lib/discorb/guild.rb', line 379

def fetch_channels
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/channels").wait
    data.map { |c| Channel.make_channel(@client, c) }
  end
end

#fetch_emoji(id) -> Async::Task<Discorb::CustomEmoji>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Note:

This querys the API every time. We recommend using #emojis instead.

Fetch emoji id of the guild.

Parameters:

  • id (#to_s)

    The emoji id.

Returns:

Raises:



316
317
318
319
# File 'lib/discorb/guild.rb', line 316

def fetch_emoji(id)
  _resp, data = @client.http.get("/guilds/#{@id}/emojis/#{id}").wait
  @emojis[e[:id]] = CustomEmoji.new(@client, self, data)
end

#fetch_emoji_list -> Async::Task<Discorb::Dictionary{Discorb::Snowflake => Discorb::CustomEmoji}> Also known as: fetch_emojis

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Note:

This querys the API every time. We recommend using #emojis instead.

Fetch emoji list of the guild.

Returns:

Raises:



290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/discorb/guild.rb', line 290

def fetch_emoji_list
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/emojis").wait
    @emojis = Dictionary.new
    ids = @emojis.map(&:id).map(&:to_s)
    data.map do |e|
      next if ids.include?(e[:id])

      @emojis[e[:id]] = CustomEmoji.new(@client, self, e)
    end
    @emojis
  end
end

#fetch_integrations -> Async::Task<Array<Discorb::Integration>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch integrations in the guild.

Returns:

Raises:



926
927
928
929
930
931
# File 'lib/discorb/guild.rb', line 926

def fetch_integrations
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/integrations").wait
    data.map { |d| Integration.new(@client, d) }
  end
end

#fetch_invites -> Async::Task<Array<Invite>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch invites in the guild.

Returns:

  • (Async::Task<Array<Invite>>)

    The invites.

Raises:



912
913
914
915
916
917
# File 'lib/discorb/guild.rb', line 912

def fetch_invites
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/invites").wait
    data.map { |d| Invite.new(@client, d) }
  end
end

#fetch_member(id) -> Async::Task<Discorb::Member>, Async::Task<nil>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch a member in the guild.

Parameters:

  • id (#to_s)

    The ID of the member to fetch.

Returns:

  • (Async::Task<Discorb::Member>)

    The member.

  • (Async::Task<nil>)

    If the member is not found.

Raises:



621
622
623
624
625
626
627
628
629
# File 'lib/discorb/guild.rb', line 621

def fetch_member(id)
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/members/#{id}").wait
  rescue Discorb::NotFoundError
    nil
  else
    Member.new(@client, @id, data[:user], data)
  end
end

#fetch_member_named -> Async::Task<Discorb::Member>, Async::Task<nil>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Almost the same as #fetch_members_named, but returns a single member.

Returns:

  • (Async::Task<Discorb::Member>)

    The member.

  • (Async::Task<nil>)

    If the member is not found.

Raises:



689
690
691
692
693
# File 'lib/discorb/guild.rb', line 689

def fetch_member_named(...)
  Async do
    fetch_members_named(...).first
  end
end

#fetch_members(limit: 0, after: nil) -> Async::Task<Array<Discorb::Member>> Also known as: fetch_member_list

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Note:

You must enable GUILD_MEMBERS intent to use this method.

Fetch members in the guild.

Parameters:

  • limit (Integer) (defaults to: 0)

    The maximum number of members to fetch, 0 for all.

  • after (Integer) (defaults to: nil)

    The ID of the member to start fetching after.

Returns:

Raises:



641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/discorb/guild.rb', line 641

def fetch_members(limit: 0, after: nil)
  Async do
    unless limit == 0
      _resp, data = @client.http.get("/guilds/#{@id}/members?#{URI.encode_www_form({ after: after, limit: limit })}").wait
      next data[:members].map { |m| Member.new(@client, @id, m[:user], m) }
    end
    ret = []
    after = 0
    loop do
      params = { after: after, limit: 100 }
      _resp, data = @client.http.get("/guilds/#{@id}/members?#{URI.encode_www_form(params)}").wait
      ret += data.map { |m| Member.new(@client, @id, m[:user], m) }
      after = data.last[:user][:id]
      if data.length != 1000
        break
      end
    end
    ret
  end
end

#fetch_members_named(name, limit: 1) -> Async::Task<Array<Discorb::Member>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Search for members by name in the guild.

Parameters:

  • name (String)

    The name of the member to search for.

  • limit (Integer) (defaults to: 1)

    The maximum number of members to return.

Returns:

Raises:



674
675
676
677
678
679
# File 'lib/discorb/guild.rb', line 674

def fetch_members_named(name, limit: 1)
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/members/search?#{URI.encode_www_form({ query: name, limit: limit })}").wait
    data.map { |d| Member.new(@client, @id, d[:user], d) }
  end
end

#fetch_prune(days = 7, roles: []) -> Async::Task<Integer>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch how many members will be pruned.

Parameters:

  • days (Integer) (defaults to: 7)

    The number of days to prune.

  • roles (Array<Discorb::Role>) (defaults to: [])

    The roles that include for pruning.

Returns:

  • (Async::Task<Integer>)

    The number of members that will be pruned.

Raises:



859
860
861
862
863
864
865
866
867
868
869
# File 'lib/discorb/guild.rb', line 859

def fetch_prune(days = 7, roles: [])
  Async do
    params = {
      days: days,
      include_roles: @id.to_s,
    }
    param[:include_roles] = roles.map(&:id).map(&:to_s).join(";") if roles.any?
    _resp, data = @client.http.get("/guilds/#{@id}/prune?#{URI.encode_www_form(params)}").wait
    data[:pruned]
  end
end

#fetch_roles -> Async::Task<Array<Discorb::Role>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch a list of roles in the guild.

Returns:

Raises:



815
816
817
818
819
820
# File 'lib/discorb/guild.rb', line 815

def fetch_roles
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/roles").wait
    data.map { |d| Role.new(@client, self, d) }
  end
end

#fetch_scheduled_event(id) -> Discorb::ScheduledEvent?

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch the scheduled event by ID.

Parameters:

  • id (#to_s)

    The ID of the scheduled event.

Returns:

Raises:



202
203
204
205
206
207
208
209
210
# File 'lib/discorb/guild.rb', line 202

def fetch_scheduled_event(id)
  Async do
    _resp, event = @client.http.get("/guilds/#{@id}/scheduled-events/#{id}").wait
  rescue Discorb::NotFoundError
    return nil
  else
    ScheduledEvent.new(@client, event)
  end
end

#fetch_scheduled_events(with_user_count: true) -> Array<Discorb::ScheduledEvent>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch scheduled events for the guild.

Parameters:

  • with_user_count (Boolean) (defaults to: true)

    Whether to include the user count in the events. Defaults to true.

Returns:

Raises:



185
186
187
188
189
190
# File 'lib/discorb/guild.rb', line 185

def fetch_scheduled_events(with_user_count: true)
  Async do
    _resp, events = @client.http.get("/guilds/#{@id}/scheduled-events?with_user_count=#{with_user_count}").wait
    @scheduled_events = events.map { |e| ScheduledEvent.new(@client, e) }
  end
end

#fetch_sticker(id) -> Async::Task<Discorb::Sticker::GuildSticker>, Async::Task<nil>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch the sticker by ID.

Parameters:

  • id (#to_s)

    The ID of the sticker.

Returns:

Raises:



999
1000
1001
1002
1003
1004
1005
1006
1007
# File 'lib/discorb/guild.rb', line 999

def fetch_sticker(id)
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/stickers/#{id}").wait
  rescue Discorb::NotFoundError
    nil
  else
    Sticker::GuildSticker.new(@client, data)
  end
end

#fetch_stickers -> Async::Task<Array<Discorb::Sticker::GuildSticker>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch stickers in the guild.

Returns:

Raises:



982
983
984
985
986
987
# File 'lib/discorb/guild.rb', line 982

def fetch_stickers
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/stickers").wait
    data.map { |d| Sticker::GuildSticker.new(@client, d) }
  end
end

#fetch_template -> Discorb::GuildTemplate, Async::Task<nil>

Almost the same as #fetch_templates, but returns a single template.

Returns:



1029
1030
1031
1032
1033
# File 'lib/discorb/guild.rb', line 1029

def fetch_template
  Async do
    fetch_templates.wait.first
  end
end

#fetch_templates -> Async::Task<Discorb::GuildTemplate>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch templates in the guild.

Returns:

Raises:



1016
1017
1018
1019
1020
1021
# File 'lib/discorb/guild.rb', line 1016

def fetch_templates
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/templates").wait
    data.map { |d| GuildTemplate.new(@client, d) }
  end
end

#fetch_vanity_invite -> Async::Task<Discorb::Guild::VanityInvite>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch the vanity URL of the guild.

Returns:

Raises:



954
955
956
957
958
959
# File 'lib/discorb/guild.rb', line 954

def fetch_vanity_invite
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/vanity-url").wait
    VanityInvite.new(@client, self, data)
  end
end

#fetch_voice_regions -> Async::Task<Array<Discorb::VoiceRegion>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch voice regions that are available in the guild.

Returns:

Raises:



898
899
900
901
902
903
# File 'lib/discorb/guild.rb', line 898

def fetch_voice_regions
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/voice").wait
    data.map { |d| VoiceRegion.new(@client, d) }
  end
end

#fetch_webhooks -> Async::Task<Array<Discorb::Webhook>>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch webhooks of the guild.

Returns:

Raises:



351
352
353
354
355
356
# File 'lib/discorb/guild.rb', line 351

def fetch_webhooks
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/webhooks").wait
    data.map { |webhook| Webhook.new([@client, webhook]) }
  end
end

#fetch_welcome_screen -> Async::Task<Discorb::Guild::WelcomeScreen>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch the welcome screen of the guild.

Returns:

  • (Async::Task<Discorb::Guild::WelcomeScreen>)

    The welcome screen.

Raises:



968
969
970
971
972
973
# File 'lib/discorb/guild.rb', line 968

def fetch_welcome_screen
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/welcome-screen").wait
    WelcomeScreen.new(@client, self, data)
  end
end

#fetch_widget -> Async::Task<Discorb::Guild::Widget>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Fetch the widget of the guild.

Returns:

Raises:



940
941
942
943
944
945
# File 'lib/discorb/guild.rb', line 940

def fetch_widget
  Async do
    _resp, data = @client.http.get("/guilds/#{@id}/widget").wait
    Widget.new(@client, @id, data)
  end
end

#inspect -> Object



155
156
157
# File 'lib/discorb/guild.rb', line 155

def inspect
  "#<#{self.class} \"#{@name}\" id=#{@id}>"
end

#kick_member(member, reason: nil) -> Object

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Kick a member from the guild.

Parameters:

  • member (Discorb::Member)

    The member to kick.

  • reason (String) (defaults to: nil)

    The reason for kicking the member.

Raises:



719
720
721
722
723
# File 'lib/discorb/guild.rb', line 719

def kick_member(member, reason: nil)
  Async do
    @client.http.delete("/guilds/#{@id}/members/#{member.id}", audit_log_reason: reason).wait
  end
end

#leave! -> Object

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Leave the guild.

Raises:



168
169
170
171
172
173
# File 'lib/discorb/guild.rb', line 168

def leave!
  Async do
    @client.http.delete("/users/@me/guilds/#{@id}").wait
    @client.guilds.delete(@id)
  end
end

#me -> Object



159
160
161
# File 'lib/discorb/guild.rb', line 159

def me
  @members[@client.user.id]
end

#prune(days = 7, roles: [], reason: nil) -> Async::Task<Integer>

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Prune members from the guild.

Parameters:

  • days (Integer) (defaults to: 7)

    The number of days to prune.

  • roles (Array<Discorb::Role>) (defaults to: [])

    The roles that include for pruning.

  • reason (String) (defaults to: nil)

    The reason for pruning.

Returns:

  • (Async::Task<Integer>)

    The number of members that were pruned.

Raises:



882
883
884
885
886
887
888
889
# File 'lib/discorb/guild.rb', line 882

def prune(days = 7, roles: [], reason: nil)
  Async do
    _resp, data = @client.http.post(
      "/guilds/#{@id}/prune", { days: days, roles: roles.map(&:id) }, audit_log_reason: reason,
    ).wait
    data[:pruned]
  end
end

#public_updates_channel -> Object



151
152
153
# File 'lib/discorb/guild.rb', line 151

def public_updates_channel
  @client.channels[@public_updates_channel_id]
end

#rules_channel -> Object



147
148
149
# File 'lib/discorb/guild.rb', line 147

def rules_channel
  @client.channels[@rules_channel_id]
end

#system_channel -> Object



143
144
145
# File 'lib/discorb/guild.rb', line 143

def system_channel
  @client.channels[@system_channel_id]
end

#unban_user(user, reason: nil) -> Object

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Unban a user from the guild.

Parameters:

  • user (Discorb::User)

    The user to unban.

  • reason (String) (defaults to: nil)

    The reason for unbanning the user.

Raises:



802
803
804
805
806
# File 'lib/discorb/guild.rb', line 802

def unban_user(user, reason: nil)
  Async do
    @client.http.delete("/guilds/#{@id}/bans/#{user.id}", audit_log_reason: reason).wait
  end
end