Class: Discorb::Interaction

Inherits:
DiscordModel show all
Defined in:
lib/discorb/interaction.rb

Overview

Represents a user interaction with the bot.

Defined Under Namespace

Modules: SourceResponse, UpdateResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #hash

Instance Attribute Details

#application_id -> Discorb::Snowflake (readonly)

Returns The ID of the application that created the interaction.

Returns:



11
12
13
# File 'lib/discorb/interaction.rb', line 11

def application_id
  @application_id
end

#id -> Discorb::Snowflake (readonly)

Returns The ID of the interaction.

Returns:



9
10
11
# File 'lib/discorb/interaction.rb', line 9

def id
  @id
end

#member -> Discorb::Member (readonly)

Returns The member that created the interaction.

Returns:



15
16
17
# File 'lib/discorb/interaction.rb', line 15

def member
  @member
end

#token -> String (readonly)

Returns The token for the interaction.

Returns:

  • (String)

    The token for the interaction.



22
23
24
# File 'lib/discorb/interaction.rb', line 22

def token
  @token
end

#type -> Symbol (readonly)

Returns The type of interaction.

Returns:

  • (Symbol)

    The type of interaction.



13
14
15
# File 'lib/discorb/interaction.rb', line 13

def type
  @type
end

#user -> Discorb::User (readonly)

Returns The user that created the interaction.

Returns:



17
18
19
# File 'lib/discorb/interaction.rb', line 17

def user
  @user
end

#version -> Integer (readonly)

Note:

This is always 1 for now.

Returns The type of interaction.

Returns:

  • (Integer)

    The type of interaction.



20
21
22
# File 'lib/discorb/interaction.rb', line 20

def version
  @version
end

Instance Method Details

#channel -> Object



58
59
60
# File 'lib/discorb/interaction.rb', line 58

def channel
  @client.channels[@channel_id]
end

#guild -> Object



54
55
56
# File 'lib/discorb/interaction.rb', line 54

def guild
  @client.guilds[@guild_id]
end

#inspect -> Object



68
69
70
# File 'lib/discorb/interaction.rb', line 68

def inspect
  "#<#{self.class} id=#{@id}>"
end

#target -> Object Also known as: fired_by



62
63
64
# File 'lib/discorb/interaction.rb', line 62

def target
  @member || @user
end