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:


1082
1083
1084
# File 'lib/discordrb/data.rb', line 1082

def channel
  @channel
end

#codeString (readonly)

Returns this invite's code.

Returns:

  • (String)

    this invite's code


1104
1105
1106
# File 'lib/discordrb/data.rb', line 1104

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.


1092
1093
1094
# File 'lib/discordrb/data.rb', line 1092

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.


1100
1101
1102
# File 'lib/discordrb/data.rb', line 1100

def revoked
  @revoked
end

#serverInviteServer (readonly)

Returns the server this invite references.

Returns:


1085
1086
1087
# File 'lib/discordrb/data.rb', line 1085

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.


1096
1097
1098
# File 'lib/discordrb/data.rb', line 1096

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.


1088
1089
1090
# File 'lib/discordrb/data.rb', line 1088

def uses
  @uses
end

Instance Method Details

#==(other) ⇒ Object

Code based comparison


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

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.


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

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

#inspectObject

The inspect method is overwritten to give more useful output


1134
1135
1136
# File 'lib/discordrb/data.rb', line 1134

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

#urlObject

Creates an invite URL.


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

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