From c2c8241080849d57c3cf937fb1d73bec8236e238 Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Sun, 9 Jul 2023 12:36:34 +0200 Subject: [PATCH] make labscore icon in footer use brand static --- commands/message/image/anime.js | 3 ++- commands/message/image/dalle.js | 3 ++- commands/message/image/stablediffusion.js | 3 ++- commands/message/utils/qr.js | 3 ++- labscore/utils/cdn.js | 5 +++++ labscore/utils/embed.js | 8 ++++---- labscore/utils/statics.js | 5 +++++ 7 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 labscore/utils/cdn.js diff --git a/commands/message/image/anime.js b/commands/message/image/anime.js index 9c9a3c9..7806fb9 100644 --- a/commands/message/image/anime.js +++ b/commands/message/image/anime.js @@ -5,6 +5,7 @@ const superagent = require('superagent'); const { getRecentImage } = require("../../../labscore/utils/attachment"); const { Permissions } = require("detritus-client/lib/constants"); +const { STATICS } = require("../../../labscore/utils/statics"); module.exports = { name: 'anime', @@ -69,7 +70,7 @@ module.exports = { let embeds = []; let files = []; - embeds.push(createEmbed("default", context, {image: {url:`attachment://anime.png`}, url: `https://example.com`, footer: { iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`, text: `${context.application.name} • Took ${((Date.now() - t) / 1000).toFixed(2)}s` }})) + embeds.push(createEmbed("default", context, {image: {url:`attachment://anime.png`}, url: `https://example.com`, footer: { iconUrl: STATICS.labscore, text: `${context.application.name} • Took ${((Date.now() - t) / 1000).toFixed(2)}s` }})) files.push({ filename: `anime.png`, value: Buffer.from(img.body.image, 'base64') diff --git a/commands/message/image/dalle.js b/commands/message/image/dalle.js index ff40800..cd83fd6 100644 --- a/commands/message/image/dalle.js +++ b/commands/message/image/dalle.js @@ -4,6 +4,7 @@ const { editOrReply } = require("../../../labscore/utils/message"); const superagent = require('superagent'); const { Permissions } = require("detritus-client/lib/constants"); +const { STATICS } = require("../../../labscore/utils/statics"); module.exports = { name: 'dalle', @@ -49,7 +50,7 @@ module.exports = { let files = []; for(let i = 0; i < 4; i++){ - embeds.push(createEmbed("default", context, {image: {url:`attachment://dalle${i}.jpeg`}, url: `https://example.com`, footer: { iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`, text: `${context.application.name} • Took ${((Date.now() - t) / 1000).toFixed(2)}s` }})) + embeds.push(createEmbed("default", context, {image: {url:`attachment://dalle${i}.jpeg`}, url: `https://example.com`, footer: { iconUrl: STATICS.labscore, text: `${context.application.name} • Took ${((Date.now() - t) / 1000).toFixed(2)}s` }})) files.push({ filename: `dalle${i}.jpeg`, value: Buffer.from(img.body.images[i], 'base64') diff --git a/commands/message/image/stablediffusion.js b/commands/message/image/stablediffusion.js index b463217..3102586 100644 --- a/commands/message/image/stablediffusion.js +++ b/commands/message/image/stablediffusion.js @@ -4,6 +4,7 @@ const { editOrReply } = require("../../../labscore/utils/message"); const superagent = require('superagent'); const { Permissions } = require("detritus-client/lib/constants"); +const { STATICS } = require("../../../labscore/utils/statics"); module.exports = { name: 'stability', @@ -50,7 +51,7 @@ module.exports = { let files = []; for(let i = 0; i < 4; i++){ - embeds.push(createEmbed("default", context, {image: {url:`attachment://stability${i}.jpeg`}, url: `https://example.com`, footer: { iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`, text: `${context.application.name} • Took ${((Date.now() - t) / 1000).toFixed(2)}s` }})) + embeds.push(createEmbed("default", context, {image: {url:`attachment://stability${i}.jpeg`}, url: `https://example.com`, footer: { iconUrl: STATICS.labscore, text: `${context.application.name} • Took ${((Date.now() - t) / 1000).toFixed(2)}s` }})) files.push({ filename: `stability${i}.jpeg`, value: Buffer.from(img.body.images[i].replace('data:image/jpeg;base64,',''), 'base64') diff --git a/commands/message/utils/qr.js b/commands/message/utils/qr.js index c81b5e6..dbf1de7 100644 --- a/commands/message/utils/qr.js +++ b/commands/message/utils/qr.js @@ -7,6 +7,7 @@ const { codeblock, icon } = require('../../../labscore/utils/markdown'); const superagent = require('superagent'); const { Permissions } = require("detritus-client/lib/constants"); +const { STATICS } = require('../../../labscore/utils/statics'); module.exports = { name: 'qr', @@ -76,7 +77,7 @@ module.exports = { url: image }, footer: { - iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`, + iconUrl: STATICS.labscore, text: `labsCore • Took ${((Date.now() - t) / 1000).toFixed(2)}s` } })) diff --git a/labscore/utils/cdn.js b/labscore/utils/cdn.js new file mode 100644 index 0000000..c4a7840 --- /dev/null +++ b/labscore/utils/cdn.js @@ -0,0 +1,5 @@ +const CDN = "https://cdn.discordapp.com" + +const cdnUrl = (route, size, format) => `${CDN}${route}.${format}?size=${size}` + +module.exports.guildIcon = (id, hash, size = 4096, format = "png") => cdnUrl(`/icons/${id}/${hash}`, size, format) \ No newline at end of file diff --git a/labscore/utils/embed.js b/labscore/utils/embed.js index 134060c..a780b10 100644 --- a/labscore/utils/embed.js +++ b/labscore/utils/embed.js @@ -1,12 +1,12 @@ const { COLORS } = require('../constants') -const { STATIC_ICONS } = require('./statics') +const { STATIC_ICONS, STATICS } = require('./statics') const embedTypes = Object.freeze({ "default": (context) => { return { color: COLORS.embed, footer: { - iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`, + iconUrl: STATICS.labscore, text: context.application.name } } @@ -15,7 +15,7 @@ const embedTypes = Object.freeze({ return { color: COLORS.embed, footer: { - iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`, + iconUrl: STATICS.labscore, text: context.application.name } } @@ -98,7 +98,7 @@ module.exports.createEmbed = function(type, context, content){ return emb } - if(content && content.footer && !content.footer.iconUrl) content.footer.iconUrl = `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256` + if(content && content.footer && !content.footer.iconUrl) content.footer.iconUrl = STATICS.labscore if(["image"].includes(type)){ if(content.url.includes('://')){ diff --git a/labscore/utils/statics.js b/labscore/utils/statics.js index 80b713c..c9beaa6 100644 --- a/labscore/utils/statics.js +++ b/labscore/utils/statics.js @@ -32,6 +32,10 @@ const Statics = Object.freeze({ file: "brands/inspirobot.png", revision: 0 }, + labscore: { + file: "brands/labscore.png", + revision: 0 + }, makesweet: { file: "brands/makesweet.png", revision: 0 @@ -113,6 +117,7 @@ module.exports.STATICS = Object.freeze({ emojipedia: staticAsset(Statics.brands.emojipedia), inferkit: staticAsset(Statics.brands.inferkit), inspirobot: staticAsset(Statics.brands.inspirobot), + labscore: staticAsset(Statics.brands.labscore), makesweet: staticAsset(Statics.brands.makesweet), openweathermap: staticAsset(Statics.brands.openweathermap), perspectiveapi: staticAsset(Statics.brands.perspectiveapi),