Class: MijDiscord::Data::Invite
- Inherits:
-
Object
- Object
- MijDiscord::Data::Invite
- Defined in:
- lib/mij-discord/data/invite.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#inviter ⇒ Object
(also: #user)
readonly
Returns the value of attribute inviter.
-
#max_uses ⇒ Object
(also: #uses)
readonly
Returns the value of attribute max_uses.
-
#revoked ⇒ Object
(also: #revoked?)
readonly
Returns the value of attribute revoked.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#temporary ⇒ Object
(also: #temporary?)
readonly
Returns the value of attribute temporary.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #delete(reason = nil) ⇒ Object (also: #revoke)
-
#initialize(data, bot) ⇒ Invite
constructor
A new instance of Invite.
- #invite_url ⇒ Object
Constructor Details
#initialize(data, bot) ⇒ Invite
Returns a new instance of Invite.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/mij-discord/data/invite.rb', line 55 def initialize(data, bot) @bot = bot @channel = InviteChannel.new(data['channel'], bot) @server = InviteServer.new(data['guild'], bot) @code, @max_uses = data['code'], data['uses'] @temporary, @revoked = data['temporary'], data['revoked'] @inviter = data['inviter'] ? @bot.cache.put_user(data['inviter']) : nil end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
37 38 39 |
# File 'lib/mij-discord/data/invite.rb', line 37 def channel @channel end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
41 42 43 |
# File 'lib/mij-discord/data/invite.rb', line 41 def code @code end |
#inviter ⇒ Object (readonly) Also known as: user
Returns the value of attribute inviter.
46 47 48 |
# File 'lib/mij-discord/data/invite.rb', line 46 def inviter @inviter end |
#max_uses ⇒ Object (readonly) Also known as: uses
Returns the value of attribute max_uses.
43 44 45 |
# File 'lib/mij-discord/data/invite.rb', line 43 def max_uses @max_uses end |
#revoked ⇒ Object (readonly) Also known as: revoked?
Returns the value of attribute revoked.
52 53 54 |
# File 'lib/mij-discord/data/invite.rb', line 52 def revoked @revoked end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
39 40 41 |
# File 'lib/mij-discord/data/invite.rb', line 39 def server @server end |
#temporary ⇒ Object (readonly) Also known as: temporary?
Returns the value of attribute temporary.
49 50 51 |
# File 'lib/mij-discord/data/invite.rb', line 49 def temporary @temporary end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
67 68 69 |
# File 'lib/mij-discord/data/invite.rb', line 67 def ==(other) @code == (other.respond_to?(:code) ? other.code : other) end |
#delete(reason = nil) ⇒ Object Also known as: revoke
73 74 75 |
# File 'lib/mij-discord/data/invite.rb', line 73 def delete(reason = nil) MijDiscord::Core::API::Invite.delete(@bot.auth, @code, reason) end |
#invite_url ⇒ Object
79 80 81 |
# File 'lib/mij-discord/data/invite.rb', line 79 def invite_url "https://discord.gg/#{@code}" end |