Module: Burroughs
- Includes:
- Configurable, Environments
- Defined in:
- lib/burroughs.rb,
lib/burroughs/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Methods included from Configurable
Methods included from Environments
Class Method Details
.init ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/burroughs.rb', line 22 def self.init Signal.trap("INT") { exit } Signal.trap("TERM") { exit } l = Logger.new($stdout) l.level = prefs.loglevel l.debug "hello" l.debug env.type bot = Discordrb::Bot.new(token: Burroughs.prefs.token) bot.register_application_command(:ping, "Are you awake?") bot.register_application_command(:clear, "Clear messages in the channel (max 100).") do |cmd| cmd.integer("size", "Number of messages to clear.", required: true) end bot.application_command(:ping) do |event| travel_time = (Time.now - event.).round event.respond(content: "I'm awake and only `#{travel_time}ms` away.") end bot.application_command(:clear) do |event| n = event.["size"] = event.channel.history(n) # event.channel.prune(n) # TODO: For some reason, this is getting rate limited, but our workaround is fine for now .each do |m| m.delete end n == 1 ? event.respond(content: "Cleared #{n} message.") : event.respond(content: "Cleared #{n} messages.") sleep 4 event.interaction.delete_response end bot.run ensure bot.stop if bot&.connected? l.close end |