make embeds use STATICs

This commit is contained in:
derpystuff 2022-07-03 23:08:31 +02:00
parent 320c7464ba
commit bfb3168bf9
2 changed files with 30 additions and 6 deletions

View file

@ -1,6 +1,6 @@
const { COLORS } = require('../constants') const { COLORS } = require('../constants')
const { STATIC_ICONS } = require('./statics')
// TODO: make embed icons use the general STATICS system
const embedTypes = Object.freeze({ const embedTypes = Object.freeze({
"default": (context) => { "default": (context) => {
return { return {
@ -36,7 +36,7 @@ const embedTypes = Object.freeze({
"warning": (context) => { "warning": (context) => {
return { return {
author: { author: {
iconUrl: `https://derpystuff.gitlab.io/webstorage4/v2/assets/icons/ico_warning_small.png`, iconUrl: STATIC_ICONS.warning,
name: `Warning` name: `Warning`
}, },
color: COLORS.warning color: COLORS.warning
@ -45,7 +45,7 @@ const embedTypes = Object.freeze({
"error": (context) => { "error": (context) => {
return { return {
author: { author: {
iconUrl: `https://derpystuff.gitlab.io/webstorage4/v2/assets/icons/ico_error_small.png`, iconUrl: STATIC_ICONS.error,
name: `Error` name: `Error`
}, },
color: COLORS.error color: COLORS.error
@ -54,7 +54,7 @@ const embedTypes = Object.freeze({
"nsfw": (context) => { "nsfw": (context) => {
return { return {
author: { 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.`, 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` 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) => { "loading": (context) => {
return { return {
author: { author: {
iconUrl: `https://derpystuff.gitlab.io/webstorage4/v2/assets/icons/ico_loading_small.gif`, iconUrl: STATIC_ICONS.loading,
name: `Loading` name: `Loading`
}, },
color: COLORS.embed color: COLORS.embed
@ -78,7 +78,6 @@ module.exports.createEmbed = function(type, context, content){
if(!content) embedTypes[type](context) if(!content) embedTypes[type](context)
let emb = embedTypes[type](context) let emb = embedTypes[type](context)
// Special handling
if(["success","warning","error","loading"].includes(type)){ if(["success","warning","error","loading"].includes(type)){
emb.author.name = content emb.author.name = content
return emb return emb

View file

@ -48,6 +48,24 @@ const Statics = Object.freeze({
file: "brands/youtube.png", file: "brands/youtube.png",
revision: 1 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), wikihow: staticAsset(Statics.brands.wikihow),
wolframalpha: staticAsset(Statics.brands.wolframalpha), wolframalpha: staticAsset(Statics.brands.wolframalpha),
youtube: staticAsset(Statics.brands.youtube) 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)
}) })