Class: Discordrb::Invite

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data/invite.rb

Overview

A Discord invite to a channel

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#channelInviteChannel, Channel (readonly)



48
49
50
# File 'lib/discordrb/data/invite.rb', line 48

def channel
  @channel
end

#codeString (readonly)



70
71
72
# File 'lib/discordrb/data/invite.rb', line 70

def code
  @code
end

#created_atTime? (readonly)



84
85
86
# File 'lib/discordrb/data/invite.rb', line 84

def created_at
  @created_at
end

#inviterUser? (readonly) Also known as: user



58
59
60
# File 'lib/discordrb/data/invite.rb', line 58

def inviter
  @inviter
end

#max_ageInteger? (readonly)



81
82
83
# File 'lib/discordrb/data/invite.rb', line 81

def max_age
  @max_age
end

#member_countInteger? (readonly) Also known as: user_count



73
74
75
# File 'lib/discordrb/data/invite.rb', line 73

def member_count
  @member_count
end

#online_member_countInteger? (readonly) Also known as: online_user_count



77
78
79
# File 'lib/discordrb/data/invite.rb', line 77

def online_member_count
  @online_member_count
end

#revokedtrue, false (readonly) Also known as: revoked?



66
67
68
# File 'lib/discordrb/data/invite.rb', line 66

def revoked
  @revoked
end

#serverInviteServer, Server (readonly)



51
52
53
# File 'lib/discordrb/data/invite.rb', line 51

def server
  @server
end

#temporarytrue, false (readonly) Also known as: temporary?



62
63
64
# File 'lib/discordrb/data/invite.rb', line 62

def temporary
  @temporary
end

#usesInteger (readonly) Also known as: max_uses



54
55
56
# File 'lib/discordrb/data/invite.rb', line 54

def uses
  @uses
end

Instance Method Details

#==(other) ⇒ Object

Code based comparison



115
116
117
# File 'lib/discordrb/data/invite.rb', line 115

def ==(other)
  other.respond_to?(:code) ? (@code == other.code) : (@code == other)
end

#delete(reason = nil) ⇒ Object Also known as: revoke

Deletes this invite



121
122
123
# File 'lib/discordrb/data/invite.rb', line 121

def delete(reason = nil)
  API::Invite.delete(@bot.token, @code, reason)
end

#inspectObject

The inspect method is overwritten to give more useful output



128
129
130
# File 'lib/discordrb/data/invite.rb', line 128

def inspect
  "<Invite code=#{@code} channel=#{@channel} uses=#{@uses} temporary=#{@temporary} revoked=#{@revoked} created_at=#{@created_at} max_age=#{@max_age}>"
end

#urlObject

Creates an invite URL.



133
134
135
# File 'lib/discordrb/data/invite.rb', line 133

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