-
Notifications
You must be signed in to change notification settings - Fork 3
idk u said u wanted to look at it #47
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| repos: | ||
| - repo: https://github.com/ambv/black | ||
| rev: stable | ||
| rev: 21.5b0 | ||
| hooks: | ||
| - id: black | ||
| language_version: python3.8 | ||
| language_version: python3.9 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import datetime | ||
| import textwrap | ||
|
|
||
| from discord.utils import sleep_until | ||
| from discord.ext import commands | ||
| from datetime import datetime | ||
| from discord import Message | ||
|
|
||
| from internal.context import Context | ||
| from utilities.helpers import EmbedHelper, CustomTimeConverter, get_str_time_mapping | ||
| from internal.bot import Bot | ||
|
|
||
|
|
||
| class Reminders(commands.Cog): | ||
| def __init__(self, bot): | ||
| self.bot = bot | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please typehint bot to Magoji's bot class |
||
|
|
||
| async def send_reminder( | ||
| self, | ||
| ctx: Context, | ||
| msg: Message, | ||
| original_time: str, | ||
| time: datetime, | ||
| *, | ||
| content: str, | ||
| ): | ||
|
|
||
| description = textwrap.dedent( | ||
| f""" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrongly indented. |
||
| Your reminder from [{get_str_time_mapping(original_time)['amount']} {get_str_time_mapping(original_time)['unit']}]({msg.jump_url}) ago has arrived: | ||
| ``` | ||
| {content} | ||
| ``` | ||
| """ | ||
| ) | ||
|
|
||
| embed = EmbedHelper( | ||
| title="Your reminder has arrived", | ||
| description=description, | ||
| timestamp=datetime.utcnow(), | ||
| ) | ||
|
|
||
| await sleep_until(time) | ||
| return await ctx.reply(embed=embed) | ||
|
|
||
| @commands.command() | ||
| async def remind(self, ctx: Context, length: str, *, content: str): | ||
| time = await CustomTimeConverter.convert(self, ctx, length) + datetime.utcnow() | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is there a blank line here? Did you mean to put in a docstring?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. black™️ |
||
| description = textwrap.dedent( | ||
| f""" | ||
| Your reminder will arrive in {get_str_time_mapping(length)['amount']} {get_str_time_mapping(length)['unit']}(s) with the following content: | ||
| ``` | ||
| {content} | ||
| ``` | ||
| """ | ||
| ) | ||
|
Comment on lines
+51
to
+57
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is way too indented. |
||
|
|
||
| embed = EmbedHelper( | ||
| title="Reminder Created", | ||
| description=description, | ||
| timestamp=datetime.utcnow(), | ||
| ) | ||
|
|
||
| msg = await ctx.send(embed=embed) | ||
|
|
||
| await self.send_reminder(ctx, msg, length, time, content=content) | ||
|
|
||
|
|
||
| def setup(bot: Bot) -> None: | ||
| bot.add_cog(Reminders(bot)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |
| from aiohttp import ClientSession | ||
| from typing import Optional | ||
| from dotenv import load_dotenv | ||
| from os import getenv | ||
| from logging import getLogger, INFO | ||
| from traceback import format_exc | ||
|
|
||
|
|
@@ -55,6 +54,7 @@ async def login(self, *args, **kwargs) -> None: | |
| await super().login(*args, **kwargs) | ||
|
|
||
| async def get_prefix(self, message: Message) -> str: | ||
| ''' | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be commented out
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I didnt mean to commit it while that was commented, mb. |
||
| """Get a dynamic prefix for the bot.""" | ||
|
|
||
| if not message.guild: | ||
|
|
@@ -66,21 +66,12 @@ async def get_prefix(self, message: Message) -> str: | |
| return ">" | ||
|
|
||
| return guild_config[1] | ||
| ''' | ||
|
|
||
| return ">uwu< " | ||
|
|
||
| async def get_context(self, message: Message, *, cls=Context) -> Context: | ||
| """Get the custom `Context`.""" | ||
| return await super().get_context(message, cls=cls) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| bot = Bot() | ||
|
|
||
| bot.load_extension("jishaku") | ||
| bot.load_extensions( | ||
| "core.utility", | ||
| "core.config", | ||
| "utility.info", | ||
| "utility.tokens", | ||
| ) | ||
|
|
||
| bot.run(getenv("TOKEN")) | ||
|
Comment on lines
-75
to
-86
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this was removed. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A docstring for this class would be nice