Module: OnyxCord::Commands::Bot::Channels
- Included in:
- OnyxCord::Commands::Bot
- Defined in:
- lib/onyxcord/commands/bot/channels.rb
Overview
Channel restriction logic for command bots.
Instance Method Summary collapse
-
#add_channel(channel) ⇒ Object
Add a channel to the list of channels the bot accepts commands from.
- #channels=(channels) ⇒ Object
-
#remove_channel(channel) ⇒ Object
Remove a channel from the list of channels the bot accepts commands from.
-
#update_channels(channels = []) ⇒ Object
Update the list of channels the bot accepts commands from.
Instance Method Details
#add_channel(channel) ⇒ Object
Add a channel to the list of channels the bot accepts commands from.
21 22 23 24 25 |
# File 'lib/onyxcord/commands/bot/channels.rb', line 21 def add_channel(channel) return if @attributes[:channels].find { |c| channel.resolve_id == c.resolve_id } @attributes[:channels] << channel end |
#channels=(channels) ⇒ Object
7 8 9 |
# File 'lib/onyxcord/commands/bot/channels.rb', line 7 def channels=(channels) update_channels(channels) end |
#remove_channel(channel) ⇒ Object
Remove a channel from the list of channels the bot accepts commands from.
30 31 32 |
# File 'lib/onyxcord/commands/bot/channels.rb', line 30 def remove_channel(channel) @attributes[:channels].delete_if { |c| channel.resolve_id == c.resolve_id } end |
#update_channels(channels = []) ⇒ Object
Update the list of channels the bot accepts commands from.
14 15 16 |
# File 'lib/onyxcord/commands/bot/channels.rb', line 14 def update_channels(channels = []) @attributes[:channels] = Array(channels) end |