32 lines
945 B
Ruby
32 lines
945 B
Ruby
|
require 'discordrb'
|
||
|
require 'dotenv'
|
||
|
require 'sqlite3'
|
||
|
|
||
|
Dotenv.load
|
||
|
|
||
|
bot = Discordrb::Commands::CommandBot.new token: ENV['TOKEN'], client_id: ENV['CLIENT_ID'], prefix: ENV['PREFIX']
|
||
|
db = SQLite3::Database.new("jon.sqlite")
|
||
|
|
||
|
bot.message do |event|
|
||
|
if ENV['FORBIDDEN_WORDS'].split(",").any? { |word| event.message.content.downcase.include?(word.downcase)}
|
||
|
event.author.pm("Garfield, watch your tone!")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
bot.command :addquote do |event, *message|
|
||
|
category = message[0]
|
||
|
quote = message[1..].join(" ")
|
||
|
event.channel.send_message("I'm adding the quote '#{quote}' under the category #{category}")
|
||
|
db.execute("INSERT INTO quotes (author, category, quote) VALUES (?, ?, ?)", [event.author.id, category, quote])
|
||
|
nil
|
||
|
end
|
||
|
|
||
|
bot.command :quote do |event, *message|
|
||
|
category = message[0]
|
||
|
quotes = db.execute("SELECT * FROM quotes WHERE category = ?", [category])
|
||
|
event.channel.send_message(quotes.sample[3])
|
||
|
nil
|
||
|
end
|
||
|
|
||
|
bot.run
|