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:



937
938
939
# File 'lib/discordrb/data.rb', line 937

def channel
  @channel
end

#codeString (readonly)

Returns this invite's code.

Returns:

  • (String)

    this invite's code



959
960
961
# File 'lib/discordrb/data.rb', line 959

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.



947
948
949
# File 'lib/discordrb/data.rb', line 947

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.



955
956
957
# File 'lib/discordrb/data.rb', line 955

def revoked
  @revoked
end

#serverInviteServer (readonly)

Returns the server this invite references.

Returns:



940
941
942
# File 'lib/discordrb/data.rb', line 940

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.



951
952
953
# File 'lib/discordrb/data.rb', line 951

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.



943
944
945
# File 'lib/discordrb/data.rb', line 943

def uses
  @uses
end

Instance Method Details

#==(other) ⇒ Object

Code based comparison



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

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

#deleteObject Also known as: revoke

Deletes this invite



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

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

#inspectObject

The inspect method is overwritten to give more useful output



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

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

#urlObject

Creates an invite URL.



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

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