Class: Discordrb::Invite

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

Overview

A Discord invite to a channel

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#channelInviteChannel (readonly)

Returns the channel this invite references.

Returns:



1122
1123
1124
# File 'lib/discordrb/data.rb', line 1122

def channel
  @channel
end

#codeString (readonly)

Returns this invite's code.

Returns:

  • (String)

    this invite's code



1144
1145
1146
# File 'lib/discordrb/data.rb', line 1144

def code
  @code
end

#created_atTime? (readonly)

Returns when this invite was created, or nil if it's unknown.

Returns:

  • (Time, nil)

    when this invite was created, or nil if it's unknown



1158
1159
1160
# File 'lib/discordrb/data.rb', line 1158

def created_at
  @created_at
end

#inviterUser? (readonly) Also known as: user

Returns the user that made this invite. May also be nil if the user can't be determined.

Returns:

  • (User, nil)

    the user that made this invite. May also be nil if the user can't be determined.



1132
1133
1134
# File 'lib/discordrb/data.rb', line 1132

def inviter
  @inviter
end

#max_ageInteger? (readonly)

Returns the invites max age before it expires, or nil if it's unknown. If the max age is 0, the invite will never expire unless it's deleted.

Returns:

  • (Integer, nil)

    the invites max age before it expires, or nil if it's unknown. If the max age is 0, the invite will never expire unless it's deleted.



1155
1156
1157
# File 'lib/discordrb/data.rb', line 1155

def max_age
  @max_age
end

#member_countInteger? (readonly) Also known as: user_count

Returns the amount of members in the server. Will be nil if it has not been resolved.

Returns:

  • (Integer, nil)

    the amount of members in the server. Will be nil if it has not been resolved.



1147
1148
1149
# File 'lib/discordrb/data.rb', line 1147

def member_count
  @member_count
end

#online_member_countInteger? (readonly) Also known as: online_user_count

Returns the amount of online members in the server. Will be nil if it has not been resolved.

Returns:

  • (Integer, nil)

    the amount of online members in the server. Will be nil if it has not been resolved.



1151
1152
1153
# File 'lib/discordrb/data.rb', line 1151

def online_member_count
  @online_member_count
end

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

Returns whether this invite is still valid.

Returns:

  • (true, false)

    whether this invite is still valid.



1140
1141
1142
# File 'lib/discordrb/data.rb', line 1140

def revoked
  @revoked
end

#serverInviteServer (readonly)

Returns the server this invite references.

Returns:



1125
1126
1127
# File 'lib/discordrb/data.rb', line 1125

def server
  @server
end

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

Returns whether or not this invite grants temporary membership. If someone joins a server with this invite, they will be removed from the server when they go offline unless they've received a role.

Returns:

  • (true, false)

    whether or not this invite grants temporary membership. If someone joins a server with this invite, they will be removed from the server when they go offline unless they've received a role.



1136
1137
1138
# File 'lib/discordrb/data.rb', line 1136

def temporary
  @temporary
end

#usesInteger (readonly) Also known as: max_uses

Returns the amount of uses left on this invite.

Returns:

  • (Integer)

    the amount of uses left on this invite.



1128
1129
1130
# File 'lib/discordrb/data.rb', line 1128

def uses
  @uses
end

Instance Method Details

#==(other) ⇒ Object

Code based comparison



1179
1180
1181
# File 'lib/discordrb/data.rb', line 1179

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

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

Deletes this invite

Parameters:

  • reason (String) (defaults to: nil)

    The reason the invite is being deleted.



1185
1186
1187
# File 'lib/discordrb/data.rb', line 1185

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

#inspectObject

The inspect method is overwritten to give more useful output



1192
1193
1194
# File 'lib/discordrb/data.rb', line 1192

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.



1197
1198
1199
# File 'lib/discordrb/data.rb', line 1197

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