bot.rb 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. require 'bundler'
  2. require 'erb'
  3. require 'yaml'
  4. require 'json'
  5. require 'terminal-table'
  6. BOT_ENV = ENV.fetch('BOT_ENV') { 'development' }
  7. Bundler.require(:default, BOT_ENV)
  8. require 'active_record'
  9. # Constants: such as roles and channel ids
  10. ADMINS = 308250685554556930
  11. # ---
  12. Dotenv.load if BOT_ENV != 'production'
  13. db_yml = File.open('config/database.yml') do |erb|
  14. ERB.new(erb.read).result
  15. end
  16. db_config = YAML.safe_load(db_yml)[BOT_ENV]
  17. ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)
  18. ActiveRecord::Base.establish_connection(
  19. adapter: 'postgresql',
  20. host: db_config.fetch('host') { 'localhost' },
  21. database: db_config['database'],
  22. user: db_config['user'],
  23. password: db_config['password']
  24. )
  25. Dir['app/**/*.rb'].each { |f| require File.join(File.expand_path(__dir__), f) }
  26. Dir['/lib/*.rb'].each { |f| require f }
  27. token = ENV['DISCORD_BOT_TOKEN']
  28. bot = Discordrb::Bot.new(token: token)
  29. # Methods: define basic methods here
  30. # ---
  31. # Commands: structure basic bot commands here
  32. commands = []
  33. pm_commands = []
  34. hello = Command.new(:hello, "Says hello!") do |event|
  35. user = event.author.nickname || event.author.name
  36. greetings = [
  37. "Hi there, #{user}",
  38. "Greetings #{user}, you lovable bum",
  39. "Alola, #{user}",
  40. "Hello, #{user}! The Guildmasters have been waiting",
  41. "#{user} would like to battle!"
  42. ]
  43. Embed.new(
  44. description: greetings.sample,
  45. color: event.author.color.combined,
  46. thumbnail: {
  47. url: Image::HAPPY
  48. }
  49. )
  50. end
  51. opts = {
  52. "" => "displays a list of all commands",
  53. "command" => "displays info and usage for specified command"
  54. }
  55. desc = "Displays help information for the commands"
  56. help = Command.new(:help, desc, opts) do |event, command|
  57. if command
  58. short = /pkmn-(\w+)/.match(command)
  59. command = short ? short[1] : command
  60. cmd = commands.detect { |c| c.name == command.to_sym }
  61. pm_cmd = pm_commands.detect { |pc| pc.name == command.to_sym }
  62. end
  63. if command && cmd
  64. command_embed(cmd)
  65. elsif command && pm_cmd
  66. command_embed(pm_cmd, "PM Command")
  67. elsif !command
  68. embed = command_list_embed(
  69. pm_commands,
  70. "Can only be used in a pm with the bot",
  71. "PM Commands"
  72. )
  73. event.send_embed("", embed)
  74. command_list_embed(commands)
  75. else
  76. command_error_embed("Command not found!", help)
  77. end
  78. end
  79. opts = { "type" => "" }
  80. desc = "Displays a chart of effectiveness for the given type"
  81. matchup = Command.new(:matchup, desc, opts) do |event, type|
  82. channel = event.channel.id
  83. file = "images/Type #{type.capitalize}.png"
  84. if File.exists?(file)
  85. bot.send_file(channel, File.open(file, 'r'))
  86. else
  87. bot.respond("I do not know this pokemon type! Please try again!")
  88. end
  89. end
  90. opts = {
  91. "" => "starts a new app",
  92. "name" => "edits an existing app",
  93. "name | (in)active" => "sets app to active or inactive"
  94. }
  95. desc = "Everything to do with character applications"
  96. app = Command.new(:app, desc, opts) do |event, name, status|
  97. user = event.author
  98. user_name = user.nickname || user.name
  99. color = user.color ? user.color.combined : Color::DEFAULT
  100. character = Character.where(user_id: user.id).find_by(name: name) if name
  101. active = status.match(/(in)?active/i) if status
  102. case
  103. when name && !character
  104. app_not_found_embed(user_name, name)
  105. when status && active && character
  106. character.update!(active: active[0].capitalize)
  107. character.reload
  108. success_embed("Successfully updated #{name} to be #{active[0].downcase}")
  109. when name && character && !status
  110. edit_url = Url::CHARACTER + character.edit_url
  111. embed = edit_app_dm(name, edit_url, color)
  112. bot.send_message(user.dm.id, "", false, embed)
  113. edit_app_embed(user_name, name, color)
  114. when !name && !status
  115. embed = new_app_dm(user_name, color, user.id)
  116. message = bot.send_message(user.dm.id, "", false, embed)
  117. message.react(Emoji::PHONE)
  118. new_app_embed(user_name, color)
  119. else
  120. command_error_embed("There was an error processing your application!", app)
  121. end
  122. end
  123. opts = { "question | option1, option2, etc" => ""}
  124. desc = "Creates a dynamic poll in any channel"
  125. poll = Command.new(:poll, desc, opts) do |event, question, options|
  126. if options
  127. options_array = options.split(/\s?,\s?/)
  128. new_poll_embed(event, question, options_array)
  129. else
  130. command_error_embed("There was an error creating your poll!", poll)
  131. end
  132. end
  133. opts = {
  134. "participants" =>
  135. "Accepts Everyone, Here, or a comma seperated list of names"
  136. }
  137. desc = "Creates a raffle and picks a winner"
  138. raffle = Command.new(:raffle, desc, opts) do |event, participant|
  139. participants =
  140. case participant
  141. when /^everyone$/i
  142. event.server.members
  143. when /^here$/i
  144. event.message.channel.users
  145. else
  146. participant.split(/\s?,\s?/)
  147. end
  148. winner = participants.sample
  149. winner_name =
  150. case winner
  151. when String
  152. winner
  153. else
  154. winner.nickname || winner.username
  155. end
  156. if winner_name
  157. message_embed("Raffle Results!", "Winner: #{winner_name}")
  158. else
  159. command_error_embed("There was an error creating your raffle!", raffle)
  160. end
  161. end
  162. opts = {
  163. "name | keyword | (n)sfw | url" => "add or update image",
  164. "name | keyword | delete" => "remove image",
  165. "name | keyword" => "display image",
  166. "name" => "list all images"
  167. }
  168. desc = "View, add and edit your characters' images"
  169. image = Command.new(:image, desc, opts) do |event, name, keyword, tag, url|
  170. user = event.author
  171. char = Character.where(user_id: user.id).find_by!(name: name) if name
  172. color = CharacterController.type_color(char) if char
  173. img = CharImage.find_by(keyword: keyword) if keyword
  174. case
  175. when /^Default$/i.match(keyword)
  176. error_embed(
  177. "Cannot update Default here!",
  178. "Use `pkmn-app character` to edit your default image in your form"
  179. )
  180. when char && keyword && url && tag && tag.match(/(n)?sfw/i)
  181. img_app = CharImage.to_form(
  182. char.name,
  183. char.species,
  184. char.id,
  185. keyword,
  186. tag,
  187. url,
  188. user.id
  189. )
  190. approval = bot.send_message(Channel::APPROVAL, img_app, false, nil)
  191. approval.react(Emoji::Y)
  192. approval.react(Emoji::N)
  193. success_embed("Your image has been submitted for approval!")
  194. when char && img && tag && tag.match(/delete/i)
  195. CharImage.find(img.id).delete
  196. success_embed("Removed image: #{keyword}")
  197. when char && img && !tag
  198. char_image_embed(char, img, user, color)
  199. when char && !keyword
  200. imgs = CharImage.where(char_id: char.id)
  201. image_list_embed(char, imgs, user, color)
  202. when keyword && !img
  203. error_embed("Could not find your image!")
  204. else
  205. command_error_embed("Could not process your image request!", image)
  206. end
  207. rescue ActiveRecord::RecordNotFound
  208. error_embed(
  209. "Character not Found!",
  210. "I could not find your character named #{name}"
  211. )
  212. end
  213. opts = {
  214. "" => "List all guild members",
  215. "@user" => "List all characters belonging to the user",
  216. "name " => "Display the given character",
  217. "name | section" => "Display the given section for the character",
  218. "name | image | keword" => "Display the given image"
  219. }
  220. desc = "Display info about the guild members"
  221. member = Command.new(:member, desc, opts) do |event, name, section, keyword|
  222. sections = [:all, :default, :bio, :type, :status, :rumors, :image]
  223. case name
  224. when Regex::UID
  225. user_id = Regex::UID.match(name)
  226. when String
  227. char = Character.find_by!(name: name)
  228. img = CharImage.where(char_id: char.id).find_by(keyword: 'Default')
  229. user = event.server.member(char.user_id)
  230. color = CharacterController.type_color(char)
  231. end
  232. case
  233. when !name
  234. chars = Character.all
  235. char_list_embed(chars)
  236. when name && user_id
  237. chars = Character.where(user_id: user_id[1])
  238. user = event.server.member(user_id[1])
  239. char_list_embed(chars, user)
  240. when name && char && !section
  241. embed = character_embed(
  242. char: char,
  243. img: img,
  244. section: :default,
  245. user: user,
  246. color: color
  247. )
  248. msg = event.send_embed("", embed)
  249. Carousel.create(message_id: msg.id, char_id: char.id)
  250. section_react(msg)
  251. when char && section && keyword
  252. embed = command_error_embed(
  253. "Invalid Arguments",
  254. member
  255. )unless /image/i.match(section)
  256. unless embed
  257. img = CharImage.where(char_id: char.id).find_by!(keyword: keyword)
  258. embed = error_embed(
  259. "Wrong Channel!",
  260. "The requested image is NSFW"
  261. )if img.category == 'NSFW' && !event.channel.nsfw?
  262. end
  263. unless embed
  264. embed = character_embed(
  265. char: char,
  266. img: img,
  267. section: :image,
  268. user: user,
  269. color: color
  270. )
  271. msg = event.send_embed("", embed)
  272. Carousel.create(message_id: msg.id, char_id: char.id, image_id: img.id)
  273. arrow_react(msg)
  274. end
  275. embed
  276. when name && char && section
  277. sect = section.downcase.to_sym
  278. nsfw = event.channel.nsfw?
  279. img = ImageController.img_scroll(
  280. char_id: char.id,
  281. nsfw: nsfw
  282. )if section == :image
  283. if sections.detect{ |s| s == sect }
  284. embed = character_embed(
  285. char: char,
  286. img: img,
  287. section: sect,
  288. user: user,
  289. color: color,
  290. )
  291. msg = event.send_embed("", embed)
  292. Carousel.create(message_id: msg.id, char_id: char.id, image_id: img.id)
  293. if sect == :image
  294. arrow_react(msg)
  295. else
  296. section_react(msg)
  297. end
  298. else
  299. error_embed("Invalid Section!")
  300. end
  301. end
  302. rescue ActiveRecord::RecordNotFound => e
  303. error_embed("Record Not Found!", e.message)
  304. end
  305. # ---
  306. commands = [
  307. hello,
  308. matchup,
  309. app,
  310. help,
  311. poll,
  312. raffle,
  313. member
  314. ]
  315. # This will trigger on every message sent in discord
  316. bot.message do |event|
  317. content = event.message.content
  318. author = event.author.id
  319. command = /^pkmn-(\w+)/.match(content)
  320. cmd = commands.detect { |c| c.name == command[1].to_sym } if command
  321. reply = cmd.call(content, event) if cmd
  322. case reply
  323. when Embed
  324. event.send_embed("", reply)
  325. when String
  326. event.respond(reply)
  327. end
  328. event.send_embed(
  329. "",
  330. error_embed("Command not found!")
  331. )if command && !cmd && event.server
  332. Character.check_user(event) if author == Bot::CHARACTER
  333. end
  334. pm_commands = [ image ]
  335. # This will trigger when a dm is sent to the bot from a user
  336. bot.pm do |event|
  337. content = event.message.content
  338. command = /^pkmn-(\w+)/.match(content)
  339. cmd = pm_commands.detect { |c| c.name == command[1].to_sym } if command
  340. reply = cmd.call(content, event) if cmd
  341. case reply
  342. when Embed
  343. event.send_embed("", reply)
  344. when String
  345. event.respond(reply)
  346. end
  347. end
  348. # This will trigger when any reaction is added in discord
  349. bot.reaction_add do |event|
  350. content = event.message.content
  351. reactions = event.message.reactions
  352. maj = if event.server
  353. event.server.roles.find{ |r| r.id == ADMINS }.members.count / 2
  354. end
  355. maj = 1
  356. form =
  357. case
  358. when event.message.author.id == Bot::CHARACTER
  359. :character_application
  360. when event.message.from_bot? && content.match(Regex::CHAR_APP)
  361. :character_rejection
  362. when event.message.from_bot? && event.server.nil?
  363. :pm
  364. when event.message.from_bot? && content.match(/\_New\sCharacter\sImage\_:/)
  365. :image_application
  366. when carousel = Carousel.find_by(message_id: event.message.id)
  367. :carousel
  368. end
  369. vote =
  370. case
  371. when reactions[Emoji::Y]&.count.to_i > maj then :yes
  372. when reactions[Emoji::N]&.count.to_i > maj then :no
  373. when reactions[Emoji::CHECK]&.count.to_i > 1 then :check
  374. when reactions[Emoji::CROSS]&.count.to_i > 1 then :cross
  375. when reactions[Emoji::CRAYON]&.count.to_i > 1 then :crayon
  376. when reactions[Emoji::NOTEBOOK]&.count.to_i > 1 then :notebook
  377. when reactions[Emoji::QUESTION]&.count.to_i > 1 then :question
  378. when reactions[Emoji::PALLET]&.count.to_i > 1 then :pallet
  379. when reactions[Emoji::EAR]&.count.to_i > 1 then :ear
  380. when reactions[Emoji::PICTURE]&.count.to_i > 1 then :picture
  381. when reactions[Emoji::BAGS]&.count.to_i > 1 then :bags
  382. when reactions[Emoji::FAMILY]&.count.to_i > 1 then :family
  383. when reactions[Emoji::EYES]&.count.to_i > 1 then :eyes
  384. when reactions[Emoji::KEY]&.count.to_i > 1 then :key
  385. when reactions[Emoji::PHONE]&.count.to_i > 1 then :phone
  386. when reactions[Emoji::LEFT]&.count.to_i > 1 then :left
  387. when reactions[Emoji::RIGHT]&.count.to_i > 1 then :right
  388. when reactions[Emoji::UNDO]&.count.to_i > 1 then :back
  389. end
  390. case [form, vote]
  391. when [:character_application, :yes]
  392. params = content.split("\n")
  393. uid = Regex::UID.match(content)
  394. user = event.server.member(uid[1])
  395. char = CharacterController.edit_character(params)
  396. img = ImageController.default_image(content, char.id)
  397. color = CharacterController.type_color(char)
  398. embed = character_embed(
  399. char: char,
  400. img: img,
  401. user: user,
  402. color: color
  403. )if char
  404. if embed
  405. bot.send_message(
  406. Channel::CHARACTER,
  407. "Good news, <@#{user.id}>! Your character was approved",
  408. false,
  409. embed
  410. )
  411. event.message.delete
  412. else
  413. event.respond(
  414. "",
  415. admin_error_embed("Something went wrong when saving application")
  416. )
  417. end
  418. when [:character_application, :no]
  419. content = event.message.content
  420. embed = reject_char_embed(content)
  421. event.message.delete
  422. reject = event.send_embed(content, embed)
  423. Emoji::CHAR_APP.each do |reaction|
  424. reject.react(reaction)
  425. end
  426. reject.react(Emoji::CHECK)
  427. reject.react(Emoji::CROSS)
  428. reject.react(Emoji::CRAYON)
  429. when [:character_rejection, :check]
  430. user = event.server.member(Regex::UID.match(content)[1])
  431. embed = user_char_app(event)
  432. event.message.delete
  433. bot.send_temporary_message(event.channel.id, "", 5, false, embed)
  434. bot.send_message(user.dm.id, "", false, embed)
  435. when [:character_rejection, :cross]
  436. event.message.delete
  437. when [:character_rejection, :crayon]
  438. event.message.delete
  439. bot.send_temporary_message(
  440. event.channel.id,
  441. "",
  442. 35,
  443. false,
  444. self_edit_embed(content)
  445. )
  446. when [:pm, :phone]
  447. event.message.delete_own_reaction(Emoji::PHONE)
  448. user = event.message.reacted_with(Emoji::PHONE).first
  449. bot.send_message(user.dm.id, user.id, false, nil)
  450. when [:image_application, :yes]
  451. params = content.split("\n")
  452. img = ImageController.edit_image(params)
  453. char = Character.find(img.char_id)
  454. user = event.server.member(char.user_id)
  455. color = CharacterController.type_color(char)
  456. embed = char_image_embed(char, img, user, color)
  457. event.message.delete if embed
  458. channel = if img.category == 'SFW'
  459. Channel::CHARACTER
  460. else
  461. Channel::CHARACTER_NSFW
  462. end
  463. bot.send_message(channel, "Image Approved!", false, embed)
  464. when [:image_application, :no]
  465. content = event.message.content
  466. embed = reject_img_embed(content)
  467. event.message.delete
  468. reject = event.send_embed(content, embed)
  469. Emoji::IMG_APP.each do |reaction|
  470. reject.react(reaction)
  471. end
  472. reject.react(Emoji::CHECK)
  473. reject.react(Emoji::CROSS)
  474. when [:image_application, :check]
  475. user = event.server.member(Regex::UID.match(content)[1])
  476. embed = user_img_app(event)
  477. event.message.delete
  478. bot.send_temporary_message(event.channel.id, "", 5, false, embed)
  479. bot.send_message(user.dm.id, "", false, embed)
  480. when [:image_application, :cross]
  481. event.message.delete
  482. when [:carousel, :notebook]
  483. emoji = Emoji::NOTEBOOK
  484. users = event.message.reacted_with(emoji)
  485. users.each do |user|
  486. event.message.delete_reaction(user.id, emoji) unless user.current_bot?
  487. end
  488. char = Character.find(carousel.char_id)
  489. embed = character_embed(
  490. char: char,
  491. img: CharImage.where(char_id: char.id).find_by(keyword: 'Default'),
  492. user: event.server.member(char.user_id),
  493. color: CharacterController.type_color(char),
  494. section: :bio
  495. )
  496. event.message.edit("", embed)
  497. when [:carousel, :question]
  498. emoji = Emoji::QUESTION
  499. users = event.message.reacted_with(emoji)
  500. users.each do |user|
  501. event.message.delete_reaction(user.id, emoji) unless user.current_bot?
  502. end
  503. char = Character.find(carousel.char_id)
  504. embed = character_embed(
  505. char: char,
  506. img: CharImage.where(char_id: char.id).find_by(keyword: 'Default'),
  507. user: event.server.member(char.user_id),
  508. color: CharacterController.type_color(char),
  509. section: :status
  510. )
  511. event.message.edit("", embed)
  512. when [:carousel, :pallet]
  513. emoji = Emoji::PALLET
  514. users = event.message.reacted_with(emoji)
  515. users.each do |user|
  516. event.message.delete_reaction(user.id, emoji) unless user.current_bot?
  517. end
  518. char = Character.find(carousel.char_id)
  519. embed = character_embed(
  520. char: char,
  521. img: CharImage.where(char_id: char.id).find_by(keyword: 'Default'),
  522. user: event.server.member(char.user_id),
  523. color: CharacterController.type_color(char),
  524. section: :type
  525. )
  526. event.message.edit("", embed)
  527. when [:carousel, :ear]
  528. emoji = Emoji::EAR
  529. users = event.message.reacted_with(emoji)
  530. users.each do |user|
  531. event.message.delete_reaction(user.id, emoji) unless user.current_bot?
  532. end
  533. char = Character.find(carousel.char_id)
  534. embed = character_embed(
  535. char: char,
  536. img: CharImage.where(char_id: char.id).find_by(keyword: 'Default'),
  537. user: event.server.member(char.user_id),
  538. color: CharacterController.type_color(char),
  539. section: :rumors
  540. )
  541. event.message.edit("", embed)
  542. when [:carousel, :picture]
  543. event.message.delete_all_reactions
  544. char = Character.find(carousel.char_id)
  545. img = ImageController.img_scroll(
  546. char_id: char.id,
  547. nsfw: event.channel.nsfw?,
  548. )
  549. carousel.update(id: carousel.id, image_id: img.id)
  550. embed = character_embed(
  551. char: char,
  552. img: img,
  553. user: event.server.member(char.user_id),
  554. color: CharacterController.type_color(char),
  555. section: :image
  556. )
  557. event.message.edit("", embed)
  558. arrow_react(event.message)
  559. when [:carousel, :bags]
  560. when [:carousel, :family]
  561. when [:carousel, :eyes]
  562. emoji = Emoji::EYES
  563. users = event.message.reacted_with(emoji)
  564. users.each do |user|
  565. event.message.delete_reaction(user.id, emoji) unless user.current_bot?
  566. end
  567. char = Character.find(carousel.char_id)
  568. embed = character_embed(
  569. char: char,
  570. img: CharImage.where(char_id: char.id).find_by(keyword: 'Default'),
  571. user: event.server.member(char.user_id),
  572. color: CharacterController.type_color(char),
  573. section: :all
  574. )
  575. event.message.edit("", embed)
  576. when [:carousel, :key]
  577. emoji = Emoji::KEY
  578. users = event.message.reacted_with(emoji)
  579. users.each do |user|
  580. event.message.delete_reaction(user.id, emoji) unless user.current_bot?
  581. end
  582. char = Character.find(carousel.char_id)
  583. embed = character_embed(
  584. char: char,
  585. img: CharImage.where(char_id: char.id).find_by(keyword: 'Default'),
  586. user: event.server.member(char.user_id),
  587. color: CharacterController.type_color(char),
  588. section: :default
  589. )
  590. event.message.edit("", embed)
  591. when [:carousel, :back]
  592. event.message.delete_all_reactions
  593. char = Character.find(carousel.char_id)
  594. embed = character_embed(
  595. char: char,
  596. img: CharImage.where(char_id: char.id).find_by(keyword: 'Default'),
  597. user: event.server.member(char.user_id),
  598. color: CharacterController.type_color(char),
  599. section: :default
  600. )
  601. event.message.edit("", embed)
  602. section_react(event.message)
  603. when [:carousel, :left], [:carousel, :right]
  604. emoji = vote == :left ? Emoji::LEFT : Emoji::RIGHT
  605. users = event.message.reacted_with(emoji)
  606. users.each do |user|
  607. event.message.delete_reaction(user.id, emoji) unless user.current_bot?
  608. end
  609. char = Character.find(carousel.char_id)
  610. img = ImageController.img_scroll(
  611. char_id: char.id,
  612. nsfw: event.channel.nsfw?,
  613. img: carousel.image_id,
  614. dir: vote
  615. )
  616. carousel.update(id: carousel.id, image_id: img.id)
  617. embed = character_embed(
  618. char: char,
  619. img: img,
  620. user: event.server.member(char.user_id),
  621. color: CharacterController.type_color(char),
  622. section: :image
  623. )
  624. event.message.edit("", embed)
  625. when [:carousel, :cross]
  626. event.message.delete
  627. Carousel.find_by(message_id: event.message.id).delete
  628. end
  629. end
  630. # This will trigger when any reaction is removed in discord
  631. bot.reaction_remove do |event|
  632. end
  633. # This will trigger when a member is updated
  634. bot.member_update do |event|
  635. end
  636. # This will trigger when anyone joins the server
  637. bot.member_join do |event|
  638. end
  639. # This will trigger when anyone leaves the server
  640. bot.member_leave do |event|
  641. end
  642. # This will trigger when anyone is banned from the server
  643. bot.user_ban do |event|
  644. end
  645. # This will trigger when anyone is un-banned from the server
  646. bot.user_unban do |event|
  647. end
  648. bot.run