@@ -11,6 +11,24 @@ class ApplicationForm
raise 'NYI'
end
+ def self.check_votes(event, maj)
+ reactions = event.message.reactions
+
+ if reactions[Emoji::Y]&.count.to_i > maj && star(event)
+ approve(event)
+ elsif reactions[Emoji::N]&.count.to_i > maj
+ reject(event)
+ elsif reactions[Emoji::CRAYON]&.count.to_i > 1
+ edit(event)
+ elsif reactions[Emoji::CROSS]&.count.to_i > 1
+ remove(event)
+ elsif reactions[Emoji::GHOST]&.count.to_i > 0
+ to_office(event, ENV['MIZU_CH'])
+ elsif reactions[Emoji::FISH]&.count.to_i > 0
+ to_office(event, ENV['NEIRO_CH'])
+ end
def self.approve
@@ -40,4 +58,9 @@ class ApplicationForm
event.message&.delete unless member.current_bot?
+ def self.to_office(event, office)
+ app = Embed.convert(event.message.embeds.first)
+ BotResponse.new(destination: office, embed: app)
@@ -5,17 +5,8 @@ class CharacterApplication < ApplicationForm
@process ||= Application.new('Character Application') do |event|
# Calculate majority, and check votes
maj = majority(event)
+ check_votes(event, maj)
- reactions = event.message.reactions
- if reactions[Emoji::Y]&.count.to_i > maj && star(event)
- approve(event)
- elsif reactions[Emoji::N]&.count.to_i > maj
- deny(event)
- elsif reactions[Emoji::CRAYON]&.count.to_i > 1
- edit(event)
- elsif reactions[Emoji::CROSS]&.count.to_i > 1
- remove(event)
- end
rescue StandardError => e
error_embed(e.message)
@@ -3,15 +3,11 @@ require './app/app_forms/app_form.rb'
class ConfirmArchive < ApplicationForm
def self.process
@process ||= Application.new('Team Alert') do |event|
- # Check reactions
- if reactions[Emoji::Y]&.count.to_i > 1
- elsif reactions[Emoji::N]&.count.to_i > 1
- #rescue StandardError => e
- #error_embed(e.message)
+ # Check votes
+ check_votes(event, 1)
+ rescue StandardError => e
+ error_embed(e.message)
@@ -3,20 +3,12 @@ require './app/app_forms/app_form.rb'
class FableApplication < ApplicationForm
@process||= Application.new('Fable Application') do |event|
- # Calculate majority
+ # Calculate majority, and check votes
- # Check votes
@@ -3,17 +3,10 @@ require './app/app_forms/app_form.rb'
class ImageApplication < ApplicationForm
@process ||= Application.new('Image Application') do |event|
- # Calculate majority, and check votes
+ # Calculate majority
@@ -5,18 +5,8 @@ class ItemApplication < ApplicationForm
@process ||= Application.new('Item Application') do |event|
# Calculate majority
@@ -5,18 +5,8 @@ class LandmarkApplication < ApplicationForm
@process ||= Application.new('Landmark Application') do |event|
@@ -3,22 +3,12 @@ require './app/app_forms/app_form.rb'
class ReactivationApplication < ApplicationForm
@process ||= Application.new('Reactivation Application') do |event|
- # Calculate majority and Save application
+ # Calculate majority and check votes
- elsif reactions[Emoji::CRAYON]&.count.to_i > maj
class TeamApplication < ApplicationForm
@process ||= Application.new('Team Application') do |event|
@@ -5,13 +5,8 @@ class TeamJoinApplication < ApplicationForm
@process ||= Application.new('Team Join Request') do |event|
# Calculate majority and check votes
- if reactions[Emoji::Y]&.count.to_i > maj
@@ -88,4 +88,34 @@ class Embed
hex = color.to_s.sub(/\A#/, '0x')
Integer(hex)
+ def self.convert(discord_embed)
+ fields = []
+ discord_embed.fields.each do |field|
+ fields.push({ name: field.name, value: field.value })
+ embed = Embed.new(
+ title: discord_embed.title,
+ description: discord_embed.description,
+ url: discord_embed.url,
+ color: discord_embed.color&.combined,
+ timestamp: discord_embed.timestamp
+ )
+ embed.footer = {
+ icon_url: discord_embed.footer.icon_url,
+ text: discord_embed.footer.text
+ } if discord_embed.footer
+ embed.thumbnail = { url: discord_embed.thumbnail.url } if discord_embed.thumbnail
+ embed.image = { url: discord_embed.image.url } if discord_embed.image
+ embed.author = {
+ icon_url: discord_embed.author.icon_url,
+ name: discord_embed.author.name,
+ url: discord_embed.author.url,
+ } if discord_embed.author
+ embed.fields = fields if fields
+ embed
@@ -73,7 +73,7 @@ class User < ActiveRecord::Base
n = Nature.find(nature)
stats = stat_calc(n.up_stat, n.down_stat)
- img = stat_image(self, member, stats) if member
+ img = UsersController.stat_image(self, member, stats) if member
self.update(stats)
self.reload
@@ -82,6 +82,9 @@ module Emoji
WIZARD = "🧙"
TALK = "🗣️"
+ GHOST = "👻"
+ FISH = "🐟"
LETTERS = [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z]
NUMBERS = [ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN]