Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
♻️ Remove duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilbert142 committed Dec 9, 2018
1 parent 1c5b151 commit f3a1381
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions Internals/Events/guildUpdate/GAB.GuildUpdate.js
@@ -1,5 +1,6 @@
const BaseEvent = require("../BaseEvent");
const { StatusMessages } = require("../../Constants");
const { GetFlagForRegion } = require("../../../Modules/Utils");

class GuildUpdate extends BaseEvent {
async handle (oldGuild, guild) {
Expand Down Expand Up @@ -35,38 +36,8 @@ class GuildUpdate extends BaseEvent {
winston.verbose(`Region of guild '${oldGuild.name}' changed from '${oldGuild.region}' to '${guild.region}'`, { svrid: guild.id });
const channel = guild.channels.get(serverDocument.config.moderation.status_messages.server_region_updated_message.channel_id);
if (channel) {
const getRegionEmoji = region => {
if (region.startsWith("us-")) return ":flag_us:";
if (region.startsWith("eu-")) return ":flag_eu:";

switch (region) {
case "amsterdam":
return ":flag_nl:";
case "brazil":
return ":flag_br:";
case "frankfurt":
return ":flag_de:";
case "hongkong":
return ":flag_hk:";
case "japan":
return ":flag_jp:";
case "london":
return ":flag_gb:";
case "russia":
return ":flag_ru:";
case "singapore":
return ":flag_sg:";
case "southafrica":
return ":flag_za:";
case "sydney":
return ":flag_au:";
default:
return ":grey_question:";
}
};

const getRegionString = region => {
const emoji = getRegionEmoji(region);
const emoji = GetFlagForRegion(region);
if (region.startsWith("us-") || region.startsWith("eu-")) return `**${region.substring(0, 2).toUpperCase()} ${region.charAt(3).toUpperCase()}${region.slice(4)}** ${emoji}`;
else return `**${region.charAt(0).toUpperCase()}${region.slice(1)}** ${emoji}`;
};
Expand Down

0 comments on commit f3a1381

Please sign in to comment.