Skip to content

[feature] Automatically open threads for messages in specific channels #164

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

RogueArt
Copy link
Collaborator

Purpose of pull request

Related Issue: resolves #157

  • Automatically opens a new thread for career questions
  • Automatically opens a new thread for valid resume review submissions
    • Checks if a resume review submission has an image or PDF, otherwise deletes it

Pull request checklist

  • Branch and PR are named correctly
  • Updated relevant documentation
  • Tested with a tester bot
  • Wrote unit tests for changes

NOTE: Please do not merge this before merging into these two PRs

  1. Upgrade Discord.js to v13: [feature] Upgrade Discord.js to v13 #161
  2. Small PR to fix linting not working on Windows: [bug] Fix Windows linting errors #163

Screenshots

Career Questions:
career-questions

Resume Review:
resume-review

Testing instructions

  1. Run unit tests using yarn test
  2. Set up locally and designate two channels, one as a career question channel and one as a resume review channel to test manually

Copy link

@payne911 payne911 left a comment

Choose a reason for hiding this comment

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

I love the demo GIF! I like your style.

Comment on lines 21 to 33
// Verify a resume is attached to message
if (message.attachments.size === 0) {
author.send(defaultStrings.noResume);
message.delete();
return;
}

// Verify that all attachments are in valid format for a resume
if (!message.attachments.every((file) => attachmentIsAllowed(file))) {
author.send(defaultStrings.invalidFormat);
message.delete();
return;
}

Choose a reason for hiding this comment

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

The DM should include the text the user posted and which got deleted. This way, if they had written a massive wall-of-text, it's not lost.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great idea, I'll add that to the next revision

Copy link

@Zacheriah Zacheriah left a comment

Choose a reason for hiding this comment

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

Looks great! I added some feedback on some lines I thought you could expand your implementation.

// Run routine based on id
switch (message.channelId) {
// Career questions channel
case get('CAREER_QUESTIONS_CHANNEL_ID'):

Choose a reason for hiding this comment

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

Consider adding a case for when a person replies to another message at the top-level instead of in a thread. (as a reply instead of as a standalone message). Also consider returning the message they sent in the dm you send them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a really smart idea, will do both. Thanks!


// Verify that all attachments are in valid format for a resume
if (!message.attachments.every((file) => attachmentIsAllowed(file))) {
author.send(defaultStrings.invalidFormat);

Choose a reason for hiding this comment

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

Consider sending the author of the invalid message a copy of their message when you delete it so they can repost it easily with the correct format.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would save a lot of frustration. Will add that in the next revision, thanks for mentioning!

@RogueArt
Copy link
Collaborator Author

RogueArt commented Apr 21, 2022

Made a new revision with the following changes:

  • Replies to a top-level comment/thread will be auto-deleted
  • Deleted replies will have their message contents AND attachments sent to the user as a direct message
    • Added code to handle the edge case where the content length is >2000 characters

Here's a gif demonstrating the new features:
thread-create-rev-1

Copy link

@payne911 payne911 left a comment

Choose a reason for hiding this comment

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

Side-note: I would rename the PR

[feature] Automatically open threads for messages in specific channels

Comment on lines +7 to +9
CAREER_QUESTIONS_CHANNEL_ID=0987654321
RESUME_REVIEW_CHANNEL_ID=0987654321
SHARE_YOUR_CONTENT_CHANNEL_ID=0987654321

Choose a reason for hiding this comment

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

As discussed on Discord, I believe the auto-thread feature should also be applied to #share-your-content and #hiring

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a lot more specific. Renamed the PR to that.

Will add both channels to the code in the next revision.

Copy link
Member

Choose a reason for hiding this comment

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

Because it's fairly dynamic I think it would be better to have a database entry of like a 1 col table where you can add/remove channels by command. Never know if we plan to add or remove channels from this practice

@RogueArt RogueArt changed the title [feature] Automatically open threads on comments [feature] Automatically open threads for messages in specific channels Apr 22, 2022
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

yarn format && yarn lint

Choose a reason for hiding this comment

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

This is a breaking change, as previously yarn format failing would cause pre-commit to fail, and it does not anymore. Probably want set -x on verification scripts like this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good catch. I tested yarn format && yarn lint on Windows PowerShell just now and it seems to be working now while it wasn't earlier. I've added it #163, will need to drop the old commit from this pull request once #161 and #163 are merged.

@RogueArt
Copy link
Collaborator Author

Made a new revision adding support for hiring and share your question channels along with some unit tests. Verified that the current functionality for career questions and resume review still works:
image

Copy link

@payne911 payne911 left a comment

Choose a reason for hiding this comment

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

The yarn comment from @crabbycrabby is beyond me, so I can't speak for that.

But the rest looks good to me. (Although my revision is very much on the surface since I am mostly a Java dev.)

I'm submitting an Approval so that my previous "Request changes" doesn't block this PR.

@nikgil
Copy link
Member

nikgil commented Apr 24, 2022

Can you try pull and merge with development branch?

Copy link
Member

@nikgil nikgil left a comment

Choose a reason for hiding this comment

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

Overall fine imo. Just needs the mod bypass stuff. Also the dynamic suggestion is more something for a future diff if the time comes to it. Also I merged your last diff in so this may present conflicts weith dev branch.

Comment on lines +7 to +9
CAREER_QUESTIONS_CHANNEL_ID=0987654321
RESUME_REVIEW_CHANNEL_ID=0987654321
SHARE_YOUR_CONTENT_CHANNEL_ID=0987654321
Copy link
Member

Choose a reason for hiding this comment

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

Because it's fairly dynamic I think it would be better to have a database entry of like a 1 col table where you can add/remove channels by command. Never know if we plan to add or remove channels from this practice

Comment on lines +27 to +31
if (isMessageReply(message)) {
author.send(defaultStrings.invalidReply(channelName));
deleteAndReturnMessage(message);
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Need bypass for mods.

break;

// Resume review channel
case getChannelIdForName(CHANNEL_NAMES.RESUME_REVIEW):
Copy link
Member

Choose a reason for hiding this comment

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

I get the reasoning behind all this, but referring to my more dynamic suggestion I think this is a single breakaway case that can be dealt with like this,

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.

[feature] Auto thread creator
5 participants