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

Improved Discord notifications #1826

Merged
merged 19 commits into from
May 11, 2022

Conversation

JasirZaeem
Copy link
Member

Followup to #949

Use discord ids of connected users to add and improve notifications

  • On challenge submission

image

  • On lesson completion

image

image

  • On receiving a star

image

  • On a comment on user's submission

Sent dm
image

  • On acceptance/rejection of user's submission

Sent dm
image
image

The title of the direct message is the reviewer's or commenter's name on c0d3.
The message either mentions the c0d3 user or discord username/nickname if their discord id is available, this let's other's easily know them on discord. The mention can also be clicked on to dm users.
image

@vercel
Copy link

vercel bot commented May 3, 2022

@JasirZaeem is attempting to deploy a commit to a Personal Account owned by @garageScript on Vercel.

@garageScript first needs to authorize it.

Update mock data to attempt to fix unexpected rejection in describe("Add comment resolver", ...)
@codecov
Copy link

codecov bot commented May 3, 2022

Codecov Report

Merging #1826 (7f053dd) into master (6c25178) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1826   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          161       163    +2     
  Lines         2751      2793   +42     
  Branches       732       745   +13     
=========================================
+ Hits          2751      2793   +42     
Impacted Files Coverage Δ
graphql/resolvers/starsController.ts 100.00% <ø> (ø)
constants/index.ts 100.00% <100.00%> (ø)
graphql/resolvers/addComment.ts 100.00% <100.00%> (ø)
graphql/resolvers/submissionController.ts 100.00% <100.00%> (ø)
helpers/getDiscordMessageUserIdString.ts 100.00% <100.00%> (ø)
helpers/updateSubmission.ts 100.00% <100.00%> (ø)

constants/index.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,178 @@
/**
Copy link
Member

Choose a reason for hiding this comment

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

NIT: space between the test cases and variables would make the code a little bit easier to go through.

const { author, submission } = comment

if (author.id !== submission.user.id && submission.user.discordId) {
const notificationEmbed: MessageEmbedOptions = {
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to explicitly give it a type? TypeScript is capable of inferring its type and comparing the object's properties with sendDirectMessage first parameter type.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah ts will figure out if the type is sufficient when this object is passed to the function, but I have explicitly typed the object literal as MessageEmbedOptions to help with autocomplete and ides when reading/modifying the variable where it is declared.

@vercel
Copy link

vercel bot commented May 10, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
c0d3-app ✅ Ready (Inspect) Visit Preview May 11, 2022 at 4:54PM (UTC)

if (user.discordId && reviewer) {
const reviewerString = getDiscordMessageUserIdString(reviewer)
const reviewNotificationEmbed: MessageEmbedOptions = {
color: '#5440d8',
Copy link
Contributor

Choose a reason for hiding this comment

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

should this also be a constant?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, Done.

@JasirZaeem JasirZaeem merged commit a7fca00 into garageScript:master May 11, 2022
@JasirZaeem JasirZaeem deleted the discord-notifications branch July 10, 2022 17:27
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.

None yet

5 participants