Class: Discorb::Invite

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

Overview

Represents invite of discord.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

#approximate_member_countInteger (readonly)

Returns The approximate number of members of invite.

Returns:

  • (Integer)

    The approximate number of members of invite.



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

def approximate_member_count
  @approximate_member_count
end

#approximate_presence_countInteger (readonly)

Returns The approximate number of online users of invite.

Returns:

  • (Integer)

    The approximate number of online users of invite.



18
19
20
# File 'lib/discorb/invite.rb', line 18

def approximate_presence_count
  @approximate_presence_count
end

#channelDiscorb::Channel? (readonly)

Note:

This method returns an object from client cache. it will return nil if the object is not in cache.

Channel of the invite.

Returns:



# File 'lib/discorb/invite.rb', line 45

#codeString (readonly)

Returns The code of invite.

Returns:

  • (String)

    The code of invite.



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

def code
  @code
end

#created_atTime? (readonly)

Returns:

  • (Time)

    The time when invite was created.

  • (nil)

    The invite doesn't have metadata.



43
44
45
# File 'lib/discorb/invite.rb', line 43

def created_at
  @created_at
end

#expires_atTime? (readonly)

Returns:

  • (Time)

    The time when invite expires.

  • (nil)

    The invite never expires.

  • (nil)

    The invite doesn't have metadata.



27
28
29
# File 'lib/discorb/invite.rb', line 27

def expires_at
  @expires_at
end

#guildDiscorb::Guild? (readonly)

Note:

This method returns an object from client cache. it will return nil if the object is not in cache.

Guild of the invite.

Returns:

  • (Discorb::Guild)

    Guild of invite.

  • (nil)

    The object wasn't cached.



# File 'lib/discorb/invite.rb', line 45

#max_ageInteger? (readonly)

Returns:

  • (Integer)

    Duration of invite in seconds.

  • (nil)

    The invite doesn't have metadata.



39
40
41
# File 'lib/discorb/invite.rb', line 39

def max_age
  @max_age
end

#max_usesInteger? (readonly)

Returns:

  • (Integer)

    The maximum number of uses of invite.

  • (nil)

    The invite doesn't have metadata.



35
36
37
# File 'lib/discorb/invite.rb', line 35

def max_uses
  @max_uses
end

#remain_usesInteger (readonly)

Number of remaining uses of invite.

Returns:

  • (Integer)

    Number of remaining uses of invite.



# File 'lib/discorb/invite.rb', line 45

#target_type:voice, ... (readonly)

Returns The type of invite.

Returns:

  • (:voice, :stream, :guild)

    The type of invite.



12
13
14
# File 'lib/discorb/invite.rb', line 12

def target_type
  @target_type
end

#target_userUser (readonly)

Returns The user of invite.

Returns:

  • (User)

    The user of invite.



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

def target_user
  @target_user
end

#temporary?Boolean (readonly)

Whether the invite is temporary.

Returns:

  • (Boolean)


# File 'lib/discorb/invite.rb', line 45

#urlString (readonly)

Full url of invite.

Returns:

  • (String)

    Full url of invite.



# File 'lib/discorb/invite.rb', line 45

#usesInteger? (readonly)

Returns:

  • (Integer)

    The number of uses of invite.

  • (nil)

    The invite doesn't have metadata.



31
32
33
# File 'lib/discorb/invite.rb', line 31

def uses
  @uses
end

Instance Method Details

#delete(reason: nil) ⇒ Async::Task<void>

Delete the invite.

Returns:

  • (Async::Task<void>)

    The task.



111
112
113
114
115
116
117
118
119
# File 'lib/discorb/invite.rb', line 111

def delete(reason: nil)
  Async do
    @client.http.request(
      Route.new("/invites/#{@code}", "//invites/:code", :delete),
      {},
      audit_log_reason: reason
    )
  end
end