add an admin "interface" to delete quotes
This commit is contained in:
parent
22a226402c
commit
40f121541c
@ -1,5 +1,6 @@
|
|||||||
TOKEN=
|
TOKEN=
|
||||||
CLIENT_ID=
|
CLIENT_ID=
|
||||||
PREFIX=;
|
PREFIX=;
|
||||||
|
ADMIN=
|
||||||
|
|
||||||
FORBIDDEN_WORDS=word1,word2
|
FORBIDDEN_WORDS=word1,word2
|
||||||
|
6
bot.rb
6
bot.rb
@ -23,8 +23,10 @@ bot.command :help do |event, *message|
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
require_relative 'systems/quote'
|
# stolen from https://github.com/Suylo/Discord-Bot/blob/master/index.rb
|
||||||
require_relative 'systems/network'
|
systems = Dir["systems/*.rb"]
|
||||||
|
systems.each { |i| require_relative "#{i}" }
|
||||||
|
|
||||||
bot.include! QuoteSystem
|
bot.include! QuoteSystem
|
||||||
bot.include! NetworkModule
|
bot.include! NetworkModule
|
||||||
bot.run
|
bot.run
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
|
require 'dotenv'
|
||||||
require 'sqlite3'
|
require 'sqlite3'
|
||||||
require 'discordrb'
|
require 'discordrb'
|
||||||
|
|
||||||
|
Dotenv.load("#{__dir__}/../.env")
|
||||||
|
|
||||||
module QuoteSystem
|
module QuoteSystem
|
||||||
extend Discordrb::Commands::CommandContainer
|
extend Discordrb::Commands::CommandContainer
|
||||||
db = SQLite3::Database.new("jon.sqlite")
|
db = SQLite3::Database.new("jon.sqlite")
|
||||||
@ -46,4 +50,16 @@ module QuoteSystem
|
|||||||
event.channel.send_message("##{quote[0][0]} <#{quote[0][2]}>: #{quote[0][3]}")
|
event.channel.send_message("##{quote[0][0]} <#{quote[0][2]}>: #{quote[0][3]}")
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
command :delquote do |event, *message|
|
||||||
|
if event.author.id != ENV['ADMIN'].to_i
|
||||||
|
event.channel.send_message("You really thought you could do this?")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for quote in message do
|
||||||
|
db.execute('DELETE FROM quotes WHERE "id"=?;', [quote])
|
||||||
|
end
|
||||||
|
event.channel.send_message("Job complete.")
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user