Add Birthday Announcement Feature #29
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
JMTNTBANG/Bitey-Frank!29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "jmtntbang/birthdays"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Anyone who wants to look over my code feel free to, let me know ill add you as a reviewer
Looks like a good start, but could benefit from a bit of tidying up and refactoring
@ -114,6 +115,22 @@ async def goob_schedule_upd():await channel.send(schedule_message)Why
14and0? These particular values aren't clear - perhaps add a comment explaining why they are used? My best guess is that you only want to say "happy birthday" to users once per day, but if so, why is this function called so often (guessing every minute)?Use boolean operations to simplify your code and reduce indentation
Overall, this code is far too indented for my liking. It could be worthwhile setting up some CI (using something like
flake8to lint the code) to automatically detect these kinds of issues@ -117,0 +128,4 @@if b_day.year > 1:await channel.send(f'Merry {today.year - b_day.year}th Birthmas {user.mention}!')else:await channel.send(f'Merry Birthmas {user.mention}!')Add a docstring to ensure that the behaviour of the code is clear
@ -117,0 +129,4 @@await channel.send(f'Merry {today.year - b_day.year}th Birthmas {user.mention}!')else:await channel.send(f'Merry Birthmas {user.mention}!')Consider using the
aiofileslibrary to read this data asynchronouslyThis code seems unfinished - I'd expect something inside
on_ready@ -0,0 +1,61 @@import botUse a
withstatement to avoid the need to manuallyupdate.close()the file@ -114,6 +115,22 @@ async def goob_schedule_upd():await channel.send(schedule_message)You can get rid of three levels of nesting by using the
.date()method, combining conditions, and taking advantage of short circuit evaluation for the None check.Wait no the year should be discarded. In that case something like one of the two following would work.
Tuple comparison:
Just combining the month and day:
@ -0,0 +1,61 @@import botFrank deserves a capital F.
Here too.
Ditto.
And longer and get shouldn't be capitalized.
@ -114,6 +115,22 @@ async def goob_schedule_upd():await channel.send(schedule_message)Better still only calling it once a day like Miguel suggested would remove the hour and minute check altogether.
@ -114,6 +115,22 @@ async def goob_schedule_upd():await channel.send(schedule_message)Its called every minute because its being run along with 2 other functions (Aussie Clock and Goob Schedule) which also run every minute
@ -117,0 +129,4 @@await channel.send(f'Merry {today.year - b_day.year}th Birthmas {user.mention}!')else:await channel.send(f'Merry Birthmas {user.mention}!')that will probably something i add in later on as that would require learning a new library, and im just now learning the json one
@ -0,0 +1,61 @@import botyeah i tried that but had issues, but if that will work than thats what ill do
@ -114,6 +115,22 @@ async def goob_schedule_upd():await channel.send(schedule_message)yes the tuple comparison, that was something i was going for but forgot how to do it, thank you!
Forgot about that, ill have to remove that
I went through some of the changes and did commit some of them, others i will probably hold off until i have more information on how to actually do it
@ -114,6 +115,22 @@ async def goob_schedule_upd():await channel.send(schedule_message)In that case, why check the same thing for every user whose birthday is today - you could just check the time at the start of the function
@ -114,6 +115,22 @@ async def goob_schedule_upd():await channel.send(schedule_message)ohh i see, move it outside the for loop, that way it saves processing power if it didn't need to do it in the first place
@ -114,6 +115,22 @@ async def goob_schedule_upd():await channel.send(schedule_message)i mean its already being checked with the actual date and time so i might as well keep it there