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)


1115
1116
1117
# File 'lib/discordrb/data.rb', line 1115

def channel
  @channel
end

#codeString (readonly)


1137
1138
1139
# File 'lib/discordrb/data.rb', line 1137

def code
  @code
end

#created_atTime? (readonly)


1151
1152
1153
# File 'lib/discordrb/data.rb', line 1151

def created_at
  @created_at
end

#inviterUser? (readonly) Also known as: user


1125
1126
1127
# File 'lib/discordrb/data.rb', line 1125

def inviter
  @inviter
end

#max_ageInteger? (readonly)


1148
1149
1150
# File 'lib/discordrb/data.rb', line 1148

def max_age
  @max_age
end

#member_countInteger? (readonly) Also known as: user_count


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

def member_count
  @member_count
end

#online_member_countInteger? (readonly) Also known as: online_user_count


1144
1145
1146
# File 'lib/discordrb/data.rb', line 1144

def online_member_count
  @online_member_count
end

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


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

def revoked
  @revoked
end

#serverInviteServer (readonly)


1118
1119
1120
# File 'lib/discordrb/data.rb', line 1118

def server
  @server
end

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


1129
1130
1131
# File 'lib/discordrb/data.rb', line 1129

def temporary
  @temporary
end

#usesInteger (readonly) Also known as: max_uses


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

def uses
  @uses
end

Instance Method Details

#==(other) ⇒ Object

Code based comparison


1172
1173
1174
# File 'lib/discordrb/data.rb', line 1172

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

#delete(reason = nil) ⇒ Object Also known as: revoke

Deletes this invite


1178
1179
1180
# File 'lib/discordrb/data.rb', line 1178

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

#inspectObject

The inspect method is overwritten to give more useful output


1185
1186
1187
# File 'lib/discordrb/data.rb', line 1185

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

#urlObject

Creates an invite URL.


1190
1191
1192
# File 'lib/discordrb/data.rb', line 1190

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