Class: Discordrb::Events::PollVoteEvent

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

Overview

Generic superclass for poll events.

Direct Known Subclasses

PollVoteAddEvent, PollVoteRemoveEvent

Instance Attribute Summary collapse

Attributes inherited from Event

#bot

Instance Method Summary collapse

Instance Attribute Details

#answer_idInteger (readonly)

Returns the ID of the answer associated with the event.

Returns:

  • (Integer)

    the ID of the answer associated with the event.



17
18
19
# File 'lib/discordrb/events/polls.rb', line 17

def answer_id
  @answer_id
end

#channel_idInteger (readonly)

Returns the ID of the channel associated with the event.

Returns:

  • (Integer)

    the ID of the channel associated with the event.



20
21
22
# File 'lib/discordrb/events/polls.rb', line 20

def channel_id
  @channel_id
end

#message_idInteger (readonly)

Returns the ID of the message associated with the event.

Returns:

  • (Integer)

    the ID of the message associated with the event.



23
24
25
# File 'lib/discordrb/events/polls.rb', line 23

def message_id
  @message_id
end

#server_idInteger? (readonly)

Returns the ID of the server associated with the event.

Returns:

  • (Integer, nil)

    the ID of the server associated with the event.



14
15
16
# File 'lib/discordrb/events/polls.rb', line 14

def server_id
  @server_id
end

#user_idInteger (readonly)

Returns the ID of the user associated with the event.

Returns:

  • (Integer)

    the ID of the user associated with the event.



10
11
12
# File 'lib/discordrb/events/polls.rb', line 10

def user_id
  @user_id
end

Instance Method Details

#answerPoll::Answer

Get the poll answer associated with the event.

Returns:

  • (Poll::Answer)

    The poll answer associated with the event.



43
44
45
# File 'lib/discordrb/events/polls.rb', line 43

def answer
  poll&.answer(@answer_id)
end

#channelChannel

Get the channel that the poll originates from.

Returns:

  • (Channel)

    The channel that the poll originates from.



49
50
51
# File 'lib/discordrb/events/polls.rb', line 49

def channel
  @bot.channel(@channel_id)
end

#messageMessage

Get the message that the poll originates from.

Returns:

  • (Message)

    The message that the poll originates from.



61
62
63
# File 'lib/discordrb/events/polls.rb', line 61

def message
  @message ||= channel.load_message(@message_id)
end

#pollPoll

Get the poll associated with the event.

Returns:

  • (Poll)

    The poll associated with the event.



37
38
39
# File 'lib/discordrb/events/polls.rb', line 37

def poll
  message&.poll
end

#serverServer?

Get the server that the poll originates from.

Returns:

  • (Server, nil)

    The server that the poll originates from.



55
56
57
# File 'lib/discordrb/events/polls.rb', line 55

def server
  @bot.server(@server_id) if @server_id
end

#userUser, Member Also known as: member

Get the user who added or removed their poll vote.

Returns:

  • (User, Member)

    The member who added the poll vote, or a user if the member cannot be reached, or the poll was created in a DM channel.



69
70
71
# File 'lib/discordrb/events/polls.rb', line 69

def user
  @user ||= (server&.member(@user_id) || @bot.user(@user_id))
end