aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
* Catch HTTPException in fetching, only fetch if isn't User or MemberGravatar Manuel Ignacio Pérez Alcolea2019-12-22-8/+12
| | | | | | | | | There's now a check to see if the `user` argument (possibly a `discord.Object`) needs to be made a `User`, instead of doing so directly, to avoid unnecessary requests to the Discord API. Besides that, a possible HTTPException is catched if it the fetch fails, cancelling the message to be send to the user (which would make the following calls fail later on for not being of the proper type.)
* Make `watchchannels` use `FetchedUser` instead of `proxy_user`Gravatar Manuel Ignacio Pérez Alcolea2019-12-22-31/+24
| | | | | | This changes also removes the original `proxy_user` used by `watchchannels` the attributes in its `discord.Object` object to the one returned by FetchedUser.
* Fix bug to log if `user` is either `Member` or `User`Gravatar Manuel Ignacio Pérez Alcolea2019-12-22-1/+1
|
* Move type declarations for annotations and convertersGravatar Manuel Ignacio Pérez Alcolea2019-12-22-4/+7
| | | | | | | It turns out how it was originally was the best idea. Now the `infractions` module imports `FetchedUser` and makes a `typing.Union` between it and `utils.UserTypes`. The usage of `FetchedUser` isn't needed in `utils` at all, and it shouldn't be used for/as type hinting there.
* Minor refactor moving `return ...`Gravatar Manuel Ignacio Pérez Alcolea2019-12-22-3/+1
|
* Merge branch 'fetched-user' of https://github.com/manusaurio/bot into ↵Gravatar Manuel Ignacio Pérez Alcolea2019-12-22-1/+1
|\ | | | | | | fetched-user
| * Add space in conditionGravatar manusaurio2019-12-22-1/+1
| | | | | | Co-Authored-By: Mark <[email protected]>
* | Add descriptive message to exception if user from API doesn't existGravatar Manuel Ignacio Pérez Alcolea2019-12-22-1/+1
|/
* Correct log messages levels, add log messages and ctx.send messageGravatar Manuel Ignacio Pérez Alcolea2019-12-22-7/+12
|
* Merge branch 'master' into fetched-userGravatar manusaurio2019-12-20-29/+26
|\
| * Merge pull request #703 from python-discord/user-sync-on-user-updateGravatar Sebastiaan Zeeff2019-12-20-29/+26
| |\ | | | | | | Properly sync users to the database when they update their information
| | * Use on_user_update to properly sync users with dbGravatar Sebastiaan Zeeff2019-12-17-29/+26
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's important to us that we keep the information we have about users in the database in sync with the actual user information the bot can observe in our guild. To do this, we relied on the `on_member_update` event listener to synchronize a user's information when an update of the information was detected. However, unfortunately, this does not work for user account information (i.e., the username, avatar, and discriminator of the user). The solution is to use the `on_user_update` event listener to watch for updates in the user settings and to use the `on_member_update` event listener to watch for updates in guild-related information for that user. (We currently only sync the roles the user has.) See: - https://discordpy.readthedocs.io/en/stable/api.html#discord.on_member_update - https://discordpy.readthedocs.io/en/stable/api.html#discord.on_user_update Note: The docs for `discord.py` make it *seem* like the `on_member_update` event does not fire for updates of theusername, discriminator, and avatar attributes. However, experimentation shows that this event *does* fire; it's just that the member objects provided as `before` and `after` to the listener will already have been updated in cache by the `on_user_update` event that fires *before* it. This means that if the only changes made were to the username, avatar, and discriminator, the `on_member_update` event does fire, but with two *equal* Member objects. This makes it appear as if you may be able to use `on_member_update`, since it fires, but it does not actually contain anything useful.
* | "Correct indentation style"Gravatar Manuel Ignacio Pérez Alcolea2019-12-20-2/+4
| |
* | Move `utils.proxy_user` to Converters and do minor refactoringGravatar Manuel Ignacio Pérez Alcolea2019-12-20-55/+29
| | | | | | | | | | | | | | | | | | The `proxy_user` function now belongs to the `Converters` module, since its use is directly related to it. `FetchedUser` uses this function if there's an error trying to fetch and it doesn't indicate a non existing user. Technically finished and working.
* | Make post_user take default values for payload from `getattr`Gravatar Manuel Ignacio Pérez Alcolea2019-12-20-20/+12
| |
* | Make `FetchedUser` return a `discord.Object` if user *may* existGravatar Manuel Ignacio Pérez Alcolea2019-12-20-7/+35
| | | | | | | | | | | | | | The FetchedUser Converter now counts with a `proxy_user` helper function (which SHOULD NOT be there) to return a user as a last resource, in case there was an issue fetching from the Discord API, as long as the error isn't that there's no user with the given ID.
* | Give `post_user` default values for `payload` if absent in `user`Gravatar Manuel Ignacio Pérez Alcolea2019-12-20-19/+26
| | | | | | | | | | | | | | Now `post_user(...)` expects either a `discord.User` or a `discord.Object` object as `user`. Either way, it will try to take the relevant attributes from `user` to fill the DB columns. If it can't be done, `.avatar_hash`, `.discriminator`, and `name` will take default values.
* | Refactor minor details in `post_infraction`Gravatar Manuel Ignacio Pérez Alcolea2019-12-20-5/+4
| |
* | Make post_infraction try to `post_user` if user doesn't existGravatar Manuel Ignacio Pérez Alcolea2019-12-16-20/+17
| | | | | | | | | | | | | | | | | | Try twice to apply the infraction. If the user is not in the database, try to add it, then try to apply the infraction again. This allows any moderation function that uses `FetchedUser` as a converter to apply the infraction even when the user is absent in the local database.
* | Add `post_user` function to POST a new user to the DBGravatar Manuel Ignacio Pérez Alcolea2019-12-16-0/+33
| | | | | | | | | | | | | | | | As it is now, this function is planned to be used a big-helper in `post_infraction`. Its interface is partially similar: it will return a "JSON" dictionary if everything went well, or `None` if it failed. If it fails, it will send a message to the channel and register the issue in the `log`.
* | Remove pointless comma after last argumentGravatar Manuel Ignacio Pérez Alcolea2019-12-16-1/+1
| |
* | Add FetchedUser to convert ids of absent users to `discord.User`Gravatar Manuel Ignacio Pérez Alcolea2019-12-16-0/+22
|/ | | | | | This `discord.ext.commands.Converter` fetches a user from the Discord API and returns a `discord.User` object. This should replace the `proxy_user` function from the moderation `utils`.
* Use OAuth to be Reddit API compliant (#696)Gravatar scragly2019-12-13-11/+88
|\ | | | | | | | | Use OAuth to be Reddit API compliant Co-authored-by: null <[email protected]>
| * Merge branch 'master' into revert-695-revert-510-reddit-api-oauthGravatar scragly2019-12-13-27/+233
| |\ | |/ |/|
* | Merge pull request #694 from python-discord/enh/mod/534/no-ping-dm-failGravatar Mark2019-12-12-3/+6
|\ \ | | | | | | Moderation: show emoji for DM failure instead of mentioning actor
| * \ Merge branch 'master' into enh/mod/534/no-ping-dm-failGravatar Mark2019-12-12-258/+604
| |\ \ | |/ / |/| |
* | | Merge pull request #692 from python-discord/enh/verification/688/allow-mods-cmdsGravatar Mark2019-12-12-5/+11
|\ \ \ | | | | | | | | Allow mods+ to use commands and delete bots' messages in checkpoint channel
| * \ \ Merge branch 'master' into enh/verification/688/allow-mods-cmdsGravatar Mark2019-12-12-253/+593
| |\ \ \ | |/ / / |/| | |
* | | | Clean command improvements (#691)Gravatar scragly2019-12-13-16/+46
|\ \ \ \ | | | | | | | | | | Clean command improvements
| * \ \ \ Merge branch 'master' into enhancement/690-clean-cmdGravatar scragly2019-12-13-46/+297
| |\ \ \ \ | |/ / / / |/| | | |
* | | | | Merge pull request #680 from ↵Gravatar scragly2019-12-13-3/+170
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | python-discord/Write-unit-tests-for-`bot/utils/time.py` Added `unittest` for `bot.utils.time`
| * | | | | Fixed a typo ( due to poor copy pasta and eyeballing skills )Gravatar Shirayuki Nekomata2019-12-13-1/+1
| | | | | |
| * | | | | Added tests for `until_expiration`Gravatar Shirayuki Nekomata2019-12-13-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to `format_infraction_with_duration` ( if not outright copying it ), added 3 tests for `until_expiration`: - None `expiry`. - Custom `max_units`. - Normal use cases.
| * | | | | Adding an optional argument for `until_expiration`, update typehints for ↵Gravatar Shirayuki Nekomata2019-12-13-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `format_infraction_with_duration` - `until_expiration` was being a pain to unittests without a `now` ( default to `datetime.utcnow()` ). Adding an optional argument for this will not only make writing tests easier, but also allow more control over the helper function should we need to calculate the remaining time between two dates in the past. - Changed typehint for `date_from` in `format_infraction_with_duration` to `Optional[datetime.datetime]` to better reflect what it is.
| * | | | | Merge branch 'master' into Write-unit-tests-for-`bot/utils/time.py`Gravatar scragly2019-12-12-1/+32
| |\ \ \ \ \
| * \ \ \ \ \ Merge branch 'master' into Write-unit-tests-for-`bot/utils/time.py`Gravatar scragly2019-12-12-240/+358
| |\ \ \ \ \ \
| * | | | | | | Removed `setUp()` from `TimeTests` since it is not being used for anything.Gravatar Shirayuki Nekomata2019-12-05-3/+0
| | | | | | | |
| * | | | | | | Moved all individual test cases into iterables and test with `self.subTest` ↵Gravatar Shirayuki Nekomata2019-12-05-14/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | context manager.
| * | | | | | | Added `self.subTest` for tests with multiple test cases & simplified single ↵Gravatar Shirayuki Nekomata2019-12-05-19/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test case tests.
| * | | | | | | Introduced test for `test_format_infraction`, refactored ↵Gravatar Shirayuki Nekomata2019-12-05-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `test_parse_rfc1123`, fixed typo.
| * | | | | | | Splitting test cases for `format_infraction_with_duration` into proper, ↵Gravatar Shirayuki Nekomata2019-12-05-7/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | independent tests.
| * | | | | | | Changed `assert` to `self.assertIs` for `test_wait_until`Gravatar Shirayuki Nekomata2019-12-05-1/+1
| | | | | | | |
| * | | | | | | Added missing docstring for `test_humanize_delta_raises_for_invalid_max_units`Gravatar Shirayuki Nekomata2019-12-05-0/+1
| | | | | | | |
| * | | | | | | Splitting test cases for `humanize_delta` into proper, independent tests.Gravatar Shirayuki Nekomata2019-12-05-7/+21
| | | | | | | |
| * | | | | | | Added `unittest` for `bot.utils.time`Gravatar Shirayuki Nekomata2019-12-04-0/+87
| | | | | | | |
| | | | * | | | Merge remote-tracking branch 'origin/master' into enhancement/690-clean-cmdGravatar MarkKoz2019-12-12-191/+250
| | | | |\ \ \ \
| | | | * | | | | Clean: reformat argumentsGravatar MarkKoz2019-12-11-8/+33
| | | | | | | | |
| | | | * | | | | Clean: allow amount argument to be skipped Gravatar Mark2019-12-11-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This make the channel specifiable without the amount. Co-Authored-By: scragly <[email protected]>
| | | | * | | | | Clean: support specifying a channel different than the context'sGravatar MarkKoz2019-12-11-13/+18
| | | | | | | | |
| | | | * | | | | Clean: un-hide from help and add purge aliasGravatar MarkKoz2019-12-11-1/+1
| | | | | | | | |