|
|
@@ -1,11 +1,14 @@
|
|
|
def character_embed(character:, event:, section: nil, image: nil)
|
|
|
# Find the author, if they're a member, or in DMs use the event's author
|
|
|
- if event.server
|
|
|
- member = character.user_id.match(/public/i) ? 'Public' :
|
|
|
- event.server.member(character.user_id)
|
|
|
- else
|
|
|
- member = event.author
|
|
|
- end
|
|
|
+ member = if event.server
|
|
|
+ if character.user_id.match(/public/i)
|
|
|
+ 'Public'
|
|
|
+ else
|
|
|
+ event.server.member(character.user_id)
|
|
|
+ end
|
|
|
+ else
|
|
|
+ event.author
|
|
|
+ end
|
|
|
fields = []
|
|
|
|
|
|
embed = Embed.new(
|
|
|
@@ -39,17 +42,19 @@ def character_embed(character:, event:, section: nil, image: nil)
|
|
|
when /rumors?/i
|
|
|
fields = char_rumors(character, fields)
|
|
|
when /images?/i
|
|
|
- image = image ? image : default_img
|
|
|
+ image ||= default_img
|
|
|
if image
|
|
|
- embed.title =
|
|
|
- "#{character.name} | #{image.keyword}" unless image.keyword == 'Default'
|
|
|
+ unless image.keyword == 'Default'
|
|
|
+ embed.title =
|
|
|
+ "#{character.name} | #{image.keyword}"
|
|
|
+ end
|
|
|
embed.image = { url: image.url }
|
|
|
|
|
|
# Replace the rating with the image's rating
|
|
|
footer_info.pop
|
|
|
footer_info.push(image.category)
|
|
|
else
|
|
|
- embed.description = "No character images found!"
|
|
|
+ embed.description = 'No character images found!'
|
|
|
end
|
|
|
|
|
|
# Remove default image
|
|
|
@@ -71,30 +76,46 @@ def char_bio(char, fields)
|
|
|
char_teams = CharTeam.where(char_id: char.id, active: true).map(&:team_id)
|
|
|
teams = Team.where(id: char_teams).map(&:name)
|
|
|
|
|
|
- fields.push(
|
|
|
- { name: 'Hometown', value: char.hometown, inline: true }
|
|
|
- )if char.hometown
|
|
|
- fields.push(
|
|
|
- { name: 'Location', value: char.location, inline: true }
|
|
|
- )if char.location
|
|
|
- fields.push(
|
|
|
- { name: 'Likes', value: char.likes }
|
|
|
- )if char.likes
|
|
|
- fields.push(
|
|
|
- { name: 'Dislikes', value: char.dislikes }
|
|
|
- )if char.dislikes
|
|
|
- fields.push(
|
|
|
- { name: 'Backstory', value: char.backstory }
|
|
|
- )if char.backstory
|
|
|
- fields.push(
|
|
|
- { name: 'Recent Events', value: char.recent_events }
|
|
|
- )if char.recent_events
|
|
|
- fields.push(
|
|
|
- { name: 'Other', value: char.other }
|
|
|
- )if char.other
|
|
|
- fields.push(
|
|
|
- { name: 'Team', value: teams.join("\n") }
|
|
|
- )if !teams.empty?
|
|
|
+ if char.hometown
|
|
|
+ fields.push(
|
|
|
+ { name: 'Hometown', value: char.hometown, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.location
|
|
|
+ fields.push(
|
|
|
+ { name: 'Location', value: char.location, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.likes
|
|
|
+ fields.push(
|
|
|
+ { name: 'Likes', value: char.likes }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.dislikes
|
|
|
+ fields.push(
|
|
|
+ { name: 'Dislikes', value: char.dislikes }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.backstory
|
|
|
+ fields.push(
|
|
|
+ { name: 'Backstory', value: char.backstory }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.recent_events
|
|
|
+ fields.push(
|
|
|
+ { name: 'Recent Events', value: char.recent_events }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.other
|
|
|
+ fields.push(
|
|
|
+ { name: 'Other', value: char.other }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ unless teams.empty?
|
|
|
+ fields.push(
|
|
|
+ { name: 'Team', value: teams.join("\n") }
|
|
|
+ )
|
|
|
+ end
|
|
|
|
|
|
fields
|
|
|
end
|
|
|
@@ -102,12 +123,16 @@ end
|
|
|
def char_type(char, fields)
|
|
|
sp = char.shiny ? "#{char.species} #{Emoji::STAR}" : char.species
|
|
|
|
|
|
- fields.push(
|
|
|
- { name: 'Species', value: sp, inline: true }
|
|
|
- )if char.species
|
|
|
- fields.push(
|
|
|
- { name: 'Type', value: char.types, inline: true }
|
|
|
- )if char.types
|
|
|
+ if char.species
|
|
|
+ fields.push(
|
|
|
+ { name: 'Species', value: sp, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.types
|
|
|
+ fields.push(
|
|
|
+ { name: 'Type', value: char.types, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
|
|
|
if char.attacks
|
|
|
attacks = char.attacks
|
|
|
@@ -120,9 +145,11 @@ def char_type(char, fields)
|
|
|
end
|
|
|
|
|
|
def char_rumors(char, fields)
|
|
|
- fields.push(
|
|
|
- { name: 'Warnings', value: char.warnings }
|
|
|
- )if char.warnings
|
|
|
+ if char.warnings
|
|
|
+ fields.push(
|
|
|
+ { name: 'Warnings', value: char.warnings }
|
|
|
+ )
|
|
|
+ end
|
|
|
|
|
|
if char.rumors
|
|
|
rumors = char.rumors.split(/\s?\|\s?/)
|
|
|
@@ -139,24 +166,36 @@ def char_status(char, fields, status_effects=nil)
|
|
|
# Find any status effects on the character
|
|
|
status_effects = CharStatus.where(char_id: char.id)
|
|
|
|
|
|
- fields.push(
|
|
|
- { name: 'Age', value: char.age, inline: true }
|
|
|
- )if char.age
|
|
|
- fields.push(
|
|
|
- { name: 'Gender', value: char.gender, inline: true }
|
|
|
- )if char.gender
|
|
|
- fields.push(
|
|
|
- { name: 'Weight', value: char.weight, inline: true }
|
|
|
- )if char.weight
|
|
|
- fields.push(
|
|
|
- { name: 'Height', value: char.height, inline: true }
|
|
|
- )if char.height
|
|
|
- fields.push(
|
|
|
- { name: 'Sexual Orientation', value: char.orientation, inline: true }
|
|
|
- )if char.orientation
|
|
|
- fields.push(
|
|
|
- { name: 'Relationship Status', value: char.relationship, inline: true }
|
|
|
- )if char.relationship
|
|
|
+ if char.age
|
|
|
+ fields.push(
|
|
|
+ { name: 'Age', value: char.age, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.gender
|
|
|
+ fields.push(
|
|
|
+ { name: 'Gender', value: char.gender, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.weight
|
|
|
+ fields.push(
|
|
|
+ { name: 'Weight', value: char.weight, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.height
|
|
|
+ fields.push(
|
|
|
+ { name: 'Height', value: char.height, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.orientation
|
|
|
+ fields.push(
|
|
|
+ { name: 'Sexual Orientation', value: char.orientation, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
+ if char.relationship
|
|
|
+ fields.push(
|
|
|
+ { name: 'Relationship Status', value: char.relationship, inline: true }
|
|
|
+ )
|
|
|
+ end
|
|
|
|
|
|
afs = []
|
|
|
status_effects.each do |se|
|
|
|
@@ -168,9 +207,11 @@ def char_status(char, fields, status_effects=nil)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- fields.push(
|
|
|
- { name: "Current Afflictions", value: afs.join("\n") }
|
|
|
- )unless afs.empty?
|
|
|
+ unless afs.empty?
|
|
|
+ fields.push(
|
|
|
+ { name: 'Current Afflictions', value: afs.join("\n") }
|
|
|
+ )
|
|
|
+ end
|
|
|
|
|
|
fields
|
|
|
end
|
|
|
@@ -182,7 +223,7 @@ def char_inv(char, fields)
|
|
|
|
|
|
# Show formatted items
|
|
|
value = bags.empty? ? "#{char.name} doesn't have any items" : bags.join("\n")
|
|
|
- fields.push({ name: "Bags", value: value })
|
|
|
+ fields.push({ name: 'Bags', value: value })
|
|
|
|
|
|
fields
|
|
|
end
|
|
|
@@ -190,9 +231,11 @@ end
|
|
|
def char_dm_notes(char, fields, event)
|
|
|
return fields unless ENV['DM_CH'].include?(event.channel.id.to_s)
|
|
|
|
|
|
- fields.push(
|
|
|
- { name: 'DM Notes', value: char.dm_notes }
|
|
|
- )if char.dm_notes
|
|
|
+ if char.dm_notes
|
|
|
+ fields.push(
|
|
|
+ { name: 'DM Notes', value: char.dm_notes }
|
|
|
+ )
|
|
|
+ end
|
|
|
|
|
|
fields
|
|
|
end
|
|
|
@@ -204,37 +247,39 @@ def char_list_embed(chars, group, sort = nil)
|
|
|
case group
|
|
|
when /active/i
|
|
|
title = "Registered Guild Members -- [#{chars.count}]"
|
|
|
- desc = "These are the pokemon registered to the guild, sorted by primary type"
|
|
|
+ desc = 'These are the pokemon registered to the guild, sorted by primary type'
|
|
|
when /archived/i
|
|
|
title = "Archived Guild Members -- [#{chars.count}]"
|
|
|
- desc = "These are the pokemon in the guild archives, sorted by primary type"
|
|
|
+ desc = 'These are the pokemon in the guild archives, sorted by primary type'
|
|
|
when /npc/i
|
|
|
title = "Registered Guild NPCs -- [#{chars.length}]"
|
|
|
- desc = "These are the NPCs from all around Zaplana, sorted by current location"
|
|
|
+ desc = 'These are the NPCs from all around Zaplana, sorted by current location'
|
|
|
when /special/i
|
|
|
title = "Special Characters -- [#{chars.count}]"
|
|
|
- desc = "These are the special pokemon around Zaplana, sorted by category"
|
|
|
+ desc = 'These are the special pokemon around Zaplana, sorted by category'
|
|
|
end
|
|
|
|
|
|
case sort&.first
|
|
|
when Type
|
|
|
sort.each do |s|
|
|
|
list[s.name] = chars.map do |c|
|
|
|
- next unless c.types.split("/").first === s.name
|
|
|
+ next unless c.types.split('/').first === s.name
|
|
|
+
|
|
|
name = c.name
|
|
|
name = "|| #{name} ||" if c.rating&.match(/NSFW/i)
|
|
|
name
|
|
|
end.compact
|
|
|
end
|
|
|
|
|
|
- list = list.reject { |k,v| v == [] }
|
|
|
- list.each do |k,v|
|
|
|
- fields.push({ name: k, value: v.join(", ") })
|
|
|
+ list = list.reject { |_k, v| v == [] }
|
|
|
+ list.each do |k, v|
|
|
|
+ fields.push({ name: k, value: v.join(', ') })
|
|
|
end
|
|
|
when Region
|
|
|
sort.each do |s|
|
|
|
list[s.name] = chars.map do |c|
|
|
|
next unless c.region == s.name
|
|
|
+
|
|
|
name = c.name
|
|
|
name = "*#{name}*" if c.user_id.match(/public/i)
|
|
|
name = "|| #{name} ||" if c.rating&.match(/NSFW/i)
|
|
|
@@ -242,58 +287,56 @@ def char_list_embed(chars, group, sort = nil)
|
|
|
end.compact
|
|
|
end
|
|
|
|
|
|
-
|
|
|
- list["Unknown"] = chars.map do |c|
|
|
|
+ list['Unknown'] = chars.map do |c|
|
|
|
next unless c.region.nil?
|
|
|
+
|
|
|
name = c.name
|
|
|
name = "*#{name}*" if c.user_id.match(/public/i)
|
|
|
name = "|| #{name} ||" if c.rating&.match(/NSFW/i)
|
|
|
name
|
|
|
end.compact
|
|
|
|
|
|
- list = list.reject { |k,v| v == [] }
|
|
|
- list.each do |k,v|
|
|
|
- fields.push({ name: k, value: v.join(", ") })
|
|
|
+ list = list.reject { |_k, v| v == [] }
|
|
|
+ list.each do |k, v|
|
|
|
+ fields.push({ name: k, value: v.join(', ') })
|
|
|
end
|
|
|
when nil
|
|
|
- list["guild"] = []
|
|
|
- list["adoptable"] = []
|
|
|
- list["legend"] = []
|
|
|
+ list['guild'] = []
|
|
|
+ list['adoptable'] = []
|
|
|
+ list['legend'] = []
|
|
|
|
|
|
chars.each do |c|
|
|
|
case c.special
|
|
|
when /legend/i
|
|
|
- list["legend"].push("#{c.name}, #{c.species} -- last seen: #{c.location || "???"}")
|
|
|
+ list['legend'].push("#{c.name}, #{c.species} -- last seen: #{c.location || '???'}")
|
|
|
when /guild/i
|
|
|
- list["guild"].push("#{c.name}, #{c.species}")
|
|
|
+ list['guild'].push("#{c.name}, #{c.species}")
|
|
|
else
|
|
|
- list["adoptable"].push("#{c.name}, #{c.species} -- #{c.location || "???"}")
|
|
|
+ list['adoptable'].push("#{c.name}, #{c.species} -- #{c.location || '???'}")
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- list = list.reject { |k,v| v == [] }
|
|
|
- list.each do |k,v|
|
|
|
+ list = list.reject { |_k, v| v == [] }
|
|
|
+ list.each do |k, v|
|
|
|
case k
|
|
|
when /legend/i
|
|
|
- fields.push({ name: "Mythic/Legend Pokemon", value: v.join("\n") })
|
|
|
+ fields.push({ name: 'Mythic/Legend Pokemon', value: v.join("\n") })
|
|
|
when /guild/i
|
|
|
- fields.push({ name: "Guild Employees", value: v.join("\n") })
|
|
|
+ fields.push({ name: 'Guild Employees', value: v.join("\n") })
|
|
|
when /adoptable/i
|
|
|
- fields.push({ name: "Adoptable NPCs", value: v.join("\n") })
|
|
|
+ fields.push({ name: 'Adoptable NPCs', value: v.join("\n") })
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- if fields.empty?
|
|
|
- fields.push({name: "No Resulst", value: "--"})
|
|
|
- end
|
|
|
+ fields.push({ name: 'No Resulst', value: '--' }) if fields.empty?
|
|
|
|
|
|
Embed.new(
|
|
|
title: title,
|
|
|
description: desc,
|
|
|
fields: fields,
|
|
|
footer: {
|
|
|
- text: "React to Navigate | 1. Active | 2. Archived | 3. NPCs | 4. Special"
|
|
|
+ text: 'React to Navigate | 1. Active | 2. Archived | 3. NPCs | 4. Special'
|
|
|
}
|
|
|
)
|
|
|
end
|
|
|
@@ -303,7 +346,7 @@ def user_char_embed(chars, member, nsfw=nil)
|
|
|
active = []
|
|
|
archived = []
|
|
|
npcs = []
|
|
|
- user_name = member&.nickname || member&.name || "Unknown User"
|
|
|
+ user_name = member&.nickname || member&.name || 'Unknown User'
|
|
|
|
|
|
chars.each do |char|
|
|
|
case char.active
|
|
|
@@ -317,31 +360,32 @@ def user_char_embed(chars, member, nsfw=nil)
|
|
|
end
|
|
|
|
|
|
active.each.with_index do |char, i|
|
|
|
- name = nsfw && char.rating == 'NSFW' ?
|
|
|
- "#{i+1} || #{char.name} ||" : "#{i+1} #{char.name}"
|
|
|
+ name = if nsfw && char.rating == 'NSFW'
|
|
|
+ "#{i + 1} || #{char.name} ||"
|
|
|
+ else
|
|
|
+ "#{i + 1} #{char.name}"
|
|
|
+ end
|
|
|
fields.push({
|
|
|
- name: name,
|
|
|
- value: "#{char.species} -- #{char.types}"
|
|
|
- })
|
|
|
+ name: name,
|
|
|
+ value: "#{char.species} -- #{char.types}"
|
|
|
+ })
|
|
|
end
|
|
|
|
|
|
unless archived.empty?
|
|
|
fields.push({
|
|
|
- name: "#{user_name}'s Archived Characters",
|
|
|
- value: archived.join(", ")
|
|
|
- })
|
|
|
+ name: "#{user_name}'s Archived Characters",
|
|
|
+ value: archived.join(', ')
|
|
|
+ })
|
|
|
end
|
|
|
|
|
|
- unless npcs.empty?
|
|
|
- fields.push({ name: "#{user_name}'s NPCs", value: npcs.join(", ") })
|
|
|
- end
|
|
|
+ fields.push({ name: "#{user_name}'s NPCs", value: npcs.join(', ') }) unless npcs.empty?
|
|
|
|
|
|
# Find allowed active characters
|
|
|
allowed = member ? User.find(member.id.to_s).allowed_chars(member) : '???'
|
|
|
|
|
|
embed = Embed.new(
|
|
|
title: "#{user_name}'s Characters [#{active.count}/#{allowed}]",
|
|
|
- description: "Click on the corresponding reaction to view the character",
|
|
|
+ description: 'Click on the corresponding reaction to view the character',
|
|
|
fields: fields
|
|
|
)
|
|
|
|
|
|
@@ -354,29 +398,32 @@ def dup_char_embed(chars, name)
|
|
|
|
|
|
chars.each.with_index do |char, i|
|
|
|
fields.push({
|
|
|
- name: "#{Emoji::NUMBERS[i]}: #{char.species}",
|
|
|
- value: "Created by <@#{char.user_id}>"
|
|
|
- })
|
|
|
+ name: "#{Emoji::NUMBERS[i]}: #{char.species}",
|
|
|
+ value: "Created by <@#{char.user_id}>"
|
|
|
+ })
|
|
|
end
|
|
|
|
|
|
Embed.new(
|
|
|
title: "Which #{name}?",
|
|
|
- description: "Click on the corresponding reaction to pick",
|
|
|
+ description: 'Click on the corresponding reaction to pick',
|
|
|
fields: fields
|
|
|
)
|
|
|
end
|
|
|
|
|
|
def image_list_embed(character, event)
|
|
|
# Find the author, if they're a member, or in DMs use the event's author
|
|
|
- if event.server
|
|
|
- member = character.user_id.match(/public/i) ? 'Public' :
|
|
|
- event.server.member(character.user_id)
|
|
|
- else
|
|
|
- member = event.author
|
|
|
- end
|
|
|
+ member = if event.server
|
|
|
+ if character.user_id.match(/public/i)
|
|
|
+ 'Public'
|
|
|
+ else
|
|
|
+ event.server.member(character.user_id)
|
|
|
+ end
|
|
|
+ else
|
|
|
+ event.author
|
|
|
+ end
|
|
|
# Grab an array of the character's images
|
|
|
images = CharImage.where(char_id: character.id).
|
|
|
- map{ |i| "[#{i.keyword}](#{i.url})" }
|
|
|
+ map { |i| "[#{i.keyword}](#{i.url})" }
|
|
|
|
|
|
# Create Embed
|
|
|
embed = Embed.new(
|