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?, #hash

Instance Attribute Details

#approximate_member_count -> Integer (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_count -> Integer (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

#code -> String (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_at -> Time? (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_at -> Time? (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

#max_age -> Integer? (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_uses -> Integer? (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

#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_user -> User (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

#uses -> Integer? (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

#channel -> Object



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

def channel
  @client.channels[@channel_data[:id]]
end

#delete!(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.

Delete the invite.

Raises:



105
106
107
108
109
# File 'lib/discorb/invite.rb', line 105

def delete!(reason: nil)
  Async do
    @client.internet.delete("/invites/#{@code}", audit_log_reason: reason)
  end
end

#guild -> Object



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

def guild
  @client.guilds[@guild_data[:id]]
end

#remain_uses -> Object



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

def remain_uses
  @max_uses && @max_uses - @uses
end

#temporary? -> Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/discorb/invite.rb', line 98

def temporary?
  @temporary
end

#url -> Object



90
91
92
# File 'lib/discorb/invite.rb', line 90

def url
  "https://discord.gg/#{@code}"
end