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 { 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

View file

@ -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)
})