61 Commits

Author SHA1 Message Date
jack1142
0f299ae195
Support all Messageables in bot.embed_requested() (#5576)
* Support all Messageables in bot.embed_requested

* Update usage in core

* Simplify [p]contact

This couldn't be done before this change.

I have also simplified getting embed color.

* Make `True` the new default for `check_permissions` kwarg
2022-03-21 10:22:55 -06:00
jack1142
0338e8e0a8
Avoid 'editing' message with no changes when case is created (#5577) 2022-02-20 16:42:56 -05:00
Dav
c6517d5087
[Core/Core Cogs] Prevent translation errors and use formatting utils (#5435)
* Use proper syntax for inline formatting in core_commands

* use proper formating utils in core and core cogs wherever reasonable

* tests are awesome

* ensure "(continued)" is translated in help.py

* add colons to translatable strings for easier context comprehension by translators

* Thx flame :)

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

* good point

Co-authored-by: Dav <dav@mail.stopdavabuse.de>
Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
2022-02-15 20:25:21 -05:00
Jan
7db3339aba
isolate direction of username within modlog (#5422)
* isolate direction of username within modlog

* Add link to Unicode's usage

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2021-12-25 17:34:02 +01:00
jack1142
fc560db72d
Stop fetching the messages when getting the cases in Modlog (#4977)
* Use PartialMessage when Case is fetched from Config

* Update docstring
2021-11-05 12:18:23 +01:00
Kowlin
89e3a78ead
Fix Case's modified_at attr and its format in message content (#5317)
* Fix modified_at field to properly format.

* let's just fix the type hints

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2021-09-14 02:42:20 +02:00
Kowlin
f05debc923
Initial support for Discord timestamping (#5155)
* Initial support for Discord timestamping

* Fix timezones

* Fix userinfo for users with member.joined_at equal to None

* Simplify

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2021-08-31 19:55:33 +00:00
jack1142
1c32186d0b
Fix logging and handle NotFound exception in Case.edit() (#4975) 2021-05-19 18:10:15 +02:00
jack1142
e2f0ac582b
Add documentation for Case class in Modlog
* Merge pull request #4979

* Add documentation for Case class in Modlog
2021-05-19 14:10:19 +01:00
jack1142
8139587e5e
Update d.py to 1.6.0, aiohttp to 3.7.3, Red-Lavalink to 0.7.2 (#4728)
* Bump d.py, aiohttp, Red-Lavalink

* Remove deprecation warnings that are no longer relevant

* Max concurrency things in `Command.prepare()`

* Two random things that date back to times older than d.py 1.1...
2021-02-01 14:49:50 +01:00
Flame442
a97cd64f48
[Modlog] Fix error when the bot can't read message history in the modlog channel (#4588) 2020-11-11 17:14:36 +01:00
TrustyJAID
085cd1bb49
Modlog account for very long case reasons (#4541)
* Modlog account for very long case reasons

* if
2020-10-27 02:12:06 +01:00
Kowlin
2413c6abd3
[Core] Guild scoped I18n (#3896)
* Guild I18n

Never again!

* Finish off guild scoped i18n

* Black formatting

* Added guild only flags.

* Fix missing import.

* Added listing of guild i18n settings

* Added API support

* Added API support... properly!

* Added API support... for realsies!

* Auto-translate create_cases instances

You're welcome cog creators! Jack talked me into this!

* Fix get_regional_format to actually return properly

* Cleanup `set showsettings`

* Style pass

* Update redbot/core/core_commands.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/core/events.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/core/core_commands.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* Fix missing import

* Improve caching

* Removal of unneeded function

* Fix some naming

* IDFK anymore...

* Reformat

* Update redbot/core/settings_caches.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/core/settings_caches.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/core/settings_caches.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* Remove line number

* Fix global sets

* Set contextual locale manually where needed

* Reports cog is wonderful...

* Update redbot/core/core_commands.py

Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>

* Set contextual locale manually where needed in Mutes cog

* s

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>
2020-10-26 17:59:11 +01:00
Dav
4e1ce7524b
[Modlog API] Handle deleted channels in Case.message_content() (#4415)
* Handle deleted channels in case.message_content()

* remove avatar_url + black
2020-09-19 19:39:59 +02:00
TrustyJAID
fec25fcaba
Accept discord.Objects for cases, add last_known_username param in create_case() (#4326)
* [Modlog] Fix typehints for create_case

* Simplify Logic after review

* discord.abc.User to catch both member and user objects and other potential discord.Object's being sent

* fix typehints and Case.edit()

* fix docstrings in create_case

* Add note about last_known_username

* fix the weird thing that scared me
2020-09-19 19:05:00 +02:00
jack1142
0200c2cb3f
Clarify documentation of modlog.create_case() (#4389) 2020-09-02 23:09:59 +02:00
DevilXD
6e63ed4e60
Use aware objects when storing and reading UTC timestamps (#4017)
* Use aware objects instead of naive ones

* Use aware objects when storing and reading UTC timestamps

* Remove unneeded parentheses

* Fixed naive and aware objects unable to be compared here

* Address feedback

* Fix the newly added `modlog.create_case()` calls

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-08-12 10:46:32 +02:00
Michael H
c0b1e50a5f
Begin work on a data request API (#4045)
[Core] Data Deletion And Disclosure APIs

 - Adds a Data Deletion API
   - Deletion comes in a few forms based on who is requesting
   - Deletion must be handled by 3rd party
 - Adds a Data Collection Disclosure Command
   - Provides a dynamically generated statement from 3rd party
   extensions
 - Modifies the always available commands to be cog compatible
   - Also prevents them from being unloaded accidentally
2020-08-03 15:09:07 +02:00
jack1142
f2d02a6f46
(again) Handle the ints for user objects in Modlog appropriately (#3805)
* Handle the ints for user objects in Modlog appropriately (#3784)

* God, this is stupid

* Add logging of unexpected exceptions

* Add more specific info for Forbidden error

* add i18n support
2020-05-29 00:09:37 +02:00
Kowlin
ef35fc0c5f
Revert "Handle the ints for user objects in Modlog appropriately (#3784)" (#3802)
This reverts commit e595f1859a017ded487390f71d897548656dde8e.
2020-04-28 02:03:22 +02:00
jack1142
e595f1859a
Handle the ints for user objects in Modlog appropriately (#3784) 2020-04-24 04:08:08 +02:00
Draper
e4018ec677
Normalize names of attributes with Config instances (#3765)
* Lets normalize how we name config attributes across the bot.

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* ....

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* nothing to see here

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
2020-04-20 19:12:57 +02:00
jack1142
ed267d17f2
[ModLog] Keep last known username in case's data (#3674) 2020-03-28 01:34:40 +01:00
Michael H
498d0d22fb
resolves #3443 (#3447) 2020-01-25 18:57:07 -05:00
Michael H
6219f0da67
[Modlog API] Add resolution for people inpacted by bad casetypes (#3333)
* add resolution for people inpacted by bad casetypes

* *some* amount of notice on this

* Fine.

* clearer warnings

* actually, unnneded
2020-01-17 18:51:49 -05:00
Michael H
ed692bcaa5 This shouldn't be possible normally, but we've have enough issues with it (#3318) 2020-01-09 19:20:34 -09:00
Michael H
a80e20067c
do better with loop cleanup (#3245)
* do better with loop cleanup

* changelog

* remove redundant line

* Do this a bit better than the initial pass

* Improve windows support

Make some other things coroutines to work with improved design

* Wish we'd have done this right from the start...

* Update deps surrounding this

 - see bpo-23057
 - neccessary for windows users
 - nice for consistent support channel info / feature availability

* dep issue

* Fix tests

* duplication plugin py version

* actually handle this

* Reconfigure some checks with codeclimate, disable pylint for now

* style

* Is my exasperation showing yet?

* handle some stupid stuff

* meh

* dep changelog
2020-01-01 19:26:32 -05:00
Michael H
a36e95c286
Remove a large amount of fetch_user calls (#3075)
* Non-audio changes

* address Flame's feedback
2019-12-21 01:15:34 -05:00
jack1142
8267ad9aab [Docs] Add missing descriptions for function returns (#3054)
* docs: add missing descriptions for function returns

* chore(changelog): add towncrier entry
2019-10-21 22:41:35 -04:00
Michael H
2c8152606c [Modlog] Reduce potential for bad API calls (#2945)
- brings a fix over from #2934
2019-08-28 08:45:56 +10:00
Toby Harradine
ef8b9b81c3 [ModLog] Optimise get_next_case_number() (#2908)
* [ModLog] Optimise get_next_case_number()

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Address reviews

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add changelog entry

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Delete get_next_case_number

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add modlog.get_latest_case() and fix `[p]reason`

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-08-02 10:49:22 -04:00
DiscordLiz
20091cc10a [ModLog API] Add default casetypes, remove need for a specific auditlog action (#2901)
* I know this needs a changelog entry and docs still

* update tests for new behavior

* update docs, filter; add changelog

* Ready for review

* stop fetching the same Audit logs when the bot is the mod

* I forgot to press save

* fix a comprehension

* Fix AttributeError

* And the other place that happens

* timing fixes
2019-07-27 15:37:29 -04:00
Toby Harradine
778eadd418
[ModLog] Fix get_case() and get_casetype() (#2877)
This fixes `[p]reason` and `[p]case` with cases that were created after 3.1.3.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-15 20:18:21 +10:00
Michael H
21a6384ebf [Modlog] Fix get_case for missing cases (#2858)
Due to the modlog redesign, the detection for a missing case changed. This fixes `get_case` for this.

This resolves #2844.
2019-07-14 10:47:16 +10:00
Toby Harradine
03e0683dd7 [ModLog] Actually prevent duplicate kwarg error
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-13 14:39:50 +10:00
Toby Harradine
e34eca557b [ModLog] Prevent duplicate kwarg error (#2848)
* [ModLog] Prevent duplicate kwarg error

The `name` key used to be set in the Config for casetypes.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Don't mutate `data` argument

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-12 20:17:00 -04:00
PredaaA
03fe3ee720 [i18n] Fix some missing i18n strings in the whole bot (#2633) 2019-06-30 01:13:53 +10:00
Toby Harradine
461f56bca1
Kill Pipfile, update dependencies, and add dep bumping tools (#2806)
### Replacement for pipenv's environment setup
First of all, there's a new Make recipe for all devs and contributors on both Windows and Posix, `make setupenv`, which is kind of a replacement for `pipenv install --dev`. It creates a virtual environment in `.venv` using the inbuilt `venv` module, clearing out any existing virtual environment if needed first. Then it installs all dev dependencies using our new `dev-requirements.txt` file. `CONTRIBUTING.md` has been updated to reflect all of this.

### Dependency version bumping tool
Secondly, I've added a python script, `tools/bumpdeps.py` to help with bumping dependency versions. It has its own Make recipe too, `make bumpdeps`. This script won't work on Windows (yet). It reads the `tools/primary_deps.ini` file, which contains the primary requirements of Red and its extras with loose version specifiers, and outputs all pinned dependencies, in `setup.cfg` format. It's not a foolproof dependency resolver, it's quite simple, but it's bound to help out a lot. It'll try to give warnings if there might be a version conflict, but updating `setup.cfg` with its output and then doing `pip install -r dev-requirements.txt` will allow pip to issue warnings if something is conflicting.

So to add a new dependency, add it to `tools/primary_deps.ini` in the appropriate place, and either use `make bumpdeps` to completely update all dependencies, or simply add it to `setup.cfg` manually with its sub-dependencies, and all versions pinned.

### Sphinx 2.1.2 (docs changes)
The sphinx update brought along the ability to disable type annotations being rendered in function and method signatures, and I have gladly gone and done that. Type annotations should already be specified under the "Parameters" section, and the way sphinx renders them in function signatures makes them much harder to read.

Also, documented classes will now display what classes they inherit from.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-06-28 00:16:14 +10:00
Toby Harradine
49819a2eeb
[ModLog] Fix get_all_casetypes() (#2807)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-06-26 20:39:22 +10:00
Toby Harradine
f91d8610ae
[ModLog] Use custom scopes for ModLog Config (#2766)
Modlog was the biggest culprit for seriously large documents in the MongoDB backend, since it stored all cases as nested dicts in the guild scope. So, for example, on the Fortnite server, the guild document for Kowlin's bot had exceeded 8MB. 

This commit gives each case its own document. It also does the same for casetypes. Not only does it remove the possibility of the document exceeding the maximum size in MongoDB, it's also just more efficient for all backends.

Other misc changes: Fixed a bunch of type-hints, and also added more support for when an object related to a case (user, moderator, channel etc.) can't be found (because it was deleted or something rather)

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-06-26 00:52:33 +10:00
jack1142
57d5c0870a style(modlog): Phrase information about reason command better (#2777) 2019-06-19 08:40:25 -04:00
Michael H
ad114295e7
Discord.py dep update 3.1 (#2587)
* Dependency update

discord.py==1.0.1
websockets<7

[style]
black==19.3b0

[Docs]
jinja==2.10.1
urllib3==1.24.2

Changes related to breaking changes from discord.py have also been made
to match

As of this commit, help formatter is back to discord.py's default
2019-04-23 21:40:38 -04:00
Will
fb722c79be
[V3 ModLog] Change register_casetypes behavior (#2551)
* Ignore runtime error in register_casetypes

* Fix documentation
2019-04-04 18:59:14 -04:00
DiscordLiz
619c3f28f7 fix case generation for cases which were not logged to modlog channel (#2477)
Add documentation for failure cases
Prevent an expected failure case.
2019-02-22 03:33:45 +01:00
DiscordLiz
9966668307 adds function to modlg API to get cases by member (#2453)
adds command using this to view all of a member's cases demonstrating this

closes #2266
2019-02-22 03:31:37 +01:00
Michael H
d13bf37845 [Utils] Add filters for spoiler markdown (#2401)
This also wraps some fields of the modlog with the same sanitization, as well as the `[p]names` command.
2019-02-16 11:34:38 +11:00
Toby Harradine
b1066ad58f
Guard module-level creation of Config objects (#2449)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-02-14 15:36:48 +11:00
Kowlin
38b15ded87 [Mod] Fixed loud RuntimeError on modlog cases (#2331) 2018-12-16 10:26:48 +11:00
Michael H
77944e195a Output sanitisation (#1942)
* Add output sanitization defaults to context.send
Add some common regex filters in redbot.core.utils.common_filters
Add a wrapper for ease of use in bot.send_filtered
Sanitize ModLog Case's user field (other's considered trusted as moderator input)
Sanitize Usernames/Nicks in userinfo command.
Santize Usernames in closing of tunnels.

* Add documentation
2018-08-24 23:50:38 +10:00
Michael H
8b15053dd4 [V3 Mod/Modlog] prevent self-casing the bot + feedback for heirarchy (#1777)
* prevent the bot from being a modlog target

* prevent heirarchy issues in mod

* modify this comparison to avoid more complex mocking of the guild object in mod test

* spelling
2018-06-08 20:27:07 -04:00