Update MessageUtilities.plugin.js
This commit is contained in:
parent
414d8a4421
commit
65647ff657
|
@ -2,7 +2,7 @@
|
||||||
* @name MessageUtilities
|
* @name MessageUtilities
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.8.9
|
* @version 1.9.0
|
||||||
* @description Adds several Quick Actions for Messages (Delete, Edit, Pin, etc.)
|
* @description Adds several Quick Actions for Messages (Delete, Edit, Pin, etc.)
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -17,8 +17,13 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "MessageUtilities",
|
"name": "MessageUtilities",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "1.8.9",
|
"version": "1.9.0",
|
||||||
"description": "Adds several Quick Actions for Messages (Delete, Edit, Pin, etc.)"
|
"description": "Adds several Quick Actions for Messages (Delete, Edit, Pin, etc.)"
|
||||||
|
},
|
||||||
|
"changeLog": {
|
||||||
|
"fixed": {
|
||||||
|
"Reply": "Works again"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +94,7 @@ module.exports = (_ => {
|
||||||
"Edit_Message": {name: "Edit Message", func: this.doEdit, value: {click: 1, keycombo: []} },
|
"Edit_Message": {name: "Edit Message", func: this.doEdit, value: {click: 1, keycombo: []} },
|
||||||
"Delete_Message": {name: "Delete Message", func: this.doDelete, value: {click: 0, keycombo: [46]} },
|
"Delete_Message": {name: "Delete Message", func: this.doDelete, value: {click: 0, keycombo: [46]} },
|
||||||
"Pin/Unpin_Message": {name: "Pin/Unpin Message", func: this.doPinUnPin, value: {click: 0, keycombo: [17]} },
|
"Pin/Unpin_Message": {name: "Pin/Unpin Message", func: this.doPinUnPin, value: {click: 0, keycombo: [17]} },
|
||||||
"Reply_to_Message": {name: "Reply to Message", func: this.doReply, value: {click: 0, keycombo: [17,84]} },
|
"Reply_to_Message": {name: "Reply to Message", func: this.doReply, value: {click: 0, keycombo: [17,72]} },
|
||||||
"React_to_Message": {name: "Open React Menu", func: this.doOpenReact, value: {click: 0, keycombo: [17,83]} },
|
"React_to_Message": {name: "Open React Menu", func: this.doOpenReact, value: {click: 0, keycombo: [17,83]} },
|
||||||
"Copy_Raw": {name: "Copy raw Message", func: this.doCopyRaw, value: {click: 0, keycombo: [17,68]} },
|
"Copy_Raw": {name: "Copy raw Message", func: this.doCopyRaw, value: {click: 0, keycombo: [17,68]} },
|
||||||
"Copy_Link": {name: "Copy Message Link", func: this.doCopyLink, value: {click: 0, keycombo: [17,81]} },
|
"Copy_Link": {name: "Copy Message Link", func: this.doCopyLink, value: {click: 0, keycombo: [17,81]} },
|
||||||
|
@ -328,14 +333,14 @@ module.exports = (_ => {
|
||||||
BDFDB.ListenerUtils.stopEvent(event);
|
BDFDB.ListenerUtils.stopEvent(event);
|
||||||
BDFDB.TimeUtils.clear(clickTimeout);
|
BDFDB.TimeUtils.clear(clickTimeout);
|
||||||
if (!this.hasDoubleClickOverwrite(enabledBindings[priorityAction])) {
|
if (!this.hasDoubleClickOverwrite(enabledBindings[priorityAction])) {
|
||||||
this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction]);
|
BDFDB.TimeUtils.suppress(_ => this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction, event]), "", this)();
|
||||||
}
|
}
|
||||||
else clickTimeout = BDFDB.TimeUtils.timeout(_ => {
|
else clickTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||||
this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction]);
|
BDFDB.TimeUtils.suppress(_ => this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction, event]), "", this)();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(firedEvents, type, true)});
|
BDFDB.TimeUtils.timeout(_ => BDFDB.ArrayUtils.remove(firedEvents, type, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +371,7 @@ module.exports = (_ => {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
doDelete ({messageDiv, message}, action) {
|
doDelete ({messageDiv, message}, action, event) {
|
||||||
let deleteLink = messageDiv.parentElement.querySelector(BDFDB.dotCNS.messagelocalbotoperations + BDFDB.dotCN.anchor);
|
let deleteLink = messageDiv.parentElement.querySelector(BDFDB.dotCNS.messagelocalbotoperations + BDFDB.dotCN.anchor);
|
||||||
if (deleteLink) deleteLink.click();
|
if (deleteLink) deleteLink.click();
|
||||||
else if (BDFDB.DiscordConstants.MessageTypesDeletable[message.type]) {
|
else if (BDFDB.DiscordConstants.MessageTypesDeletable[message.type]) {
|
||||||
|
@ -378,14 +383,14 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doEdit ({messageDiv, message}, action) {
|
doEdit ({messageDiv, message}, action, event) {
|
||||||
if (message.author.id == BDFDB.UserUtils.me.id && !messageDiv.querySelector(BDFDB.dotCN.messagechanneltextarea)) {
|
if (message.author.id == BDFDB.UserUtils.me.id && !messageDiv.querySelector(BDFDB.dotCN.messagechanneltextarea)) {
|
||||||
BDFDB.LibraryModules.MessageUtils.startEditMessage(message.channel_id, message.id, message.content);
|
BDFDB.LibraryModules.MessageUtils.startEditMessage(message.channel_id, message.id, message.content);
|
||||||
if (toasts[action]) BDFDB.NotificationUtils.toast(this.formatToast(BDFDB.LanguageUtils.LanguageStrings.EDITING_MESSAGE), {type: "success"});
|
if (toasts[action]) BDFDB.NotificationUtils.toast(this.formatToast(BDFDB.LanguageUtils.LanguageStrings.EDITING_MESSAGE), {type: "success"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doOpenReact ({messageDiv, message}, action) {
|
doOpenReact ({messageDiv, message}, action, event) {
|
||||||
let reactButton = messageDiv.querySelector(`${BDFDB.dotCN.messagetoolbarbutton}[aria-label="${BDFDB.LanguageUtils.LanguageStrings.ADD_REACTION}"]`);
|
let reactButton = messageDiv.querySelector(`${BDFDB.dotCN.messagetoolbarbutton}[aria-label="${BDFDB.LanguageUtils.LanguageStrings.ADD_REACTION}"]`);
|
||||||
if (reactButton) {
|
if (reactButton) {
|
||||||
reactButton.click();
|
reactButton.click();
|
||||||
|
@ -393,7 +398,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doPinUnPin ({messageDiv, message}, action) {
|
doPinUnPin ({messageDiv, message}, action, event) {
|
||||||
if (message.state == BDFDB.DiscordConstants.MessageStates.SENT) {
|
if (message.state == BDFDB.DiscordConstants.MessageStates.SENT) {
|
||||||
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
||||||
if (channel && (BDFDB.DMUtils.isDMChannel(channel.id) || BDFDB.UserUtils.can("MANAGE_MESSAGES")) && (message.type == BDFDB.DiscordConstants.MessageTypes.DEFAULT || message.type == BDFDB.DiscordConstants.MessageTypes.REPLY)) {
|
if (channel && (BDFDB.DMUtils.isDMChannel(channel.id) || BDFDB.UserUtils.can("MANAGE_MESSAGES")) && (message.type == BDFDB.DiscordConstants.MessageTypes.DEFAULT || message.type == BDFDB.DiscordConstants.MessageTypes.REPLY)) {
|
||||||
|
@ -409,24 +414,24 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doReply ({messageDiv, message}, action) {
|
doReply ({messageDiv, message}, action, event) {
|
||||||
if (message.state == BDFDB.DiscordConstants.MessageStates.SENT) {
|
if (message.state == BDFDB.DiscordConstants.MessageStates.SENT) {
|
||||||
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
||||||
if (channel && (BDFDB.DMUtils.isDMChannel(channel.id) || BDFDB.UserUtils.can("SEND_MESSAGES")) && (message.type == BDFDB.DiscordConstants.MessageTypes.DEFAULT || message.type == BDFDB.DiscordConstants.MessageTypes.REPLY)) {
|
if (channel && (BDFDB.DMUtils.isDMChannel(channel.id) || BDFDB.UserUtils.can("SEND_MESSAGES")) && (message.type == BDFDB.DiscordConstants.MessageTypes.DEFAULT || message.type == BDFDB.DiscordConstants.MessageTypes.REPLY)) {
|
||||||
BDFDB.LibraryModules.MessageManageUtils.replyToMessage(channel, message);
|
BDFDB.LibraryModules.MessageManageUtils.replyToMessage(channel, message, event);
|
||||||
if (toasts[action]) BDFDB.NotificationUtils.toast(this.formatToast(BDFDB.LanguageUtils.LanguageStrings.NOTIFICATION_REPLY), {type: "success"});
|
if (toasts[action]) BDFDB.NotificationUtils.toast(this.formatToast(BDFDB.LanguageUtils.LanguageStrings.NOTIFICATION_REPLY), {type: "success"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doCopyRaw ({messageDiv, message}, action) {
|
doCopyRaw ({messageDiv, message}, action, event) {
|
||||||
if (message.content) {
|
if (message.content) {
|
||||||
BDFDB.LibraryRequires.electron.clipboard.write({text: message.content});
|
BDFDB.LibraryRequires.electron.clipboard.write({text: message.content});
|
||||||
if (toasts[action]) BDFDB.NotificationUtils.toast(this.formatToast(BDFDB.LanguageUtils.LanguageStrings.COPIED_TEXT), {type: "success"});
|
if (toasts[action]) BDFDB.NotificationUtils.toast(this.formatToast(BDFDB.LanguageUtils.LanguageStrings.COPIED_TEXT), {type: "success"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doCopyLink ({messageDiv, message}, action) {
|
doCopyLink ({messageDiv, message}, action, event) {
|
||||||
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
BDFDB.LibraryModules.MessageManageUtils.copyLink(channel, message);
|
BDFDB.LibraryModules.MessageManageUtils.copyLink(channel, message);
|
||||||
|
@ -434,28 +439,28 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doQuote ({messageDiv, message}, action) {
|
doQuote ({messageDiv, message}, action, event) {
|
||||||
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Quote_Message.plugin)) {
|
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Quote_Message.plugin)) {
|
||||||
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
||||||
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Quote_Message.plugin).quote(channel, message);
|
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Quote_Message.plugin).quote(channel, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doNote ({messageDiv, message}, action) {
|
doNote ({messageDiv, message}, action, event) {
|
||||||
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) {
|
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) {
|
||||||
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
||||||
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Note_Message.plugin).addMessageToNotes(message, channel);
|
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Note_Message.plugin).addMessageToNotes(message, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doTranslate ({messageDiv, message}, action) {
|
doTranslate ({messageDiv, message}, action, event) {
|
||||||
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) {
|
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) {
|
||||||
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
|
||||||
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Translate_Message.plugin).translateMessage(message, channel);
|
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Translate_Message.plugin).translateMessage(message, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doReveal ({messageDiv, message}, action) {
|
doReveal ({messageDiv, message}, action, event) {
|
||||||
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) {
|
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) {
|
||||||
BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Reveal_Spoilers.plugin).revealAllSpoilers(messageDiv);
|
BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Reveal_Spoilers.plugin).revealAllSpoilers(messageDiv);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue