Better emoji pack names

This commit is contained in:
Cadence Ember
2026-02-03 01:02:57 +13:00
parent af9e2d89a5
commit b16d731ddb
2 changed files with 10 additions and 6 deletions

View File

@@ -229,14 +229,16 @@ async function syncSpaceExpressions(data, checkBeforeSync) {
*/
async function update(spaceID, key, eventKey, fn) {
if (!(key in data) || !data[key].length) return
const content = await fn(data[key])
const guild = discord.guilds.get(data.guild_id)
assert(guild)
const content = await fn(data[key], guild)
if (checkBeforeSync) {
let existing
try {
existing = await api.getStateEvent(spaceID, "im.ponies.room_emotes", eventKey)
} catch (e) {
// State event not found. This space doesn't have any existing emojis. We create a dummy empty event for comparison's sake.
existing = fn([])
existing = fn([], guild)
}
if (isDeepStrictEqual(existing, content)) return
}

View File

@@ -9,11 +9,12 @@ const file = sync.require("../../matrix/file")
/**
* @param {DiscordTypes.APIEmoji[]} emojis
* @param {DiscordTypes.APIGuild} guild
*/
async function emojisToState(emojis) {
async function emojisToState(emojis, guild) {
const result = {
pack: {
display_name: "Discord Emojis",
display_name: `${guild.name} (Discord Emojis)`,
usage: ["emoticon"] // we'll see...
},
images: {
@@ -42,11 +43,12 @@ async function emojisToState(emojis) {
/**
* @param {DiscordTypes.APISticker[]} stickers
* @param {DiscordTypes.APIGuild} guild
*/
async function stickersToState(stickers) {
async function stickersToState(stickers, guild) {
const result = {
pack: {
display_name: "Discord Stickers",
display_name: `${guild.name} (Discord Stickers)`,
usage: ["sticker"] // we'll see...
},
images: {