From bfb3168bf9d976895eddd585e5a56f5232bfab5e Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Sun, 3 Jul 2022 23:08:31 +0200 Subject: [PATCH] make embeds use STATICs --- labscore/utils/embed.js | 11 +++++------ labscore/utils/statics.js | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/labscore/utils/embed.js b/labscore/utils/embed.js index 411dc17..ec01512 100644 --- a/labscore/utils/embed.js +++ b/labscore/utils/embed.js @@ -1,6 +1,6 @@ const { COLORS } = require('../constants') +const { STATIC_ICONS } = require('./statics') -// TODO: make embed icons use the general STATICS system const embedTypes = Object.freeze({ "default": (context) => { return { @@ -36,7 +36,7 @@ const embedTypes = Object.freeze({ "warning": (context) => { return { author: { - iconUrl: `https://derpystuff.gitlab.io/webstorage4/v2/assets/icons/ico_warning_small.png`, + iconUrl: STATIC_ICONS.warning, name: `Warning` }, color: COLORS.warning @@ -45,7 +45,7 @@ const embedTypes = Object.freeze({ "error": (context) => { return { author: { - iconUrl: `https://derpystuff.gitlab.io/webstorage4/v2/assets/icons/ico_error_small.png`, + iconUrl: STATIC_ICONS.error, name: `Error` }, color: COLORS.error @@ -54,7 +54,7 @@ const embedTypes = Object.freeze({ "nsfw": (context) => { return { author: { - iconUrl: `https://derpystuff.gitlab.io/webstorage4/v2/assets/icons/ico_nsfw_small.png`, + iconUrl: STATIC_ICONS.adult, name: `This command is only available in Age Restricted channels.`, url: `https://support.discord.com/hc/en-us/articles/115000084051-Age-Restricted-Channels-and-Content` }, @@ -64,7 +64,7 @@ const embedTypes = Object.freeze({ "loading": (context) => { return { author: { - iconUrl: `https://derpystuff.gitlab.io/webstorage4/v2/assets/icons/ico_loading_small.gif`, + iconUrl: STATIC_ICONS.loading, name: `Loading` }, color: COLORS.embed @@ -78,7 +78,6 @@ module.exports.createEmbed = function(type, context, content){ if(!content) embedTypes[type](context) let emb = embedTypes[type](context) - // Special handling if(["success","warning","error","loading"].includes(type)){ emb.author.name = content return emb diff --git a/labscore/utils/statics.js b/labscore/utils/statics.js index 11244b3..3d6bef9 100644 --- a/labscore/utils/statics.js +++ b/labscore/utils/statics.js @@ -48,6 +48,24 @@ const Statics = Object.freeze({ file: "brands/youtube.png", revision: 1 } + }, + icons: { + adult: { + file: "icons/ico_nsfw_small.png", + revision: 0 + }, + error: { + file: "icons/ico_warning_small.png", + revision: 0 + }, + loading: { + file: "icons/ico_loading_small.gif", + revision: 0 + }, + warning: { + file: "icons/ico_warning_small.png", + revision: 0 + } } }) @@ -67,4 +85,11 @@ module.exports.STATICS = Object.freeze({ wikihow: staticAsset(Statics.brands.wikihow), wolframalpha: staticAsset(Statics.brands.wolframalpha), youtube: staticAsset(Statics.brands.youtube) +}) + +module.exports.STATIC_ICONS = Object.freeze({ + adult: staticAsset(Statics.icons.adult), + error: staticAsset(Statics.icons.error), + loading: staticAsset(Statics.icons.loading), + warning: staticAsset(Statics.icons.warning) }) \ No newline at end of file