From 8bfd4d2cc57e2128eb9da28fcfc8a6c40127d832 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 19 Jun 2020 21:28:49 +0300 Subject: [PATCH] emoji stuff, auto format emojis in the format func --- structure/extensions/Guild.js | 8 ++++++-- structure/extensions/Message.js | 6 +++++- util/emojis.json | 15 +++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/structure/extensions/Guild.js b/structure/extensions/Guild.js index 748e892..b304520 100644 --- a/structure/extensions/Guild.js +++ b/structure/extensions/Guild.js @@ -1,6 +1,6 @@ const escapeRegex = require('escape-string-regexp'); const { Structures } = require('discord.js'); -const { Collection } = require('../../util'); +const { Collection, Emojis } = require('../../util'); const Guild = Structures.extend('Guild', (Guild) => { @@ -123,12 +123,16 @@ const Guild = Structures.extend('Guild', (Guild) => { parameters.prefix = this.prefix; let template = this.client.localeLoader.template(language, index); + for(const emoji of Object.keys(Emojis)) { + parameters[`emoji_${emoji}`] = Emojis[emoji]; + } + if (!template) { return `**Missing language index \`${language} [${index}]\` in languages. Contact a bot developer about this.**`; } for (const [param, val] of Object.entries(parameters)) { - template = template.replace(new RegExp(`{${escapeRegex(param.toLowerCase())}}`, 'giu'), val); + template = template.replace(new RegExp(`{${escapeRegex(param.toLowerCase())}}`, 'gi'), val); } if (code) { diff --git a/structure/extensions/Message.js b/structure/extensions/Message.js index 9506dcc..c76fbe6 100644 --- a/structure/extensions/Message.js +++ b/structure/extensions/Message.js @@ -3,7 +3,7 @@ const { Structures } = require('discord.js'); const escapeRegex = require('escape-string-regexp'); const emojis = require('../../util/emojis.json'); -const { Util } = require('../../util/'); +const { Util, Emojis } = require('../../util/'); const { stripIndents } = require('common-tags') const Message = Structures.extend('Message', (Message) => { @@ -30,6 +30,10 @@ const Message = Structures.extend('Message', (Message) => { parameters.prefix = this.guild?.prefix; let template = this.client.localeLoader.template(language, index); //.languages[language][index]; + for(const emoji of Object.keys(Emojis)) { + parameters[`emoji_${emoji}`] = Emojis[emoji]; + } + if(!template) { return `**Missing language index \`${language} [${index}]\` in languages. Contact a bot developer about this.**`; } diff --git a/util/emojis.json b/util/emojis.json index c9b538c..9e058c0 100644 --- a/util/emojis.json +++ b/util/emojis.json @@ -1,10 +1,13 @@ { - "success": "👍", - "failure": "👎", - "loading": "⚙", + "success": "<:success:723595130808041512>", + "failure": "<:failure:723595130912637018>", + "loading": "", "warning": "⚠", - "enabled": "<:enabled:591893186884927508>", - "disabled": "<:disabled:591893185995735050>", + "enabled": "<:enabled:723589993733423215>", + "disabled": "<:disabled:723589993506799618>", "text-channel": "<:textchannel:716414423094525952>", - "voice-channel": "<:voicechannel:716414422662512762>" + "voice-channel": "<:voicechannel:716414422662512762>", + "pin": "📌", + "note": "📝", + "trash": "🗑️" } \ No newline at end of file