Class: Discordrb::Events::TypingEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/discordrb/events/typing.rb

Overview

Event raised when a user starts typing

Instance Attribute Summary collapse

Attributes inherited from Event

#bot

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ TypingEvent

Returns a new instance of TypingEvent.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/discordrb/events/typing.rb', line 18

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 = channel.private? ? channel.recipient : bot.member(@channel.server.id, @user_id)

  @timestamp = Time.at(data['timestamp'].to_i)
end

Instance Attribute Details

#channelChannel (readonly)

Returns the channel on which a user started typing.

Returns:

  • (Channel)

    the channel on which a user started typing.



9
10
11
# File 'lib/discordrb/events/typing.rb', line 9

def channel
  @channel
end

#timestampTime (readonly)

Returns when the typing happened.

Returns:

  • (Time)

    when the typing happened.



16
17
18
# File 'lib/discordrb/events/typing.rb', line 16

def timestamp
  @timestamp
end

#userMember (readonly) Also known as: member

Returns the user that started typing.

Returns:

  • (Member)

    the user that started typing.



12
13
14
# File 'lib/discordrb/events/typing.rb', line 12

def user
  @user
end