45 Commits

Author SHA1 Message Date
Kreusada
b630e71d08
[Docs] Warnings Cog Guide (#4920)
* Initial commit

* labeler and index

* change parameter names and labeler

* fix typo

* docstrings, quotes and improved names

* merge conflict affect fixes

* remove aliases

* get from v3/develop

* update var names

* fixes

* improve grammar

* black
2021-05-28 19:06:52 +02:00
Danstr5544
56099d6b50
Attempt to DM users before applying a warn action.
* Merge pull request #5004
2021-05-19 13:06:51 +01:00
OofChair
a919610588
Use embed_color for embeds in Warnings cog (#4878)
* add  color 

* add color on line 315, fix line 340

* Black style

* fix color on line 341

* thanks jojo >_>

* dont need i18n here

* Black style again :D
2021-04-03 02:30:26 +02:00
Obi-Wan3
c168e55be9
[Warnings] fix raw namedtuple output (#4904) 2021-04-02 23:09:18 +02:00
Dav
980b5fa1c2
[Warnings] Improve consistency in [p]warningset's commands (#4409)
* Be consistent with bool setters in warnings cog

* black
2020-09-20 00:16:42 +02:00
Kingsley Zhong
ea7e142494
Add hierarchy checks to [p]warn (#4100)
* Update warnings.py

* Cleanup the code and pass style check.

Co-authored-by: Kowlin <boxedpp@gmail.com>
2020-09-03 16:23:03 +02:00
jack1142
85afe19455
Bump black to 20.8b1 (and reformat) (#4371)
* Bump black version

* Reformat with black
2020-08-29 19:12:28 +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
jack1142
9798538438
Remove provisional note from NoParseOptional, fix and start using UserInputOptional (#4142) 2020-08-10 20:20:02 +01:00
jack1142
01a6ef3a8f
Add variation selector-16 as appropriate to emojis across Red (#4127) 2020-08-10 03:05:57 +02:00
jack1142
6cef336417
Remove unused try except blocks in modlog.create_case() usage (#4095) 2020-08-05 19:40:52 +01: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
500f91f0cd
Fix no message when unregistered reason is used in [p]warn (#3840) 2020-07-14 10:43:51 +01:00
Dav
dbcb179523
Allow to hide moderator from warnings sent to the users + warn channel fix (#3781)
* add toggle to allow switching off sending the name of the person who uhhh used? the warning

* the Kowlin way of life

* reduced config calls to stay in line with #3766 and hopefully didn't break anything (as per Draper suggestion)

* more performance magic

* found an error + black

* forgot warning channel existed

* await... seriously... how long have you done async stuff now dav?

* unify (most) config calls in ``[p]warn``

* fix all the things
2020-06-01 02:58:36 +02:00
Sean
38a034e59b
Don't allow to warn other bots (#3855) 2020-05-17 17:03:51 +02:00
jack1142
d9db03bca3
Tell the command caller when bot was unable to send warn (#3653) 2020-03-19 08:23:07 +01:00
Ianardo DiCaprio
2e5dc82692
[Warnings] Add setting for warn channel and DMing warns toggle (#2929)
* Initial Commit

* Add changelog

* Review changes

* Changed to use contextlib.suppress

* Update warnings.py

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Rename 2932.bugfix.rst.txt to 2932.bugfix.rst

* Rename 2929.enhance.rst.txt to 2929.enhance.rst

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: Draper <27962761+Drapersniper@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: Draper <27962761+Drapersniper@users.noreply.github.com>

* Update redbot/cogs/warnings/warnings.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

* Rename 2929.enhance.rst to 2929.feature.rst

* Update warnings.py

* Add files via upload

* Update warnings.py

* Black

* Update warnings.py

* black

* Update warnings.py

* Update warnings.py

* Delete 2932.bugfix.rst

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>
2020-03-12 21:17:59 +01:00
jack1142
eedec4ff02
fix: use clean prefix in code blocks (#3591) 2020-02-28 21:23:13 +01:00
Dav
d7b73eb50f
[Warnings] Fix inconsistency for warnreason (#3561) 2020-02-17 16:55:28 +01:00
Dav
e7969992c3
[Warnings]Make it possible to add reason with unwarn (#3490)
* Unwarn now able to have a reason

* black

* Update string to say Run instead of Do

Co-Authored-By: Draper <27962761+Drapersniper@users.noreply.github.com>

* Make error for unregistered reason less agressive

Co-Authored-By: Draper <27962761+Drapersniper@users.noreply.github.com>

* Removing unneccessary lines and not putting the user input through the translator.

* Because black hates me, here black formatting with adjusted line length

* Trigger CI

* Now always sendes a message when an invalid reason is passed, not only if the command author was an admin, guild owner or bot owner.

* That should do the trick

* Correct

* Make Reason optional

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-02-14 09:13:44 -05:00
Dav
90c0f76ae4 [Warnings] Make [p]warnings usable on base of permissions (#3327)
* new code

Added the admin check to warnings and removed the part where the user could check themselves.

Added new mywarns which replaces part of the old behaviour of warn

* Update warnings.py

* Create 2900.enhance.rst

* Fixed command name

Because appearently I can't remember a command for 10 seconds

* Commands in backticks

Put command names in changelog in double backticks after being advised to do so in discord

* made user not optional, and the other thing sinbad requested

* switched parts. magic

resolves #2900
2020-01-13 17:57:39 -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
Toby Harradine
d1a46acc9a PostgreSQL driver, tests against DB backends, and general drivers cleanup (#2723)
* PostgreSQL driver and general drivers cleanup

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

* Make tests pass

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

* Add black --target-version flag in make.bat

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

* Rewrite postgres driver

Most of the logic is now in PL/pgSQL.

This completely avoids the use of Python f-strings to format identifiers into queries. Although an SQL-injection attack would have been impossible anyway (only the owner would have ever had the ability to do that), using PostgreSQL's format() is more reliable for unusual identifiers. Performance-wise, I'm not sure whether this is an improvement, but I highly doubt that it's worse.

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

* Reformat

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

* Fix PostgresDriver.delete_all_data()

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

* Clean up PL/pgSQL code

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

* More PL/pgSQL cleanup

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

* PL/pgSQL function optimisations

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

* Ensure compatibility with PostgreSQL 10 and below

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

* More/better docstrings for PG functions

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

* Fix typo in docstring

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

* Return correct value on toggle()

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

* Use composite type for PG function parameters

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

* Fix JSON driver's Config.clear_all()

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

* Correct description for Mongo tox recipe

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

* Fix linting errors

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

* Update dep specification after merging bumpdeps

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

* Add towncrier entries

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

* Update from merge

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

* Mention [postgres] extra in install docs

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

* Support more connection options and use better defaults

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

* Actually pass PG env vars in tox

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

* Replace event trigger with manual DELETE queries

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-08-26 22:02:26 -04:00
Neuro Assassin
2e271d695b Add respectable aliases for consistency (#2731)
* Add respectable aliases for consistency

* General command name for alias.py

* Forgot one for alias

* General command for filter

* General command for warnings

* Whoops

Resolves #1749
2019-05-24 18:22:17 -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
TrustyJAID
691d8af26d [V3 Warnings] Utilize modlog cases (#2471)
* [V3 Warnings] Utilize modlog cases

This update utilizes modlog cases for warnings and slightly improves usage of custom warnings if enabled.

* remove BadArgument error response

* Utilize Optional and consume-rest for points and reason

* black format

* Remove unnecessary imports, cleanup error handling, and improve docstrings
2019-04-22 19:34:36 -04:00
Michael H
01ebf2835b Improve usability of warnings/unwarn\n resolves #2403 (#2404) 2019-02-03 02:37:01 -09:00
Toby Harradine
094735566d
[Warnings] Fix actions not being taken (#2218)
When multiple warning actions were registered, and the user didn't exceed the points for the highest action on the list, no action was taken.

Resolves #2106.

Also commented out the casetype registration for warnings, since it's not actually using modlog yet.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-11 11:54:11 +11:00
Toby Harradine
443f2ca556 [i18n] Pass over modlog, permissions, reports, streams, trivia, warnings
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-06 09:01:04 +10:00
Toby Harradine
dea9dde637
[Utils] Finish and Refactor Predicate Utility (#2169)
* Uses classmethods to create predicates
* Classmethods allow using a combination of different parameters to describe context
* Some predicates assign a captured `result` to the predicate object on success
* Added `ReactionPredicate` equivalent to `MessagePredicate`
* Added `utils.menus.start_adding_reactions`, a non-blocking method for adding reactions asynchronously
* Added documentation
* Uses these new utils throughout the core bot
Happened to also find some bugs in places, and places where we were waiting for events without catching `asyncio.TimeoutError`

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-06 08:07:09 +10:00
Toby Harradine
0870403299
Permissions redesign (#2149)
API changes:
- Cogs must now inherit from `commands.Cog` (see #2151 for discussion and more details)
- All functions which are not decorators in the `redbot.core.checks` module are now deprecated in favour of their counterparts in `redbot.core.utils.mod`. This is to make this module more consistent and end the confusing naming convention.
- `redbot.core.checks.check_overrides` function is now gone, overrideable checks can now be created with the `@commands.permissions_check` decorator
- Command, Group, Cog and Context have some new attributes and methods, but they are for internal use so shouldn't concern cog creators (unless they're making a permissions cog!).
- `__permissions_check_before` and `__permissions_check_after` have been replaced:  A cog method named `__permissions_hook` will be evaluated as permissions hooks in the same way `__permissions_check_before` previously was. Permissions hooks can also be added/removed/verified through the new `*_permissions_hook()` methods on the bot object, and they will be verified even when permissions is unloaded.
- New utility method `redbot.core.utils.chat_formatting.humanize_list`
- New dependency [`schema`](https://github.com/keleshev/schema)

User-facing changes:
- When a `@bot_has_permissions` check fails, the bot will respond saying what permissions were actually missing.
- All YAML-related `[p]permissions` subcommands now reside under the `[p]permissions acl` sub-group (tbh I still think the whole cog has too many top-level commands)
- The YAML schema for these commands has been changed
- A rule cannot be set as allow and deny at the same time (previously this would just default to allow)

Documentation:
- New documentation for `redbot.core.commands.requires` and `redbot.core.checks` modules
- Renewed documentation for the permissions cog
- `sphinx.ext.doctest` is now enabled

Note: standard discord.py checks will still behave exactly the same way, in fact they are checked before `Requires` is looked at, so they are not overrideable. 

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-10-01 13:19:25 +10:00
zephyrkul
2784730f7f [V3] Utilize shorten_by (#2131)
* utilize shorten_by

otherwise you get errors

* trivia shorten_by

* warnings shorten_by

max username length is 32 characters

* black formatting
2018-09-15 01:48:31 +02:00
Toby Harradine
c0c5535005
[Warnings] Help users understand custom reasons (#2049)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2018-09-03 14:57:14 +10:00
palmtree5
77566a887a [V3 Warnings] changes to the warnings cog (#1867)
* [V3 Warnings] clarify text on entering commands

* Fix up action commands and allow for no command on both add and remove

* Notify warned user when they receive a warning + disallow warning and unwarning self

* Add myself to COOWNERS for the warnings cog
2018-07-12 03:29:22 +02:00
Michael H
1c2196f78f autohelp changes. (#1836) 2018-07-12 01:23:18 +02:00
Michael H
17c7dd658d [V3 Core] Command group automatic help (#1790)
* decorator inheritence

* black format

* add autohelp

* modify commands to use autohelp
2018-06-08 20:54:36 -04:00
Eslyium
60a72b2ba4 [V3] Cleanup quotes in cogs (#1782)
* Cleanup quotes in cogs

* More quote cleanup that I missed

fixed a little bit of grammar here and there as well.

* [V3 Warnings] Change allowcustomreasons docstring

To help not confuse users who would believe that the command would use allow or disallow.

* Run black reformat
2018-06-07 00:42:59 -04:00
Redjumpman
1fd5dffdc7 [V3/Misc] Spelling, Grammar, and doc string fixes. (#1747)
* Update streams.py

* Update filter.py

* Update permissions.py

* Update customcom.py

* Update image.py

* Update trivia.py

* Update warnings.py
2018-06-01 19:20:12 +10:00
Tobotimus
f4b640126b [V3 Warnings] Fix warn command when no valid reason is passed (#1672)
Resolves #1670
2018-05-27 12:15:56 -08:00
Michael H
d3f406a34a [V3 Travis] Update travis to not skip pipfile lock... (#1678)
* Update travis to not sip pipfile lock

update pipfile dependencies

additional black formatting pass to conform to black 18.5b

* .

* pin async timeout until further discussion of 3.5 support

* .
2018-05-18 17:48:22 -08:00
Michael H
b88b5a2601 [V3] Update code standards (black code format pass) (#1650)
* ran black: code formatter against `redbot/` with `-l 99`

* badge
2018-05-14 15:33:24 -04:00
Tobotimus
15ea5440a3 [V3 i18n] Internationalise help for commands and cogs (#1143)
* Framework for internationalised command help

* Translator for class docstring of cog

* Remove references to old context module

* Use CogManagerUI as PoC

* Replace all references to RedContext

* Rename CogI18n object to avoid confusion

* Update docs

* Update i18n docs.

* Store translators in list instead of dict

* Change commands module to package, updated refs in cogs

* Updated docs and more references in cogs

* Resolve syntax error

* Update from merge
2018-05-12 01:47:49 +02:00
palmtree5
e4ea3110e3 [V3 Warnings] fix several bugs found (#1577) 2018-05-04 05:46:59 +02:00
palmtree5
c4dbbc2d1e [V3 Warnings] Action list isn't a dict (fix #1382) (#1408) 2018-03-14 19:10:07 -04:00
palmtree5
c1ac78eea4
[V3] Warning system (#1173)
* [V3 Warning] initial work on a warning system for v3

* [V3 Warning] rename some stuff and add a case type

* [V3 Warnings] rename package from warning

* [V3 Warnings] restructuring commands

* [V3 Warnings] remove expiry stuff + other refactoring

* [V3 Warnings] refactoring action logic

* [V3 Warnings] rewrites to action logic

* [V3 Warnings] add regen_messages.py
2018-02-25 20:14:38 -09:00