Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent preview message button from appearing on chat input commands #2843

Closed
wants to merge 2 commits into from

Conversation

NotPiny
Copy link

@NotPiny NotPiny commented Sep 4, 2024

Change the previewMessage plugin to hide the preview button on messages where the first word matches /^\/[-_\p{L}\p{N}]{1,32}$/gmu as the preview will simply be /ping option:option value which you can get by copying the command with ctrl + c

@@ -81,8 +81,9 @@ const PreviewButton: ChatBarButton = ({ isMainChat, isEmpty, type: { attachments

const hasAttachments = attachments && UploadStore.getUploads(channelId, DraftType.ChannelMessage).length > 0;
const hasContent = !isEmpty && draft?.length > 0;
const isCommand = draft?.split(" ")[0]?.match(/^\/[-_\p{L}\p{N}]{1,32}$/gmu) !== null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hacky. There is definitely a better way of checking if there is a command being typed. You'll likely find luck using DraftStore

@NotPiny NotPiny closed this Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants