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

Extend ++ command to award double points for good questions #176

Closed
4 tasks
twalton83 opened this issue Jul 7, 2021 · 16 comments
Closed
4 tasks

Extend ++ command to award double points for good questions #176

twalton83 opened this issue Jul 7, 2021 · 16 comments
Assignees

Comments

@twalton83
Copy link
Contributor

twalton83 commented Jul 7, 2021

Description

In an effort to improve the Discord community, the ability for maintainers and core members to award 2 points for good questions should be implemented.

Acceptance Criteria

  • Users with a maintainer or core role are able to use @user ?++ to award points
  • Using the new API query params, the above command should award the mentioned user two points
  • A message stating something like Double points for a great question! @user has XX points!
  • Tests
@timothyling1994
Copy link
Contributor

hey @twalton83, can I work on this?

@twalton83
Copy link
Contributor Author

If you can write the corresponding tests for this, absolutely.

@twalton83
Copy link
Contributor Author

@timothyling1994 Will you be taking this issue?

@timothyling1994
Copy link
Contributor

@twalton83 hey sorry for the delay. yes! i'll take this issue. I'll spend some time this weekend to work on it.

@twalton83
Copy link
Contributor Author

Please let us know if you have any questions about the testing or DiscordJS.

@timothyling1994
Copy link
Contributor

timothyling1994 commented Aug 2, 2021

@twalton83 I took a look at the codebase and had a couple of questions:

  1. In the config file, there's a points bot token (which is rightfully obscured in the .env file) that is required to send an authenticated request to the TOP points API endpoint (https://www.theodinproject.com/api/points?discord_id=${discordId}). Is there a test API endpoint that I could use for testing? Or did you want me to forgo testing the backend side of things and just mock the calls?

const config = { pointsbot: { token: process.env.POINTSBOT_TOKEN, }, noPointsChannels: ['513125912070455296'], };

POINTSBOT_TOKEN=xxxxx

  1. When updating the points for a user, we make a call to the API endpoint shown below. Is there an argument that the endpoint takes to increment points by a certain value? Or should I just call the endpoint twice to increment by 2?

const pointsBotResponse = await axios.post(https://www.theodinproject.com/api/points?discord_id=${discordId}`);`

@twalton83
Copy link
Contributor Author

In these units tests we are testing that the function itself works, not that the API is hit, so we should mock axios (see elsewhere in the test file for an example).

Refer to this issue for bullet 2- no need to hit the API twice now: #175

@twalton83
Copy link
Contributor Author

@timothyling1994 Do we have any update? :D

@timothyling1994
Copy link
Contributor

timothyling1994 commented Aug 26, 2021

@twalton83 the implementation is done but still working on getting the test cases set up. will try to finish it up this week

@timothyling1994
Copy link
Contributor

@twalton83
The implementation, test cases, and linting have been completed. There's one last thing before I'm ready to rebase on master.

I'm still unclear on how to POST the API endpoint to add 2 points to a specific user. The issue you linked above (#175) seems to be about filtering the leaderboard data when using GET on the endpoint. I'm unclear on what parameter I need to pass in the API call to add 2 points.

Let me know if I'm misinterrepting anything in that ticket. I can also hop on Discord if you wanted to chat further there.

@twalton83
Copy link
Contributor Author

@KevinMulhern do you mind clarifying or perhaps pointing this user to the POST route?

@KevinMulhern
Copy link
Member

KevinMulhern commented Sep 9, 2021

@twalton83 sorry for the delay.

The post route takes a value param for the points amount, for example:
https://www.theodinproject.com/api/points?discord_id=${discordId}&value=2

@twalton83
Copy link
Contributor Author

@timothyling1994 Did the above clear this up for you?

@timothyling1994
Copy link
Contributor

@twalton83 yes this cleared it up - I've made the appropriate changes. Currently reviewing merge differences between my local repo and the current upstream main branch. I should be able to submit my PR tomorrow. Apologies on the delay

@timothyling1994
Copy link
Contributor

@twalton83 Created the PR above. Let me know if you have any questions or comments!

@twalton83
Copy link
Contributor Author

Closed by #189

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

No branches or pull requests

3 participants