-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from gustav-langer/main
Add `!remove <DAY_NUMBER>` command
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import shelve | ||
from logging import critical, debug, error, info, warning | ||
|
||
|
||
async def run_remove(ctx,arg): | ||
return remove_session(arg, ctx.author) | ||
|
||
def remove_session(day, author): | ||
if(day.isnumeric()): | ||
with shelve.open('hachikuji.mayoi') as db: | ||
day = int(day) - 1 | ||
if str(author) not in db: | ||
return "User not registered" | ||
a = db[str(author)] | ||
if a['start_times'][day] is None: | ||
return "No session started." | ||
else: | ||
a['start_times'][day] = None | ||
db[str(author)] = a | ||
return f"You ({db[str(author)]['username']}) removed your start time for day {int(day) + 1}!" | ||
else: | ||
warning(f"invalid day {day}, day must be an integer") | ||
return "Day must be an integer." |