custom emoji picker

merges fbb7ed3c9c (diff-beb98739004ececc621a1ab4a177e04f96d8d358c215716df0dcf1e1cb0f453c) and makes it fully functional along with CSS fixes
This commit is contained in:
MathMan05 2024-08-13 13:53:52 -05:00
parent 96faadddd0
commit ece9ebceb5
8 changed files with 174 additions and 60 deletions

View file

@ -49,7 +49,7 @@ class Message {
navigator.clipboard.writeText(this.id);
});
Message.contextmenu.addsubmenu("Add reaction", function (e) {
Emoji.emojiPicker(e.x, e.y).then(_ => {
Emoji.emojiPicker(e.x, e.y, this.localuser).then(_ => {
console.log(_, ":3");
this.reactionToggle(_);
});
@ -70,22 +70,24 @@ class Message {
this.giveData(messagejson);
}
reactionToggle(emoji) {
if (typeof emoji === "string") {
let remove = false;
for (const thing of this.reactions) {
if (thing.emoji.name === emoji) {
remove = thing.me;
break;
}
let remove = false;
for (const thing of this.reactions) {
if (thing.emoji.name === emoji) {
remove = thing.me;
break;
}
fetch(this.info.api + "/channels/" + this.channel.id + "/messages/" + this.id + "/reactions/" + encodeURIComponent(emoji) + "/@me", {
method: remove ? "DELETE" : "PUT",
headers: this.headers,
});
}
let reactiontxt;
if (emoji instanceof Emoji) {
reactiontxt = emoji.id;
}
else {
emoji;
reactiontxt = encodeURIComponent(emoji);
}
fetch(`${this.info.api}/channels/${this.channel.id}/messages/${this.id}/reactions/${reactiontxt}/@me`, {
method: remove ? "DELETE" : "PUT",
headers: this.headers
});
}
giveData(messagejson) {
for (const thing of Object.keys(messagejson)) {
@ -383,7 +385,9 @@ class Message {
reaction.classList.add("meReacted");
}
let emoji;
if (thing.emoji.id) {
if (thing.emoji.id || /\d{17,21}/.test(thing.emoji.name)) {
if (/\d{17,21}/.test(thing.emoji.name))
thing.emoji.id = thing.emoji.name; //Should stop being a thing once the server fixes this bug
const emo = new Emoji(thing.emoji, this.guild);
emoji = emo.getHTML(false);
}