Fix emoji_id references and add tests
This commit is contained in:
@@ -14,7 +14,7 @@ async function emojiToKey(emoji) {
|
||||
let key
|
||||
if (emoji.id) {
|
||||
// Custom emoji
|
||||
const mxc = select("emoji", "mxc_url", {emoji_id: emoji.id}).pluck().get(emoji.id)
|
||||
const mxc = select("emoji", "mxc_url", {emoji_id: emoji.id}).pluck().get()
|
||||
if (mxc) {
|
||||
// The custom emoji is registered and we should send it
|
||||
key = mxc
|
||||
@@ -22,7 +22,7 @@ async function emojiToKey(emoji) {
|
||||
// The custom emoji is not registered. We will register it and then add it.
|
||||
assert(emoji.name) // The docs say: "name may be null when custom emoji data is not available, for example, if it was deleted from the guild"
|
||||
const mxc = await file.uploadDiscordFileToMxc(file.emoji(emoji.id, emoji.animated))
|
||||
db.prepare("INSERT OR IGNORE INTO emoji (id, name, animated, mxc_url) VALUES (?, ?, ?, ?)").run(emoji.id, emoji.name, +!!emoji.animated, mxc)
|
||||
db.prepare("INSERT OR IGNORE INTO emoji (emoji_id, name, animated, mxc_url) VALUES (?, ?, ?, ?)").run(emoji.id, emoji.name, +!!emoji.animated, mxc)
|
||||
key = mxc
|
||||
// TODO: what happens if the matrix user also tries adding this reaction? the bridge bot isn't able to use that emoji...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user