Class: MijDiscord::Data::Invite

Inherits:
Object
  • Object
show all
Defined in:
lib/mij-discord/data/invite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#channelObject (readonly)

Returns the value of attribute channel.



37
38
39
# File 'lib/mij-discord/data/invite.rb', line 37

def channel
  @channel
end

#codeObject (readonly)

Returns the value of attribute code.



41
42
43
# File 'lib/mij-discord/data/invite.rb', line 41

def code
  @code
end

#inviterObject (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_usesObject (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

#revokedObject (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

#serverObject (readonly)

Returns the value of attribute server.



39
40
41
# File 'lib/mij-discord/data/invite.rb', line 39

def server
  @server
end

#temporaryObject (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_urlObject



79
80
81
# File 'lib/mij-discord/data/invite.rb', line 79

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