Skip to content

Added user's score to Candy Command - Closes #947#978

Merged
HassanAbouelela merged 10 commits into
python-discord:mainfrom
evgriff:main
Dec 16, 2021
Merged

Added user's score to Candy Command - Closes #947#978
HassanAbouelela merged 10 commits into
python-discord:mainfrom
evgriff:main

Conversation

@evgriff
Copy link
Copy Markdown
Contributor

@evgriff evgriff commented Dec 10, 2021

Relevant Issues

Closes #947

Description

Added user's score to Candy command by adding one additional function/variable, and including verbose to the candy commands message. Invoker of candy command will now see their candy score.

Did you:

@evgriff evgriff requested a review from ks129 as a code owner December 10, 2021 19:26
Comment thread bot/exts/utilities/issues.py Outdated
async with self.bot.http_session.get(pulls_url) as p:
pull_data = await p.json()
if pull_data["draft"]:
if "draft" in pull_data and pull_data["draft"]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How about using pull_data.get("draft") instead?

Same review as 979

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hm, this commit shouldn't even be on this pr.

@evgriff this change is out of scope of this pr, so you'll need to remove it. you can do it with either resetting your HEAD and then forcepushing, or making a commit which will revert this commit.

Comment thread bot/exts/holidays/halloween/candy_collection.py
Comment on lines +191 to +195
def get_user_candy_score() -> str:
for user_id, score in records:
if user_id == user.id:
return f'<@{user.id}>: {score}'
return f'<@{user.id}>: 0'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use user.mention instead of manually writing the user mention and double quotes :)

async def candy(self, ctx: commands.Context) -> None:
"""Get the candy leaderboard and save to JSON."""
records = await self.candy_records.items()
user = await self.bot.fetch_user(ctx.author.id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't need to fetch the user here, we are using the user object to get the id/mention which can be done on ctx.author also, the two are the same objects.

@Xithrius Xithrius added area: backend Related to internal functionality and utilities category: holidays Related to holidays (Christmas, Halloween, Valentine's) status: needs review Author is waiting for someone to review and approve type: enhancement Changes or improvements to existing features labels Dec 15, 2021
@katimoth
Copy link
Copy Markdown
Contributor

@ks129 If this code is good, could you approve this PR? @evgriff and I are doing this as a school assignment due tonight and need to have proof of a successful merge.

@HassanAbouelela
Copy link
Copy Markdown
Contributor

@katimoth I agree with Shivnash's comments. Could you quickly make those changes?

@katimoth
Copy link
Copy Markdown
Contributor

@HassanAbouelela Committed the suggestions

Copy link
Copy Markdown
Contributor

@HassanAbouelela HassanAbouelela left a comment

Choose a reason for hiding this comment

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

Thanks for your work, and congrats on your first PR here 🎉

@katimoth
Copy link
Copy Markdown
Contributor

Thanks for your work, and congrats on your first PR here 🎉

Thank you !

Copy link
Copy Markdown
Contributor

@D0rs4n D0rs4n left a comment

Choose a reason for hiding this comment

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

Tested out locally, works as expected.
Congrats on you first PR 🎉

@HassanAbouelela HassanAbouelela merged commit ec6eb2e into python-discord:main Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backend Related to internal functionality and utilities category: holidays Related to holidays (Christmas, Halloween, Valentine's) status: needs review Author is waiting for someone to review and approve type: enhancement Changes or improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

View Your Score in Candy Command

8 participants