Class: Discordrb::Events::TypingEvent
- Includes:
- Respondable
- Defined in:
- lib/discordrb/events/typing.rb
Overview
Event raised when a user starts typing
Instance Attribute Summary collapse
-
#channel ⇒ Channel
readonly
The channel on which a user started typing.
-
#timestamp ⇒ Time
readonly
When the typing happened.
-
#user ⇒ User, ...
(also: #member)
readonly
The user that started typing.
Attributes inherited from Event
Instance Method Summary collapse
-
#initialize(data, bot) ⇒ TypingEvent
constructor
A new instance of TypingEvent.
Methods included from Respondable
#<<, #drain, #drain_into, #send_embed, #send_message, #send_temporary_message
Constructor Details
#initialize(data, bot) ⇒ TypingEvent
Returns a new instance of TypingEvent.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/discordrb/events/typing.rb', line 20 def initialize(data, bot) @bot = bot @user_id = data['user_id'].to_i @channel_id = data['channel_id'].to_i @channel = bot.channel(@channel_id) @user = if channel.pm? channel.recipient elsif channel.group? bot.user(@user_id) else bot.member(@channel.server.id, @user_id) end @timestamp = Time.at(data['timestamp'].to_i) end |
Instance Attribute Details
#channel ⇒ Channel (readonly)
Returns the channel on which a user started typing.
11 12 13 |
# File 'lib/discordrb/events/typing.rb', line 11 def channel @channel end |
#timestamp ⇒ Time (readonly)
Returns when the typing happened.
18 19 20 |
# File 'lib/discordrb/events/typing.rb', line 18 def @timestamp end |
#user ⇒ User, ... (readonly) Also known as: member
Returns the user that started typing.
14 15 16 |
# File 'lib/discordrb/events/typing.rb', line 14 def user @user end |