Use fileName for storage instead of emojiName
Change-Id: I0b93d8b2141beda53786db16c211bca9f396fd9c
diff --git a/index.ts b/index.ts
index 1b1b5c0..8b3c2f6 100644
--- a/index.ts
+++ b/index.ts
@@ -79,16 +79,16 @@
while (emojiCount > 0 && !(currentEmojiIndex >= emojiFiles.length)) {
let emoji = emojiFiles[currentEmojiIndex];
let attachment = readFileSync(`${process.env.EMOJI_DIR}/${emoji.name}`);
- let longName = emoji.name.split('.')[0].split('_').pop()?.replaceAll(/\-/g, "_");
- let name = (longName ?? "_").substring(0, Math.min((longName ?? "_").length, 32));
+ let longName = emoji.name.split('.')[0].split('_').pop()!.replaceAll(/\-/g, "_");
+ let name = longName.substring(0, Math.min(longName.length, 32));
let i = 1;
while (emojis.get(name)) {
name = name.substring(0,-(i.toString().length)) + i
i++
}
const outEmoji = await uploadEmoji(guild, {name, attachment});
- console.log(`${name}: ${outEmoji.id}`)
- emojis.set(name, outEmoji.id);
+ console.log(`${emoji.name.split('.')[0]}: ${outEmoji.id}`);
+ emojis.set(emoji.name.split('.')[0], outEmoji.id);
emojiCount--;
currentEmojiIndex++;