This commit is contained in:
Mirco Wittrien 2021-08-11 18:30:42 +02:00
parent 986169dfab
commit 46ffcea89c
2 changed files with 20 additions and 17 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB
* @author DevilBro
* @authorId 278543574059057154
* @version 1.7.14
* @version 1.7.15
* @description Required Library for DevilBro's Plugins
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -19,7 +19,7 @@ module.exports = (_ => {
"info": {
"name": "BDFDB",
"author": "DevilBro",
"version": "1.7.14",
"version": "1.7.15",
"description": "Required Library for DevilBro's Plugins"
},
"rawUrl": `https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js`
@ -3005,6 +3005,9 @@ module.exports = (_ => {
};
BDFDB.MessageUtils = {};
BDFDB.MessageUtils.isSystemMessage = function (message) {
return message && !BDFDB.DiscordConstants.USER_MESSAGE_TYPES.has(message.type) && (message.type !== BDFDB.DiscordConstants.MessageTypes.APPLICATION_COMMAND || message.interaction == null);
};
BDFDB.MessageUtils.rerenderAll = function (instant) {
BDFDB.TimeUtils.clear(BDFDB.MessageUtils.rerenderAll.timeout);
BDFDB.MessageUtils.rerenderAll.timeout = BDFDB.TimeUtils.timeout(_ => {
@ -8005,7 +8008,7 @@ module.exports = (_ => {
};
const ContextMenuTypes = ["UserSettingsCog", "UserProfileActions", "User", "Developer", "Slate", "GuildFolder", "GroupDM", "SystemMessage", "Message", "Native", "Role", "Guild", "Channel"];
const QueuedComponents = BDFDB.ArrayUtils.removeCopies([].concat(ContextMenuTypes.map(n => n + "ContextMenu"), ["GuildHeaderContextMenu", "MessageOptionContextMenu", "MessageOptionToolbar"]));
const QueuedComponents = BDFDB.ArrayUtils.removeCopies([].concat(ContextMenuTypes.map(n => n + "ContextMenu"), ["GuildHeaderContextMenu", "SystemMessageOptionContextMenu", "SystemMessageOptionToolbar", "MessageOptionContextMenu", "MessageOptionToolbar"]));
InternalBDFDB.addContextListeners = function (plugin) {
plugin = plugin == BDFDB && InternalBDFDB || plugin;
for (let type of QueuedComponents) if (typeof plugin[`on${type}`] == "function") {
@ -8061,17 +8064,17 @@ module.exports = (_ => {
}});
BDFDB.PatchUtils.patch(BDFDB, BDFDB.ObjectUtils.get(BDFDB.ModuleUtils.findByString("renderReactions", "canAddNewReactions", "showMoreUtilities", false), "exports.default"), "type", {after: e => {
if (document.querySelector(BDFDB.dotCN.emojipicker) || !BDFDB.ObjectUtils.toArray(PluginStores.loaded).filter(p => p.started).some(p => p.onMessageOptionContextMenu || p.onMessageOptionToolbar)) return;
if (document.querySelector(BDFDB.dotCN.emojipicker) || !BDFDB.ObjectUtils.toArray(PluginStores.loaded).filter(p => p.started).some(p => p.onSystemMessageOptionContextMenu || p.onSystemMessageOptionToolbar || p.onMessageOptionContextMenu || p.onMessageOptionToolbar)) return;
let toolbar = BDFDB.ReactUtils.findChild(e.returnValue, {filter: c => c && c.props && c.props.showMoreUtilities != undefined && c.props.showEmojiPicker != undefined && c.props.setPopout != undefined});
if (toolbar) BDFDB.PatchUtils.patch(BDFDB, toolbar, "type", {after: e2 => {
let menu = BDFDB.ReactUtils.findChild(e2.returnValue, {filter: c => c && c.props && typeof c.props.onRequestClose == "function" && c.props.onRequestClose.toString().indexOf("moreUtilities") > -1});
InternalBDFDB.executeExtraPatchedPatches("MessageOptionToolbar", {instance: {props: e2.methodArguments[0]}, returnvalue: e2.returnValue, methodname: "default"});
InternalBDFDB.executeExtraPatchedPatches(BDFDB.MessageUtils.isSystemMessage(e2.methodArguments[0] && e2.methodArguments[0].message) ? "SystemMessageOptionToolbar" : "MessageOptionToolbar", {instance: {props: e2.methodArguments[0]}, returnvalue: e2.returnValue, methodname: "default"});
if (menu && typeof menu.props.renderPopout == "function") {
let renderPopout = menu.props.renderPopout;
menu.props.renderPopout = BDFDB.TimeUtils.suppress((...args) => {
let renderedPopout = renderPopout(...args);
BDFDB.PatchUtils.patch(BDFDB, renderedPopout, "type", {after: e3 => {
InternalBDFDB.executeExtraPatchedPatches("MessageOptionContextMenu", {instance: {props: e3.methodArguments[0]}, returnvalue: e3.returnValue, methodname: "default"});
InternalBDFDB.executeExtraPatchedPatches(BDFDB.MessageUtils.isSystemMessage(e3.methodArguments[0] && e3.methodArguments[0].message) ? "SystemMessageOptionContextMenu" : "MessageOptionContextMenu", {instance: {props: e3.methodArguments[0]}, returnvalue: e3.returnValue, methodname: "default"});
}}, {noCache: true});
return renderedPopout;
});

View File

@ -2,7 +2,7 @@
* @name PersonalPins
* @author DevilBro
* @authorId 278543574059057154
* @version 2.0.5
* @version 2.0.6
* @description Allows you to locally pin Messages
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -17,12 +17,12 @@ module.exports = (_ => {
"info": {
"name": "PersonalPins",
"author": "DevilBro",
"version": "2.0.5",
"version": "2.0.6",
"description": "Allows you to locally pin Messages"
},
"changeLog": {
"fixed": {
"Canary Crash": ""
"Crash": "No longer tries to render System Messages in the Notes Popup"
}
}
};
@ -116,12 +116,12 @@ module.exports = (_ => {
notes[guild_id][channel_id][message_idPOS].channel = JSON.stringify(channel);
}
}
messages.push({
if (!BDFDB.MessageUtils.isSystemMessage(message)) messages.push({
note: notes[guild_id][channel_id][message_idPOS],
channel_id,
guild_id,
message,
channel,
channel_id: channel_id,
guild_id: guild_id,
message: message,
channel: channel,
messagetime: notes[guild_id][channel_id][message_idPOS].timestamp,
notetime: notes[guild_id][channel_id][message_idPOS].addedat
});
@ -131,10 +131,10 @@ module.exports = (_ => {
let currentChannel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId()) || {};
switch (popoutProps.selectedFilter.value) {
case "channel":
messages = messages.filter(messageData => messageData.channel_id == currentChannel.id);
messages = messages.filter(m => m.channel_id == currentChannel.id);
break;
case "server":
messages = messages.filter(messageData => messageData.guild_id == (currentChannel.guild_id || BDFDB.DiscordConstants.ME));
messages = messages.filter(m => m.guild_id == (currentChannel.guild_id || BDFDB.DiscordConstants.ME));
break;
case "allservers":
messages = messages;
@ -143,7 +143,7 @@ module.exports = (_ => {
let searchKey = popoutProps.searchKey.toUpperCase();
if (searchKey) {
let searchValues = ["content", "author.username", "rawDescription", "author.name"];
messages = messages.filter(messageData => searchValues.some(key => this.containsSearchkey(messageData.message, key, searchKey) || messageData.message.embeds.some(embed => this.containsSearchkey(embed, key, searchKey))));
messages = messages.filter(m => searchValues.some(key => this.containsSearchkey(m.message, key, searchKey) || m.message.embeds.some(embed => this.containsSearchkey(embed, key, searchKey))));
}
BDFDB.ArrayUtils.keySort(messages, popoutProps.selectedSort.value);
if (popoutProps.selectedOrder.value != "descending") messages.reverse();