You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Matthew Carey edited this page Nov 15, 2020
·
1 revision
Starting with release 1.7.0, discordrb allows you to make bots highly modular using container modules. These are modules that extend the EventContainer or CommandContainer modules - Bot classes extend them by default. The powerful feature is that a container can be included into another container, which copies over all events (or commands) from the included container into the including container. See this example:
This creates a new container that contains one event, and then later includes it using the include! method. (Even though this method is called include_events by default, it is recommended to use include! to be consistent with command events, where including events and commands have to be separate.) Of course, the same thing is possible with command containers:
It is possible to have a module that is both a command container and an event container, by simply extending both CommandContainer and EventContainer in your module. Note that the extend Discordrb::Commands::CommandContainer must come after the extend Discordrb::EventContainer!