Merge pull request #50 from DEVTomatoCake/jank/msg-reaction-remove-all-emoji

msg reaction remove all & emoji gateway event
This commit is contained in:
MathMan05 2024-08-25 15:41:21 -05:00 committed by GitHub
commit 75c58c3ef0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 4 deletions

View file

@ -379,7 +379,7 @@ class Localuser{
}else{
thing={id:temp.d.user_id}
}
message.makeReaction(temp.d.emoji,thing);
message.reactionAdd(temp.d.emoji,thing);
}
break;
case "MESSAGE_REACTION_REMOVE":
@ -387,9 +387,21 @@ class Localuser{
const message=SnowFlake.getSnowFlakeFromID(temp.d.message_id,Message).getObject();
console.log("test");
message.removeReaction(temp.d.emoji,temp.d.user_id);
message.reactionRemove(temp.d.emoji,temp.d.user_id);
}
break;
case "MESSAGE_REACTION_REMOVE_ALL":
if (SnowFlake.hasSnowFlakeFromID(temp.d.message_id, Message)) {
const messageReactionRemoveAll = SnowFlake.getSnowFlakeFromID(temp.d.message_id, Message).getObject()
messageReactionRemoveAll.reactionRemoveAll()
}
break
case "MESSAGE_REACTION_REMOVE_EMOJI":
if (SnowFlake.hasSnowFlakeFromID(temp.d.message_id, Message)) {
const messageReactionRemoveEmoji = SnowFlake.getSnowFlakeFromID(temp.d.message_id, Message).getObject()
messageReactionRemoveEmoji.reactionRemoveEmoji(temp.d.emoji)
}
break
case "GUILD_MEMBERS_CHUNK":
this.gotChunk(temp.d);
break;

View file

@ -509,7 +509,7 @@ class Message{
}
func();
}
makeReaction(data:{name:string},member:Member|{id:string}){
reactionAdd(data:{name:string},member:Member|{id:string}){
for(const thing of this.reactions){
if(thing.emoji.name===data.name){
thing.count++;
@ -527,7 +527,7 @@ class Message{
});
this.updateReactions();
}
removeReaction(data:{name:string},id:string){
reactionRemove(data:{name:string},id:string){
console.log("test");
for(const i in this.reactions){
const thing=this.reactions[i];
@ -547,6 +547,20 @@ class Message{
}
}
}
reactionRemoveAll() {
this.reactions = [];
this.updateReactions();
}
reactionRemoveEmoji(emoji:Emoji) {
for (const i in this.reactions) {
const reaction = this.reactions[i];
if ((reaction.emoji.id && reaction.emoji.id == emoji.id) || (!reaction.emoji.id && reaction.emoji.name == emoji.name)) {
this.reactions.splice(i, 1);
this.updateReactions();
break;
}
}
}
buildhtml(premessage:Message|undefined=undefined){
if(this.div){console.error(`HTML for ${this.snowflake} already exists, aborting`);return;}
try{