Update RemoveBlockedUsers.plugin.js
This commit is contained in:
parent
a859ef5b8d
commit
3036682a71
|
@ -2,7 +2,7 @@
|
|||
* @name RemoveBlockedUsers
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.5.6
|
||||
* @version 1.5.7
|
||||
* @description Removes blocked Messages/Users
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -305,47 +305,48 @@ module.exports = (_ => {
|
|||
|
||||
processReactions (e) {
|
||||
if (!this.settings.places.reactions) return;
|
||||
if (e.returnvalue && e.returnvalue.props.children && BDFDB.ArrayUtils.is(e.returnvalue.props.children[0])) {
|
||||
let updateTimeout, relationshipCount = BDFDB.LibraryStores.RelationshipStore.getRelationshipCount();
|
||||
if (cachedChannelId != e.instance.props.message.channel_id) {
|
||||
cachedReactions = {};
|
||||
cachedChannelId = e.instance.props.message.channel_id;
|
||||
}
|
||||
if (!cachedReactions[e.instance.props.message.id]) cachedReactions[e.instance.props.message.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 (!e.returnvalue || !e.returnvalue.props.children) return;
|
||||
let emojiArrayIndex = e.returnvalue.props.children.findIndex(n => BDFDB.ArrayUtils.is(n) && n[0] && n[0].props && n[0].props.emoji);
|
||||
if (emojiArrayIndex == -1) return;
|
||||
let updateTimeout, relationshipCount = BDFDB.LibraryStores.RelationshipStore.getRelationshipCount();
|
||||
if (cachedChannelId != e.instance.props.message.channel_id) {
|
||||
cachedReactions = {};
|
||||
cachedChannelId = e.instance.props.message.channel_id;
|
||||
}
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue