Sha256: a51c0805b7eed25c0384564800e3377128c36f3efd723a456bb8ad521adf61fc
Contents?: true
Size: 810 Bytes
Versions: 4
Compression:
Stored size: 810 Bytes
Contents
# @title Extension # Extension Extension allows you to split your code into multiple files. ## Make a new extension Make a new module, and extend {Discorb::Extension}. ```ruby module MyExtension extend Discorb::Extension # ... end ``` ## Register Event Use {Extension#event} to register event, or {Extension#once_event} to register event only once. ```ruby module MyExtension extend Discorb::Extension event :message do |message| # ... end once_event :ready do |message| # ... end end ``` ## Load extension Use {Client#extend} to load extension. ## Access Client from extension You can access {Client} from extension with `@client`. ```ruby module MyExtension extend Discorb::Extension event :ready do |message| puts "Logged in as #{client.user}" end end ```
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
discorb-0.2.4 | docs/extension.md |
discorb-0.2.3 | docs/extension.md |
discorb-0.2.1 | docs/extension.md |
discorb-0.2.0 | docs/extension.md |