diff --git a/plugins/antied/Settings.jsx b/plugins/antied/Settings.jsx index 669aca7..e5f9497 100644 --- a/plugins/antied/Settings.jsx +++ b/plugins/antied/Settings.jsx @@ -87,6 +87,12 @@ const togglePatch = [ label: "Toggle Message Update", subLabel: "Logs edited message", }, + { + id: "enableLogging", + default: false, + label: "Toggle Antied Logging", + subLabel: "Save Logs to plugin's storage", + }, { id: "logWarning", default: false, @@ -239,12 +245,11 @@ export default () => { return ( - - + } + label="Anti Edit & Delete Logs" + leading={} trailing={FormRow.Arrow} onPress={() => navigation.push("VendettaCustomPage", { @@ -507,4 +512,4 @@ export default () => { ) -} +} \ No newline at end of file diff --git a/plugins/antied/index.jsx b/plugins/antied/index.jsx index 7aa9657..0034366 100644 --- a/plugins/antied/index.jsx +++ b/plugins/antied/index.jsx @@ -28,8 +28,9 @@ const { FormRow, FormIcon } = Forms makeDefaults(storage, { switches: { customizeable: false, - enableMD: true, - enableMU: true, + enableMD: true, + enableMU: true, + enableLogging: false, useBackgroundColor: false, ignoreBots: false, minimalistic: true, @@ -64,10 +65,10 @@ let deletedMessageArray = {}; export default { onLoad: () => { - patches.push( - sillyPatch(), - fluxDispatchPatch(deletedMessageArray), - updateRowsPatch(deletedMessageArray), + patches.push( + sillyPatch(), + fluxDispatchPatch(deletedMessageArray), + updateRowsPatch(deletedMessageArray), selfEditPatch(), createMessageRecord(), messageRecordDefault(), @@ -157,7 +158,7 @@ export default { ActionSheet.hideActionSheet() if(storage?.inputs?.historyToast?.length > 0 || storage?.inputs?.historyToast != "") { - showToast(`[ANTI ED] ${storage?.inputs?.historyToast}`, getAssetIDByName("ic_edit_24px")) + showToast(`[ANTI ED] ${storage?.inputs?.historyToast}`, getAssetIDByName("ic_edit_24px")) } } }/> @@ -187,4 +188,4 @@ export default { } }, settings: Settings -} +} \ No newline at end of file diff --git a/plugins/antied/manifest.json b/plugins/antied/manifest.json index 2780c8a..777abde 100644 --- a/plugins/antied/manifest.json +++ b/plugins/antied/manifest.json @@ -1,5 +1,5 @@ { - "name": "Anti [Edit|Delete] v1.0.0", + "name": "Anti [Edit|Delete] v1.1.3", "description": "Keeps deleted messages and logs edited messages, until you restart/reloads the app", "authors": [ { diff --git a/plugins/antied/pages/log.jsx b/plugins/antied/pages/log.jsx index 7f6faa9..24f9905 100644 --- a/plugins/antied/pages/log.jsx +++ b/plugins/antied/pages/log.jsx @@ -161,129 +161,151 @@ export default () => { const snipLength = Number(storage?.inputs?.logLength || 60); - return (<> - - } - onPress={() => { - dialog.show({ - title: "Nuke logs", - body: "Nuke the Log?", - confirmText: "Yash", - cancelText: "nu uh", - confirmColor: "brand", - onConfirm: () => { - storage.log = []; - setLog([]) - showToast("[ANTIED] hmm yum, i ate all of it") - } - }) - }} - /> - - - { - (log.length < 1) ? - (<> - - - - ): - log.map((data) => { - const { type, author, content, edited, where } = data; - return (<> - + function MessageThing({ data }) { + const { type, author, content, edited, where } = data; + + return (<> + + Profiles.showUserProfile({ userId: author["id"] }) } + onPressIn={onPressIn} + onPressOut={onPressOut} + > + + + + + + + + + + { + `${author["username"]}` + } + + { + { + ((type == "MessageUpdate") ? + : + + ) + } + } Profiles.showUserProfile({ userId: author["id"] }) } - onPressIn={onPressIn} - onPressOut={onPressOut} - > - - { + if( + type == "MessageUpdate" && + data.where.guild && + data.where.channel && + data.where.messageLink + ) { + openURL(`https://discord.com/channels/${data.where.guild}/${data.where.channel}/${data.where.messageLink}`) + } + else { + showToast("Cannot find target Message") + } + }} + > + + - + - - - - - - { - `${author["username"]}` - } - - { - ((type == "MessageUpdate") ? - : - - ) - } - { - if(data.where.guild && data.where.channel && data.where.messageLink) { - openURL(`https://discord.com/channels/${data.where.guild}/${data.where.channel}/${data.where.messageLink}`) - } - else { - showToast("On Direct Message") - } - }} - > - - - - - - { - let clip = author.username; - - clip += ` (${author.id}):\n`; - clip =+ `>>> ${content}`; - if(edited) { - clip += `\n\n${edited}` - } - - - clipboard.setString(clip); - showToast("Log content copied") - }} - style={styles.text_container} - > - - { - (edited?.length > 0) ? (<> - - {shortenString(content, snipLength)} - - - {shortenString(edited, snipLength)} - - ) : - ( - {shortenString(content, snipLength)} - - ) - } - - - - ) - }) - } + + { + let clip = author.username; + clip += ` (${author.id}):\n`; + clip += `>>> ${content}`; + if(edited) { + clip += `\n\n${edited}` + } + + clipboard.setString(clip); + showToast("Log content copied") + }} + style={styles.text_container} + > + + { + (edited?.length > 0) ? (<> + + {shortenString(content, snipLength)} + + + {shortenString(edited, snipLength)} + + ) : + ( + + {shortenString(content, snipLength)} + + ) + } + + + + ) + } + + return (<> + + { + (!storage?.switches?.enableLogging) && (<> + + ) + } + { + (log?.length > 0) ? (<> + } + onPress={() => { + dialog.show({ + title: "Nuke logs", + body: "Nuke the Log?", + confirmText: "Yash", + cancelText: "nu uh", + confirmColor: "brand", + onConfirm: () => { + storage.log = []; + setLog([]) + showToast("[ANTIED] Logs cleared") + } + }) + }} + /> + ) : (<> + + ) + } + { + (log.length > 0) && (<> + + } + removeClippedSubviews={true} + /> + + ) + } ) -}; +}; \ No newline at end of file diff --git a/plugins/antied/patches/flux_dispatch.js b/plugins/antied/patches/flux_dispatch.js index b2e2df4..d3d1fcd 100644 --- a/plugins/antied/patches/flux_dispatch.js +++ b/plugins/antied/patches/flux_dispatch.js @@ -74,25 +74,27 @@ export default (deletedMessageArray) => before("dispatch", FluxDispatcher, (args stage: 1 } - storage.log.push({ - type: "MessageDelete", - author: { - id: originalMessage?.author?.id, - username: `${ - (originalMessage?.author?.discriminator == "0") ? - `@${originalMessage?.author?.username}` : - `${originalMessage?.author?.username}#${originalMessage?.author?.discriminator}` - }`, - avatar: originalMessage?.author?.avatar, - bot: originalMessage?.author?.bot - }, - content: originalMessage?.content, - where: { - channel: originalMessage?.channel_id || event?.channelId, - guild: ChannelStore?.getChannel(originalMessage?.channel_id)?.guild_id, - messageLink: originalMessage?.id - } - }) + if(storage?.switches?.enableLogging) { + storage.log.push({ + type: "MessageDelete", + author: { + id: originalMessage?.author?.id, + username: `${ + (originalMessage?.author?.discriminator == "0") ? + `@${originalMessage?.author?.username}` : + `${originalMessage?.author?.username}#${originalMessage?.author?.discriminator}` + }`, + avatar: originalMessage?.author?.avatar, + bot: originalMessage?.author?.bot + }, + content: originalMessage?.content, + where: { + channel: originalMessage?.channel_id || event?.channelId, + guild: ChannelStore?.getChannel(originalMessage?.channel_id)?.guild_id, + messageLink: originalMessage?.id + } + }) + } return args; } @@ -156,26 +158,28 @@ export default (deletedMessageArray) => before("dispatch", FluxDispatcher, (args }, }; - storage.log.push({ - type: "MessageUpdate", - author: { - id: event?.message?.author?.id, - username: `${ - (event?.message?.author?.discriminator == "0") ? - `@${event?.message?.author?.username}` : - `${event?.message?.author?.username}#${event?.message?.author?.discriminator}` - }`, - avatar: event?.message?.author?.avatar, - bot: event?.message?.author?.bot - }, - content: originalMessage?.content, - edited: event?.message?.content, - where: { - channel: event?.channelId || event?.message?.channel_id || originalMessage?.channel_id, - guild: ChannelStore?.getChannel(event?.channelId || event?.message?.channel_id || originalMessage?.channel_id)?.guild_id, - messageLink: event?.message?.id - } - }) + if(storage?.switches?.enableLogging) { + storage.log.push({ + type: "MessageUpdate", + author: { + id: event?.message?.author?.id, + username: `${ + (event?.message?.author?.discriminator == "0") ? + `@${event?.message?.author?.username}` : + `${event?.message?.author?.username}#${event?.message?.author?.discriminator}` + }`, + avatar: event?.message?.author?.avatar, + bot: event?.message?.author?.bot + }, + content: originalMessage?.content, + edited: event?.message?.content, + where: { + channel: event?.channelId || event?.message?.channel_id || originalMessage?.channel_id, + guild: ChannelStore?.getChannel(event?.channelId || event?.message?.channel_id || originalMessage?.channel_id)?.guild_id, + messageLink: event?.message?.id + } + }) + } return args; } diff --git a/plugins/antied/stoel/logAddon.jsx b/plugins/antied/stoel/logAddon.jsx index 7626131..d0e7984 100644 --- a/plugins/antied/stoel/logAddon.jsx +++ b/plugins/antied/stoel/logAddon.jsx @@ -14,7 +14,7 @@ export default () => { } + leading={} trailing={FormRow.Arrow} onPress={() => navigation.push("VendettaCustomPage", { diff --git a/plugins/antied/stoel/patch.tsx b/plugins/antied/stoel/patch.tsx index 42bf296..b80dc6c 100644 --- a/plugins/antied/stoel/patch.tsx +++ b/plugins/antied/stoel/patch.tsx @@ -1,5 +1,6 @@ import { plugin } from "@vendetta"; import { getAssetIDByName } from "@vendetta/ui/assets"; +import { storage } from "@vendetta/plugin"; import { patchSettingsPin } from "./pinToSetting"; @@ -16,11 +17,11 @@ export default (): (() => void) => { () => true, () => , { - key: plugin.manifest.name, + key: "antied_setting", icon: getAssetIDByName("ic_edit_24px"), - title: "Anti Edit & Delete", + title: "Anti Edit & Delete Settings", page: { - title: "Anti Edit & Delete", + title: "Anti Edit & Delete Settings", render: Settings, }, }, @@ -29,7 +30,7 @@ export default (): (() => void) => { () => true, () => , { - key: plugin.manifest.name, + key: "antied_logs", icon: getAssetIDByName("ic_message_delete"), title: "Anti Edit & Delete Logs", page: { @@ -38,7 +39,7 @@ export default (): (() => void) => { }, }, ) - ); + ) return () => patches.forEach((x) => x()); }; \ No newline at end of file diff --git a/plugins/antied/stoel/settingAddon.tsx b/plugins/antied/stoel/settingAddon.tsx index b645c03..2bee4c3 100644 --- a/plugins/antied/stoel/settingAddon.tsx +++ b/plugins/antied/stoel/settingAddon.tsx @@ -14,7 +14,7 @@ export default () => { return ( } trailing={FormRow.Arrow} onPress={() =>