add quotes and stuff
This commit is contained in:
parent
fa655f69bb
commit
93b88dfeb6
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
.env
|
||||
jon.db
|
||||
Gemfile.lock
|
||||
|
3
Gemfile
Normal file
3
Gemfile
Normal file
@ -0,0 +1,3 @@
|
||||
gem 'dotenv', groups: [:development, :test]
|
||||
gem 'discordrb'
|
||||
gem 'sqlite3'
|
31
bot.rb
Normal file
31
bot.rb
Normal file
@ -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
|
BIN
jon.sqlite
Normal file
BIN
jon.sqlite
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user