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

#channelChannel (readonly)

Returns the channel this invite references.

Returns:

  • (Channel)

    the channel this invite references.



593
594
595
# File 'lib/discordrb/data.rb', line 593

def channel
  @channel
end

#codeString (readonly)

Returns this invite's code.

Returns:

  • (String)

    this invite's code



614
615
616
# File 'lib/discordrb/data.rb', line 614

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.



602
603
604
# File 'lib/discordrb/data.rb', line 602

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.



608
609
610
# File 'lib/discordrb/data.rb', line 608

def revoked
  @revoked
end

#serverServer (readonly)

Returns the server this invite references.

Returns:

  • (Server)

    the server this invite references.



596
597
598
# File 'lib/discordrb/data.rb', line 596

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.



605
606
607
# File 'lib/discordrb/data.rb', line 605

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.



599
600
601
# File 'lib/discordrb/data.rb', line 599

def uses
  @uses
end

#xkcdtrue, false (readonly) Also known as: xkcd?

Returns whether this invite is in xkcd format (i. e. "Human readable" in the invite settings).

Returns:

  • (true, false)

    whether this invite is in xkcd format (i. e. "Human readable" in the invite settings)



611
612
613
# File 'lib/discordrb/data.rb', line 611

def xkcd
  @xkcd
end

Instance Method Details

#==(other) ⇒ Object

Code based comparison



639
640
641
# File 'lib/discordrb/data.rb', line 639

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

#deleteObject Also known as: revoke

Deletes this invite



644
645
646
# File 'lib/discordrb/data.rb', line 644

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

#inspectObject

The inspect method is overwritten to give more useful output



651
652
653
# File 'lib/discordrb/data.rb', line 651

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