Module: OnyxCord::Bot::Cogs
- Included in:
- OnyxCord::Bot
- Defined in:
- lib/onyxcord/cogs/bot.rb
Instance Attribute Summary collapse
-
#cogs ⇒ Object
readonly
Returns the value of attribute cogs.
Instance Method Summary collapse
Instance Attribute Details
#cogs ⇒ Object (readonly)
Returns the value of attribute cogs.
6 7 8 |
# File 'lib/onyxcord/cogs/bot.rb', line 6 def cogs @cogs end |
Instance Method Details
#add_cog(cog) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/onyxcord/cogs/bot.rb', line 8 def add_cog(cog) @cogs ||= {} raise ArgumentError, "Cog #{cog.qualified_name} is already loaded" if @cogs.key?(cog.qualified_name) cog._inject(self) @cogs[cog.qualified_name] = cog end |
#get_cog(name) ⇒ Object
22 23 24 25 |
# File 'lib/onyxcord/cogs/bot.rb', line 22 def get_cog(name) @cogs ||= {} @cogs[name.to_s] end |
#remove_cog(name) ⇒ Object
16 17 18 19 20 |
# File 'lib/onyxcord/cogs/bot.rb', line 16 def remove_cog(name) @cogs ||= {} cog = @cogs.delete(name.to_s) cog&._eject(self) end |