Class: OnyxCord::Interactions::Context
- Inherits:
-
Object
- Object
- OnyxCord::Interactions::Context
- Defined in:
- lib/onyxcord/interactions/context.rb
Defined Under Namespace
Classes: Proxy
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
Instance Method Summary collapse
- #bot ⇒ Object
- #channel ⇒ Object
- #channel_id ⇒ Object
- #defer ⇒ Object
- #delete_original ⇒ Object
- #edit_original ⇒ Object
- #followup ⇒ Object
- #guild ⇒ Object
- #guild_id ⇒ Object
- #guild_locale ⇒ Object
-
#initialize(event, command) ⇒ Context
constructor
A new instance of Context.
- #locale ⇒ Object
- #member ⇒ Object
- #options ⇒ Object
- #respond ⇒ Object
- #server ⇒ Object
- #server_id ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(event, command) ⇒ Context
Returns a new instance of Context.
8 9 10 11 |
# File 'lib/onyxcord/interactions/context.rb', line 8 def initialize(event, command) @event = event @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/onyxcord/interactions/context.rb', line 6 def command @command end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
6 7 8 |
# File 'lib/onyxcord/interactions/context.rb', line 6 def event @event end |
Instance Method Details
#bot ⇒ Object
13 14 15 |
# File 'lib/onyxcord/interactions/context.rb', line 13 def bot event.bot end |
#channel ⇒ Object
35 36 37 |
# File 'lib/onyxcord/interactions/context.rb', line 35 def channel event.channel end |
#channel_id ⇒ Object
39 40 41 |
# File 'lib/onyxcord/interactions/context.rb', line 39 def channel_id event.channel_id end |
#defer ⇒ Object
78 79 80 |
# File 'lib/onyxcord/interactions/context.rb', line 78 def defer(...) event.defer(...) end |
#delete_original ⇒ Object
86 87 88 |
# File 'lib/onyxcord/interactions/context.rb', line 86 def delete_original event.delete_response end |
#edit_original ⇒ Object
82 83 84 |
# File 'lib/onyxcord/interactions/context.rb', line 82 def edit_original(...) event.edit_response(...) end |
#followup ⇒ Object
90 91 92 |
# File 'lib/onyxcord/interactions/context.rb', line 90 def followup(...) event.(...) end |
#guild ⇒ Object
27 28 29 |
# File 'lib/onyxcord/interactions/context.rb', line 27 def guild event.server end |
#guild_id ⇒ Object
31 32 33 |
# File 'lib/onyxcord/interactions/context.rb', line 31 def guild_id event.server_id end |
#guild_locale ⇒ Object
55 56 57 |
# File 'lib/onyxcord/interactions/context.rb', line 55 def guild_locale event.server_locale end |
#locale ⇒ Object
51 52 53 |
# File 'lib/onyxcord/interactions/context.rb', line 51 def locale event.user_locale end |
#member ⇒ Object
21 22 23 24 25 |
# File 'lib/onyxcord/interactions/context.rb', line 21 def member return unless event.respond_to?(:interaction) && event.interaction event.interaction.user if event.interaction.user.is_a?(OnyxCord::Member) end |
#options ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/onyxcord/interactions/context.rb', line 59 def return {} unless event.data if event.data['options'] result = {} event.data['options'].each do |opt| key = opt['name'].to_sym result[key] = opt['value'] end result else {} end end |
#respond ⇒ Object
74 75 76 |
# File 'lib/onyxcord/interactions/context.rb', line 74 def respond(...) event.respond(...) end |
#server ⇒ Object
43 44 45 |
# File 'lib/onyxcord/interactions/context.rb', line 43 def server event.server end |
#server_id ⇒ Object
47 48 49 |
# File 'lib/onyxcord/interactions/context.rb', line 47 def server_id event.server_id end |
#user ⇒ Object
17 18 19 |
# File 'lib/onyxcord/interactions/context.rb', line 17 def user event.user end |