Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
Allow passing plugin config on load, add API channel invite
Browse files Browse the repository at this point in the history
  • Loading branch information
b1naryth1ef committed Oct 7, 2016
1 parent cfc40a0 commit 37a37fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# disco
Disco is a simple and extendable library for the [Discord API](https://discordapp.com/developers/docs/intro).
Disco is a simple and extendable library for the [Discord API](https://discordapp.com/developers/docs/intro). Join the Official channel and chat [here](https://discord.gg/XJRZSQk).

- Expressive, functional interface that gets out of the way
- Built for high-performance and efficiency
Expand Down
7 changes: 5 additions & 2 deletions disco/bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,22 @@ def on_message_update(self, event):

self.last_message_cache[msg.channel_id] = (msg, triggered)

def add_plugin(self, cls):
def add_plugin(self, cls, config=None):
"""
Adds and loads a plugin, based on its class.
Parameters
----------
cls : subclass of :class:`disco.bot.plugin.Plugin`
Plugin class to initialize and load.
config : Optional
The configuration to load the plugin with.
"""
if cls.__name__ in self.plugins:
raise Exception('Cannot add already added plugin: {}'.format(cls.__name__))

config = self.config.plugin_config_provider(cls.__name__) if self.config.plugin_config_provider else None
if not config and callable(self.config.plugin_config_provider):
config = self.config.plugin_config_provider(cls.__name__)

self.plugins[cls.__name__] = cls(self, config)
self.plugins[cls.__name__].load()
Expand Down

0 comments on commit 37a37fc

Please sign in to comment.