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

Discord bot !votefor command #24

Closed
ivov opened this issue Jul 15, 2020 · 1 comment
Closed

Discord bot !votefor command #24

ivov opened this issue Jul 15, 2020 · 1 comment
Assignees
Labels
Discord bot halfway-hackathon For issues/PRs/changes as part of the MLH Halfway Hackathon

Comments

@ivov
Copy link
Collaborator

ivov commented Jul 15, 2020

We have to add a !votefor command to the Discord bot, for the client-side functionality of our voting event.

Rules

  1. Each fellow has a single vote to cast. Once cast, their vote is final, i.e. no takebacks.
  2. Votes are weighted so a fellow's received votes are added to their own vote. For example, if a fellow has received five votes, their vote is worth six votes.
  3. Each fellow must cast their vote. If a fellow has not voted by the end of the voting period, they cannot be picked as a winner.
  4. Only fellows can vote and be voted for, that is, MLH staff, mentors, maintainers, sponsors are excluded. In fairness, we three should be excluded as well.
  5. Vote numbers remain secret until the results are announced. We give access to an MLH admin so they can monitor that vote numbers are legit.

Implementation

The Discord bot get a new command !votefor @Discord username and three possible answers.

// command

!votefor kendevops

// happy path

<bot> Your vote has been recorded. Thanks for voting!

// edge case 1

<bot> The records show you already voted!

// edge case 2

<bot> This person is not a fellow. Only fellows can receive votes! 

The DB gets two new columns votes_available (one or zero) and votes_received (zero and above) for each fellow.

When a fellow issues the command, the bot makes a GET request to the backend to check for votes available.

  • Happy path: If voter has a vote to cast, the bot makes a POST requests to update (1) the voter's votes_available to zero, and (2) the votee's votes_received to whatever votes the votee has plus the voter's votes_received + 1. The bot confirms successful vote to the voter.

  • Edge cases: If the voter has no vote to cast or if the votee is not in the fellows table or if the voter and the votee are the same, the bot reports why the vote cannot be cast.

When the contest ends, we look in the DB for three fellow with the highest number of votes, provided they have zero votes available.

@ivov ivov added halfway-hackathon For issues/PRs/changes as part of the MLH Halfway Hackathon Discord bot labels Jul 15, 2020
@ivov ivov self-assigned this Jul 15, 2020
@ivov
Copy link
Collaborator Author

ivov commented Jul 15, 2020

Solved, merged and closed!

@ivov ivov closed this as completed Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discord bot halfway-hackathon For issues/PRs/changes as part of the MLH Halfway Hackathon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant