-
-
Save swarley/e7fcc68672f37083c00ecba28c47f6cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TestContainer | |
extend Discordrb::EventContainer | |
message contains: /i'm (.+)/ do |event| | |
event.respond("Hi, #{event.content.match(/i'm (.+)\b/)[1]}. I'm Dad!") | |
end | |
end | |
module CommandContainer | |
extend Discordrb::Commands::CommandContainer | |
command :ping do |event| | |
'Pong!' | |
end | |
command :'8ball' do |event| | |
['yes', 'no', 'maybe', 'unsure', 'ask again later', 'unlikely'].sample | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'discordrb' | |
load 'containers.rb' | |
CONTAINERS = [TestContainer, CommandContainer] | |
def load_containers(bot) | |
# Remove all handlers | |
bot.clear! | |
CONTAINERS.map(&:clear!) | |
# Reload the file | |
load 'containers.rb' | |
# Register handlers onto the bot | |
CONTAINERS.each do |container| | |
Discordrb::LOGGER.info("Loading #{container.name}") | |
container.clear! | |
bot.include!(container) | |
end | |
end | |
bot = Discordrb::Commands::CommandBot.new(token: ENV['INOSUKE_TOKEN'], prefix: '.') | |
# Load initial containers | |
CONTAINERS.each {|container| bot.include!(container) } | |
bot.command(:reload) do |event| | |
load_containers(event.bot) | |
end | |
bot.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment