Conversation
There was a problem hiding this comment.
Looks good. Worth considering though. View full project report here.
|
|
||
| info_json = Path(__file__).parent.resolve() / "info.json" | ||
| with open(info_json, encoding="utf-8") as f: | ||
| __plugin_info__ = json.loads(f.read()) |
There was a problem hiding this comment.
| __plugin_info__ = json.loads(f.read()) | |
| __plugin_info__ = json.load(f) |
This can be simplified by using json.load(...). More details.
| if args["nick"]: | ||
| matched_here = [] | ||
| for user in matched: | ||
| if any([user.nick and piece.lower() in user.nick.lower() for piece in args["nick"]]): |
There was a problem hiding this comment.
| if any([user.nick and piece.lower() in user.nick.lower() for piece in args["nick"]]): | |
| if any(user.nick and piece.lower() in user.nick.lower() for piece in args["nick"]): |
any can take a generator, so constructing a list first may be unnecessary. Read more.
| if args["name"]: | ||
| matched_here = [] | ||
| for user in matched: | ||
| if any([piece.lower() in user.display_name.lower() for piece in args["name"]]): |
There was a problem hiding this comment.
| if any([piece.lower() in user.display_name.lower() for piece in args["name"]]): | |
| if any(piece.lower() in user.display_name.lower() for piece in args["name"]): |
As above, Constructing a list first may be unnecessary.
| if args["not-nick"]: | ||
| matched_here = [] | ||
| for user in matched: | ||
| if not any([user.nick and piece.lower() in user.nick.lower() for piece in args["not-nick"]]): |
There was a problem hiding this comment.
| if not any([user.nick and piece.lower() in user.nick.lower() for piece in args["not-nick"]]): | |
| if not any(user.nick and piece.lower() in user.nick.lower() for piece in args["not-nick"]): |
As above, Constructing a list first may be unnecessary.
| if args["not-user"]: | ||
| matched_here = [] | ||
| for user in matched: | ||
| if not any([piece.lower() in user.name.lower() for piece in args["not-user"]]): |
There was a problem hiding this comment.
| if not any([piece.lower() in user.name.lower() for piece in args["not-user"]]): | |
| if not any(piece.lower() in user.name.lower() for piece in args["not-user"]): |
Again, Constructing a list first may be unnecessary.
| if args["not-discrim"]: | ||
| matched_here = [] | ||
| for user in matched: | ||
| if not any([disc == int(user.discriminator) for disc in args["not-discrim"]]): |
There was a problem hiding this comment.
| if not any([disc == int(user.discriminator) for disc in args["not-discrim"]]): | |
| if not any(disc == int(user.discriminator) for disc in args["not-discrim"]): |
Same as above: Constructing a list first may be unnecessary.
|
|
||
| info_json = Path(__file__).parent.resolve() / "info.json" | ||
| with open(info_json, encoding="utf-8") as f: | ||
| __plugin_info__ = json.loads(f.read()) |
There was a problem hiding this comment.
| __plugin_info__ = json.loads(f.read()) | |
| __plugin_info__ = json.load(f) |
This can be simplified by using json.load(...). Explained here.
|
|
||
| info_json = Path(__file__).parent.resolve() / "info.json" | ||
| with open(info_json, encoding="utf-8") as f: | ||
| __plugin_info__ = json.loads(f.read()) |
There was a problem hiding this comment.
| __plugin_info__ = json.loads(f.read()) | |
| __plugin_info__ = json.load(f) |
This can be simplified by using json.load(...). More details.
| try: | ||
| user = await self.bot.get_or_fetch_user(user_id) | ||
| except (discord.NotFound, Exception): | ||
| raise commands.BadArgument('"{}" not found. Invalid user ID.'.format(user_id)) |
There was a problem hiding this comment.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. More details.
| except Exception as exc: | ||
| err = f"{type(exc).__name__}: {str(exc)}" | ||
| raise commands.BadArgument( | ||
| "Error renaming {name}#{discrim}.\n```Haskell\n{error}\n```".format( |
There was a problem hiding this comment.
As above, Consider using f-string instead.
There was a problem hiding this comment.
Worth considering. View full project report here.
tagsDev/models.py
Outdated
| from discord.ext import commands | ||
|
|
||
|
|
||
| class SafeFormat(object): |
There was a problem hiding this comment.
| class SafeFormat(object): | |
| class SafeFormat: |
SafeFormat inherits from object by default, so explicitly inheriting from object is redundant. Removing it keeps the code simpler. Read more.
tagsDev/models.py
Outdated
| self.__dict = kw | ||
|
|
||
| def __getitem__(self, name): | ||
| return self.__dict.get(name, SafeString('{%s}' % name)) |
There was a problem hiding this comment.
| return self.__dict.get(name, SafeString('{%s}' % name)) | |
| return self.__dict.get(name, SafeString(f'{{{name}}}')) |
f-string is easier to read, write, and less computationally expensive than legacy string formatting. More.
tagsDev/models.py
Outdated
| try: | ||
| super().__getattr__(name) | ||
| except AttributeError: | ||
| return SafeString('%s.%s}' % (self[:-1], name)) |
There was a problem hiding this comment.
| return SafeString('%s.%s}' % (self[:-1], name)) | |
| return SafeString(f'{self[:-1]}.{name}}}') |
As above, Consider using f-string instead.
Co-Authored-By: p5nbTgip0r <32445075+p5nbtgip0r@users.noreply.github.com>
remove rainbow circle and add support for animated pfps
feat(tags): slash command
No description provided.