prevent it from trying to downcase a nil element and failing.

This commit is contained in:
fzorb 2024-10-05 08:45:43 +03:00
parent dbdd9a6495
commit 1d33f6d468

View File

@ -24,12 +24,13 @@ module QuoteSystem
end
command :quote do |event, *message|
category = message[0].downcase
category = message[0]
if category == nil
quotes = db.execute("SELECT * FROM quotes")
quote = quotes.sample
event.channel.send_message("##{quote[0]} <#{quote[2]}>: #{quote[3]}")
else
category = category.downcase
quotes = db.execute("SELECT * FROM quotes WHERE category = ?", [category])
if quotes == []
event.channel.send_message("Uh, this is awkward. The category you're trying to get a quote from doesn't exist.")