msg reaction remove all & emoji gateway event
This commit is contained in:
parent
1de4767c6d
commit
b366381e53
2 changed files with 30 additions and 4 deletions
|
@ -374,7 +374,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":
|
||||
|
@ -382,9 +382,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;
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue