Update RemoveBlockedUsers.plugin.js
This commit is contained in:
parent
a859ef5b8d
commit
3036682a71
|
@ -2,7 +2,7 @@
|
||||||
* @name RemoveBlockedUsers
|
* @name RemoveBlockedUsers
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.5.6
|
* @version 1.5.7
|
||||||
* @description Removes blocked Messages/Users
|
* @description Removes blocked Messages/Users
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -305,47 +305,48 @@ module.exports = (_ => {
|
||||||
|
|
||||||
processReactions (e) {
|
processReactions (e) {
|
||||||
if (!this.settings.places.reactions) return;
|
if (!this.settings.places.reactions) return;
|
||||||
if (e.returnvalue && e.returnvalue.props.children && BDFDB.ArrayUtils.is(e.returnvalue.props.children[0])) {
|
if (!e.returnvalue || !e.returnvalue.props.children) return;
|
||||||
let updateTimeout, relationshipCount = BDFDB.LibraryStores.RelationshipStore.getRelationshipCount();
|
let emojiArrayIndex = e.returnvalue.props.children.findIndex(n => BDFDB.ArrayUtils.is(n) && n[0] && n[0].props && n[0].props.emoji);
|
||||||
if (cachedChannelId != e.instance.props.message.channel_id) {
|
if (emojiArrayIndex == -1) return;
|
||||||
cachedReactions = {};
|
let updateTimeout, relationshipCount = BDFDB.LibraryStores.RelationshipStore.getRelationshipCount();
|
||||||
cachedChannelId = e.instance.props.message.channel_id;
|
if (cachedChannelId != e.instance.props.message.channel_id) {
|
||||||
}
|
cachedReactions = {};
|
||||||
if (!cachedReactions[e.instance.props.message.id]) cachedReactions[e.instance.props.message.id] = {};
|
cachedChannelId = e.instance.props.message.channel_id;
|
||||||
for (let i in e.returnvalue.props.children[0]) {
|
|
||||||
let reaction = e.returnvalue.props.children[0][i];
|
|
||||||
let emojiId = reaction.props.emoji.name || reaction.props.emoji.id;
|
|
||||||
let oldCount = (reaction.props.message.reactions.find(n => n.emoji.name && n.emoji.name == emojiId || n.emoji.id == emojiId) || {}).count;
|
|
||||||
if (oldCount && oldCount < 10) {
|
|
||||||
if (cachedReactions[reaction.props.message.id][emojiId] && cachedReactions[reaction.props.message.id][emojiId].relationshipCount == relationshipCount && cachedReactions[reaction.props.message.id][emojiId].oldCount == oldCount) {
|
|
||||||
reaction.props.count = cachedReactions[reaction.props.message.id][emojiId].reactions.length;
|
|
||||||
if (reaction.props.count < 1) e.returnvalue.props.children[0][i] = null;
|
|
||||||
}
|
|
||||||
else BDFDB.LibraryModules.ReactionUtils.getReactions(reaction.props.message.channel_id, reaction.props.message.id, reaction.props.emoji).then(reactions => {
|
|
||||||
if (!reactions || !reactions.length) return;
|
|
||||||
let someBlocked = false;
|
|
||||||
let filteredReactions = reactions.filter(n => {
|
|
||||||
let isBlocked = n && BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id);
|
|
||||||
someBlocked = someBlocked || isBlocked;
|
|
||||||
return !isBlocked;
|
|
||||||
});
|
|
||||||
if (someBlocked) {
|
|
||||||
reaction.props.reactions = filteredReactions;
|
|
||||||
reaction.props.count = reaction.props.reactions.length;
|
|
||||||
BDFDB.TimeUtils.clear(updateTimeout);
|
|
||||||
updateTimeout = BDFDB.TimeUtils.timeout(_ => BDFDB.ReactUtils.forceUpdate(e.instance), 1000);
|
|
||||||
}
|
|
||||||
if (cachedReactions && cachedReactions[reaction.props.message.id]) cachedReactions[reaction.props.message.id][emojiId] = {
|
|
||||||
blocked: someBlocked,
|
|
||||||
relationshipCount: relationshipCount,
|
|
||||||
oldCount: oldCount || 0,
|
|
||||||
reactions: reaction.props.reactions || reactions
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!e.returnvalue.props.children[0].filter(n => n).length) return null;
|
|
||||||
}
|
}
|
||||||
|
if (!cachedReactions[e.instance.props.message.id]) cachedReactions[e.instance.props.message.id] = {};
|
||||||
|
for (let i in e.returnvalue.props.children[emojiArrayIndex]) {
|
||||||
|
let reaction = e.returnvalue.props.children[emojiArrayIndex][i];
|
||||||
|
let emojiId = reaction.props.emoji.name || reaction.props.emoji.id;
|
||||||
|
let oldCount = (reaction.props.message.reactions.find(n => n.emoji.name && n.emoji.name == emojiId || n.emoji.id == emojiId) || {}).count;
|
||||||
|
if (oldCount && oldCount < 10) {
|
||||||
|
if (cachedReactions[reaction.props.message.id][emojiId] && cachedReactions[reaction.props.message.id][emojiId].relationshipCount == relationshipCount && cachedReactions[reaction.props.message.id][emojiId].oldCount == oldCount) {
|
||||||
|
reaction.props.count = cachedReactions[reaction.props.message.id][emojiId].reactions.length;
|
||||||
|
if (reaction.props.count < 1) e.returnvalue.props.children[emojiArrayIndex][i] = null;
|
||||||
|
}
|
||||||
|
else BDFDB.LibraryModules.ReactionUtils.getReactions(reaction.props.message.channel_id, reaction.props.message.id, reaction.props.emoji).then(reactions => {
|
||||||
|
if (!reactions || !reactions.length) return;
|
||||||
|
let someBlocked = false;
|
||||||
|
let filteredReactions = reactions.filter(n => {
|
||||||
|
let isBlocked = n && BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id);
|
||||||
|
someBlocked = someBlocked || isBlocked;
|
||||||
|
return !isBlocked;
|
||||||
|
});
|
||||||
|
if (someBlocked) {
|
||||||
|
reaction.props.reactions = filteredReactions;
|
||||||
|
reaction.props.count = reaction.props.reactions.length;
|
||||||
|
BDFDB.TimeUtils.clear(updateTimeout);
|
||||||
|
updateTimeout = BDFDB.TimeUtils.timeout(_ => BDFDB.ReactUtils.forceUpdate(e.instance), 1000);
|
||||||
|
}
|
||||||
|
if (cachedReactions && cachedReactions[reaction.props.message.id]) cachedReactions[reaction.props.message.id][emojiId] = {
|
||||||
|
blocked: someBlocked,
|
||||||
|
relationshipCount: relationshipCount,
|
||||||
|
oldCount: oldCount || 0,
|
||||||
|
reactions: reaction.props.reactions || reactions
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!e.returnvalue.props.children[emojiArrayIndex].filter(n => n).length) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
processReactorsComponent (e) {
|
processReactorsComponent (e) {
|
||||||
|
|
Loading…
Reference in New Issue