class Discordrb::Invite
A Discord invite to a channel
Attributes
@return [InviteChannel, Channel] the channel this invite references.
@return [String] this invite’s code
@return [Time, nil] when this invite was created, or nil if it’s unknown
@return [User, nil] the user that made this invite. May also be nil if the user can’t be determined.
@return [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.
@return [Integer] the amount of uses left on this invite.
@return [Integer, nil] the amount of members in the server. Will be nil if it has not been resolved.
@return [Integer, nil] the amount of online members in the server. Will be nil if it has not been resolved.
@return [Integer, nil] the amount of online members in the server. Will be nil if it has not been resolved.
@return [true, false] whether this invite is still valid.
@return [true, false] whether this invite is still valid.
@return [InviteServer, Server] the server this invite references.
@return [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.
@return [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.
@return [User, nil] the user that made this invite. May also be nil if the user can’t be determined.
@return [Integer, nil] the amount of members in the server. Will be nil if it has not been resolved.
@return [Integer] the amount of uses left on this invite.
Public Class Methods
@!visibility private
# File lib/discordrb/data/invite.rb, line 87 def initialize(data, bot) @bot = bot @channel = if data['channel_id'] bot.channel(data['channel_id']) else InviteChannel.new(data['channel'], bot) end @server = if data['guild_id'] bot.server(data['guild_id']) else InviteServer.new(data['guild'], bot) end @uses = data['uses'] @inviter = data['inviter'] ? bot.ensure_user(data['inviter']) : nil @temporary = data['temporary'] @revoked = data['revoked'] @online_member_count = data['approximate_presence_count'] @member_count = data['approximate_member_count'] @max_age = data['max_age'] @created_at = data['created_at'] @code = data['code'] end
Public Instance Methods
Code based comparison
# File lib/discordrb/data/invite.rb, line 115 def ==(other) other.respond_to?(:code) ? (@code == other.code) : (@code == other) end
Deletes this invite @param reason [String] The reason the invite is being deleted.
# File lib/discordrb/data/invite.rb, line 121 def delete(reason = nil) API::Invite.delete(@bot.token, @code, reason) end
The inspect method is overwritten to give more useful output
# 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
Creates an invite URL.
# File lib/discordrb/data/invite.rb, line 133 def url "https://discord.gg/#{@code}" end