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
+4 -2
View File
@@ -229,14 +229,16 @@ async function syncSpaceExpressions(data, checkBeforeSync) {
*/ */
async function update(spaceID, key, eventKey, fn) { async function update(spaceID, key, eventKey, fn) {
if (!(key in data) || !data[key].length) return 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) { if (checkBeforeSync) {
let existing let existing
try { try {
existing = await api.getStateEvent(spaceID, "im.ponies.room_emotes", eventKey) existing = await api.getStateEvent(spaceID, "im.ponies.room_emotes", eventKey)
} catch (e) { } catch (e) {
// State event not found. This space doesn't have any existing emojis. We create a dummy empty event for comparison's sake. // 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 if (isDeepStrictEqual(existing, content)) return
} }
+6 -4
View File
@@ -9,11 +9,12 @@ const file = sync.require("../../matrix/file")
/** /**
* @param {DiscordTypes.APIEmoji[]} emojis * @param {DiscordTypes.APIEmoji[]} emojis
* @param {DiscordTypes.APIGuild} guild
*/ */
async function emojisToState(emojis) { async function emojisToState(emojis, guild) {
const result = { const result = {
pack: { pack: {
display_name: "Discord Emojis", display_name: `${guild.name} (Discord Emojis)`,
usage: ["emoticon"] // we'll see... usage: ["emoticon"] // we'll see...
}, },
images: { images: {
@@ -42,11 +43,12 @@ async function emojisToState(emojis) {
/** /**
* @param {DiscordTypes.APISticker[]} stickers * @param {DiscordTypes.APISticker[]} stickers
* @param {DiscordTypes.APIGuild} guild
*/ */
async function stickersToState(stickers) { async function stickersToState(stickers, guild) {
const result = { const result = {
pack: { pack: {
display_name: "Discord Stickers", display_name: `${guild.name} (Discord Stickers)`,
usage: ["sticker"] // we'll see... usage: ["sticker"] // we'll see...
}, },
images: { images: {