diff --git a/.gitignore b/.gitignore index 4c49bd7..d49608e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .env +jon.db +Gemfile.lock diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..f399110 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +gem 'dotenv', groups: [:development, :test] +gem 'discordrb' +gem 'sqlite3' diff --git a/bot.rb b/bot.rb new file mode 100644 index 0000000..337127d --- /dev/null +++ b/bot.rb @@ -0,0 +1,31 @@ +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 diff --git a/jon.sqlite b/jon.sqlite new file mode 100644 index 0000000..21d147a Binary files /dev/null and b/jon.sqlite differ