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:



974
975
976
# File 'lib/discordrb/data.rb', line 974

def channel
  @channel
end

#codeString (readonly)

Returns this invite's code.

Returns:

  • (String)

    this invite's code



996
997
998
# File 'lib/discordrb/data.rb', line 996

def code
  @code
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.



984
985
986
# File 'lib/discordrb/data.rb', line 984

def inviter
  @inviter
end

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

Returns whether this invite is still valid.

Returns:

  • (true, false)

    whether this invite is still valid.



992
993
994
# File 'lib/discordrb/data.rb', line 992

def revoked
  @revoked
end

#serverInviteServer (readonly)

Returns the server this invite references.

Returns:



977
978
979
# File 'lib/discordrb/data.rb', line 977

def server
  @server
end

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

Returns whether or not this invite is temporary.

Returns:

  • (true, false)

    whether or not this invite is temporary.



988
989
990
# File 'lib/discordrb/data.rb', line 988

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.



980
981
982
# File 'lib/discordrb/data.rb', line 980

def uses
  @uses
end

Instance Method Details

#==(other) ⇒ Object

Code based comparison



1013
1014
1015
# File 'lib/discordrb/data.rb', line 1013

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

#deleteObject Also known as: revoke

Deletes this invite



1018
1019
1020
# File 'lib/discordrb/data.rb', line 1018

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

#inspectObject

The inspect method is overwritten to give more useful output



1025
1026
1027
# File 'lib/discordrb/data.rb', line 1025

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

#urlObject

Creates an invite URL.



1030
1031
1032
# File 'lib/discordrb/data.rb', line 1030

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