47 Commits

Author SHA1 Message Date
Kowlin
2d47d75919
Fix unmuting when a mod isn't a mod anymore. (#6411)
Co-authored-by: TrustyJAID <TrustyJAID@gmail.com>
2024-08-04 23:01:34 +02:00
TrustyJAID
0c9c210dbb
Prevent OverflowError from very large timedeltas in Mutes (#6353) 2024-04-21 03:01:28 +02:00
Jakub Kuczys
194dea545d
Update Mutes docs with timeout changes (#6341) 2024-04-01 03:00:53 +02:00
TrustyJAID
ad9e00d1d9
Menuify [p]activemutes command (#6266) 2024-04-01 02:06:38 +02:00
TrustyJAID
463f0c5e6d
Add support for timeouts to Mutes cog (#5604)
Co-authored-by: Michael Oliveira <34169552+Flame442@users.noreply.github.com>
2024-04-01 02:05:37 +02:00
Jakub Kuczys
d8e584b5e8
Fix CancelledError handling in done callbacks of cog init tasks (#6203) 2023-07-19 22:45:44 +02:00
Karlo Prikratki
5893d590a7
Fix NoneType error and channelmute saying user is already muted (#6144)
Co-authored-by: Jakub Kuczys <me@jacken.men>
2023-05-12 21:54:10 +02:00
Jakub Kuczys
5f4b0e853e
Fix issues with channel unmutes for mute data from 3.4.x (#6121) 2023-05-04 06:22:54 +02:00
Jakub Kuczys
2fe251ecf3
Port TiV changes applied to voice channels to stage channels (#6109) 2023-05-02 19:05:44 -04:00
Kreusada
79d11e947c
Use the commands module instead of checks for permission decorators (#5463)
Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
2023-04-13 14:16:12 -04:00
Lioness100
a89a27cadf
docs: fix typos (#5989)
Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
2023-02-13 21:36:09 -05:00
Jakub Kuczys
1241ea165c
Fix unintended moving *between* VCs when channel muting (#5854) 2022-10-03 18:11:37 +02:00
Jakub Kuczys
f02528378f
discord.py 2.0 update (3d914e08->2.0.1) (#5709) 2022-10-03 16:07:15 +02:00
jack1142
febca8ccbb
Migration to discord.py 2.0 (#5600)
* Temporarily set d.py to use latest git revision

* Remove `bot` param to Client.start

* Switch to aware datetimes

A lot of this is removing `.replace(...)` which while not technically
needed, simplifies the code base. There's only a few changes that are
actually necessary here.

* Update to work with new Asset design

* [threads] Update core ModLog API to support threads

- Added proper support for passing `Thread` to `channel`
  when creating/editing case
- Added `parent_channel_id` attribute to Modlog API's Case
    - Added `parent_channel` property that tries to get parent channel
- Updated case's content to show both thread and parent information

* [threads] Disallow usage of threads in some of the commands

- announceset channel
- filter channel clear
- filter channel add
- filter channel remove
- GlobalUniqueObjectFinder converter
    - permissions addglobalrule
    - permissions removeglobalrule
    - permissions removeserverrule
    - Permissions cog does not perform any validation for IDs
      when setting through YAML so that has not been touched
- streamalert twitch/youtube/picarto
- embedset channel
- set ownernotifications adddestination

* [threads] Handle threads in Red's permissions system (Requires)

- Made permissions system apply rules of (only) parent in threads

* [threads] Update embed_requested to support threads

- Threads don't have their own embed settings and inherit from parent

* [threads] Update Red.message_eligible_as_command to support threads

* [threads] Properly handle invocation of [p](un)mutechannel in threads

Usage of a (un)mutechannel will mute/unmute user in the parent channel
if it's invoked in a thread.

* [threads] Update Filter cog to properly handle threads

- `[p]filter channel list` in a threads sends list for parent channel
- Checking for filter hits for a message in a thread checks its parent
  channel's word list. There's no separate word list for threads.

* [threads] Support threads in Audio cog

- Handle threads being notify channels
- Update type hint for `is_query_allowed()`

* [threads] Update type hints and documentation to reflect thread support

- Documented that `{channel}` in CCs might be a thread
- Allowed (documented) usage of threads with `Config.channel()`
    - Separate thread scope is still in the picture though
      if it were to be done, it's going to be in separate in PR
- GuildContext.channel might be Thread

* Use less costy channel check in customcom's on_message_without_command

This isn't needed for d.py 2.0 but whatever...

* Update for in-place edits

* Embed's bool changed behavior, I'm hoping it doesn't affect us

* Address User.permissions_in() removal

* Swap VerificationLevel.extreme with VerificationLevel.highest

* Change to keyword-only parameters

* Change of `Guild.vanity_invite()` return type

* avatar -> display_avatar

* Fix metaclass shenanigans with Converter

* Update Red.add_cog() to be inline with `dpy_commands.Bot.add_cog()`

This means adding `override` keyword-only parameter and causing
small breakage by swapping RuntimeError with discord.ClientException.

* Address all DEP-WARNs

* Remove Context.clean_prefix and use upstream implementation instead

* Remove commands.Literal and use upstream implementation instead

Honestly, this was a rather bad implementation anyway...

Breaking but actually not really - it was provisional.

* Update Command.callback's setter

Support for functools.partial is now built into d.py

* Add new perms in HUMANIZED_PERM mapping (some from d.py 1.7 it seems)

BTW, that should really be in core instead of what we have now...

* Remove the part of do_conversion that has not worked for a long while

* Stop wrapping BadArgument in ConversionFailure

This is breaking but it's best to resolve it like this.

The functionality of ConversionFailure can be replicated with
Context.current_parameter and Context.current_argument.

* Add custom errors for int and float converters

* Remove Command.__call__ as it's now implemented in d.py

* Get rid of _dpy_reimplements

These were reimplemented for the purpose of typing
so it is no longer needed now that d.py is type hinted.

* Add return to Red.remove_cog

* Ensure we don't delete messages that differ only by used sticker

* discord.InvalidArgument->ValueError

* Move from raw <t:...> syntax to discord.utils.format_dt()

* Address AsyncIter removal

* Swap to pos-only for params that are pos-only in upstream

* Update for changes to Command.params

* [threads] Support threads in ignore checks and allow ignoring them

- Updated `[p](un)ignore channel` to accept threads
- Updated `[p]ignore list` to list ignored threads
- Updated logic in `Red.ignored_channel_or_guild()`

Ignores for guild channels now work as follows (only changes for threads):
- if channel is not a thread:
    - check if user has manage channels perm in channel
      and allow command usage if so
    - check if channel is ignored and disallow command usage if so
    - allow command usage if none of the conditions above happened
- if channel is a thread:
    - check if user has manage channels perm in parent channel
      and allow command usage if so
    - check if parent channel is ignored and disallow command usage
      if so
    - check if user has manage thread perm in parent channel
      and allow command usage if so
    - check if thread is ignored and disallow command usage if so
    - allow command usage if none of the conditions above happened

* [partial] Raise TypeError when channel is of PartialMessageable type

- Red.embed_requested
- Red.ignored_channel_or_guild

* [partial] Discard command messages when channel is PartialMessageable

* [threads] Add utilities for checking appropriate perms in both channels & threads

* [threads] Update code to use can_react_in() and @bot_can_react()

* [threads] Update code to use can_send_messages_in

* [threads] Add send_messages_in_threads perm to mute role and overrides

* [threads] Update code to use (bot/user)_can_manage_channel

* [threads] Update [p]diagnoseissues to work with threads

* Type hint fix

* [threads] Patch vendored discord.ext.menus to check proper perms in threads

I guess we've reached time when we have to patch the lib we vendor...

* Make docs generation work with non-final d.py releases

* Update discord.utils.oauth_url() usage

* Swap usage of discord.Embed.Empty/discord.embeds.EmptyEmbed to None

* Update usage of Guild.member_count to work with `None`

* Switch from Guild.vanity_invite() to Guild.vanity_url

* Update startup process to work with d.py's new asynchronous startup

* Use setup_hook() for pre-connect actions

* Update core's add_cog, remove_cog, and load_extension methods

* Update all setup functions to async and add awaits to bot.add_cog calls

* Modernize cogs by using async cog_load and cog_unload

* Address StoreChannel removal

* [partial] Disallow passing PartialMessageable to Case.channel

* [partial] Update cogs and utils to work better with PartialMessageable

- Ignore messages with PartialMessageable channel in CustomCommands cog
- In Filter cog, don't pass channel to modlog.create_case()
  if it's PartialMessageable
- In Trivia cog, only compare channel IDs
- Make `.utils.menus.menu()` work for messages
  with PartialMessageable channel
- Make checks in `.utils.tunnel.Tunnel.communicate()` more rigid

* Add few missing DEP-WARNs
2022-04-03 03:21:20 +02:00
jack1142
c69e8d31fd Reformat with Black 22.1.0 2022-03-22 18:37:17 +01:00
jack1142
ed4f2cf466
Switch from low-level loop.create_task and asyncio.ensure_future (#5626)
* Switch from low-level loop.create_task and asyncio.ensure_future

* Patch vendored discord.ext.menus to use modern APIs as well

That ext is no longer maintained by Danny anyway so...

* black
2022-03-21 10:24:46 -06:00
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
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
Flame442
d56f31a708
[Mutes] Fix vars not getting formatted due to previous PR (#5404)
* Fix vars not getting formatted due to #5364

* Only format a second time if needed

* Format only on string literals
2021-10-17 02:56:26 +02:00
jack1142
4b70acb989
Do not include expected wait_for responses in translated strings (#5364)
* Do not include 'I agree' prompt in translation string

* Add more stuff

* Address review comment

* Address review comments
2021-10-16 00:02:35 +02:00
jack1142
a0a433b13d
Improve and add more usage of discord timestamps (#5241)
* Improve and add more usage of discord timestamps

* How did that whitespace get there?
2021-09-04 09:14:05 +02:00
Kreus Amredes
c34f1e2f01
[Mutes] Fix NotFound error when trying to delete message (#5163)
* [Mutes] Fix NotFound error when trying to delete message

* other occurances
2021-08-31 20:47:32 +02:00
aleclol
820b21dccb
[Mutes] Don't send dms to bots (#5071) 2021-05-23 15:24:08 +01:00
Fixator10
c40efd479b
[Mutes] Handle Forbidden in mute_channel
* Merge pull request #4994
2021-05-19 12:49:37 +01:00
Kreusada
5d905a93ac
[Docs] Mutes Cog Guide (#4875)
* initial commit

* Update mutes.rst

* Add argument headers

* Change bool name for forcerole

* fixes

* Add mutes to toctree

* spacing adjustment

* Fix spacing between examples, use bullet points

* Add args header

* Add args header

* Add labeler glob

* unify style

* aaaaa wrong branch

* fix grammar and formatting errors
2021-05-18 17:06:50 -04:00
PredaaA
847444eab1
[Mutes] Fix data conversion to shema_version 1 and add a note about it (#4934)
* [Mutes] Add a note about conversion to schema_version 1

* Only start the conversion if all_channels

* Actually do what the previous commit said

* okay this time is the right time

* Update mutes.py

* Move conversion to its own method

* Update mutes.py
2021-04-03 18:43:36 -06:00
PredaaA
35dfb04066
[Mutes] Add guild ID to mutes data (#4906)
* [Mutes] Add guild ID to mutes data.

* Actually make the whole thing works.

* config version as integer, and init task no longer in setup

* oops

* Fix cog_disabled_in_guild check.

* Add Trusty's requested changes.
2021-04-01 19:01:43 -06:00
❥sora
d45a02166d
a small typo (#4915) 2021-03-26 19:13:00 +01:00
jack1142
7d42c4c6c3
Minor text fix in Mutes cog (#4853) 2021-02-26 18:32:11 +01:00
Ellie Saurich
dfe84f9936
[Mutes] Wrong error message when muting fails (#4850)
* [Mutes] Wrong error message when muting fails

* This applies to both mute and unmuting of members.

Co-authored-by: Kowlin <Kowlin@users.noreply.github.com>
2021-02-26 08:22:04 +00:00
Jamie
649b4ebb15
add checks to 2 muteset commands (#4849) 2021-02-26 03:14:56 +01:00
jack1142
6cfaffb8a8
Add i18n deco to Dev and Mutes cog (#4815)
* Add i18n deco to Dev cog

* Add i18n deco to Mutes cog
2021-02-15 00:19:34 +01:00
Dav
aa0ee3385d
[Mutes] Add ability to send DMs on mute/unmute (#4563)
* handle manual mutes/unmutes

Doing this in the Web-Editor is painful. Let's switch to VSC.

* embed version

* non embed

* config stuff

* testing done

* wow black

* Few things before I start local testing

* Fix new lines

* Make messages not depend on modlog

* Yay voicemutes

* black+import

* what is your ducking problem vscode

* adress review

* this is driving me mad

* Check the config in `_send_dm_notification` to avoid code repetition

* Fix incorrect type hints

* Remove no longer needed line changes

* Remove unused function

* Update the type hints from commit 946299 in the MixinMeta too

* Fixed wrong variable being passed to the method and ensure DMs aren't sent when we couldn't get the member object

* They call me dumb for a reason

* Stop overriding variable with duration + various formatting tweaks

* :(

* We need to differ between voice and text in two places, interesting...

* Show info about no reason provided in embed

* Apparently, the `reason` can also be an empty string :|

* Update redbot/cogs/mutes/mutes.py

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

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2021-01-23 11:29:18 +01:00
jack1142
4138410d33
Ensure no role hierarchy bypassing in Mutes (#4741)
* Ensure no role hierarchy bypassing on bad role configuration

* Do the same for `[p]muteset role`
2021-01-20 13:32:59 -07:00
jack1142
537656c365
Fix role position checks (#4740) 2021-01-20 13:32:43 -07:00
Predeactor
d53ff57794
Shorten the audit log reason appropriately, remove unused vars (#4189)
* [Mod] Check for reason length & remove unused vars

This PR also remove unused variable.

* Blame me

* Apply Kowlin order.

Text will get truncate in audit logs in case we're going over 512 characters.

* This is already handled by ban_user()

* Use `get_audit_reason()` in `[p]tempban`

* Add a new kwarg to `get_audit_reason()` instead

* Include `[p]voiceban` and `[p]voiceunban`

* Include Mutes cog

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-12-23 03:22:59 +01:00
jack1142
7c36709f76
Handle None case for until in on_member_join (#4568)
* Handle `None` case for `until` in `on_member_join`

* They said it can't be too long!
2020-10-29 18:12:57 -06:00
jack1142
b30a8b86a4
Plurality matters (use correct variable name) (#4542) 2020-10-26 19:02:39 -06:00
TrustyJAID
b13dec10c5
Replace use of asyncio.gather with bounded_gather (#4537)
* Remove use of asyncio.gather

* black

* typo

* lol 1 character difference

* Let's try this instead

* another typo, it's too early to read

* Add max concurrency on makerole command and prevent multiple roles being added created
2020-10-27 01:20:43 +01:00
TrustyJAID
fd77e97712
[Mutes] Prevent modlog updates on unmute due to category channel sync (#4539)
* [Mutes] Prevent modlog updates on unmute due to category channel sync

* Try here

* would help to remember to change all the right things
2020-10-27 01:18:55 +01:00
jack1142
0b0ace10dd
Fix unmute type for manually removed channel overwrites (#4540) 2020-10-26 18:16:11 -06:00
TrustyJAID
3ae5301a76
Fix auto channel unmute still applying after bot restart (#4536) 2020-10-26 19:22:33 +01:00
jack1142
bcc24d67d1
Properly iterate through dict's items in multi channel unmute (#4534) 2020-10-26 11:57:29 -06:00
jack1142
46c0f5e373
Fix TypeError in automatic multi channel unmutes (#4533) 2020-10-26 11:56:45 -06:00
jack1142
eeaac828d9
Fix KeyError in [p]muteset role (#4531) 2020-10-26 11:55:52 -06: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
TrustyJAID
7bb6e60c52
Move mutes to new cog, add role-based and temporary mutes (#3634)
* revert the revert the revert git is hard...

* and remove old mutes

* make voicemutes less yelly

* fix error when no args present in mute commands

* update docstrings

* address review

* black

* oops

* fix voicemutes

* remove mutes.py file

* Remove _voice_perm_check from mod since it's now in mutes cog

* remove naive datetimes
prevent muting the bot
prevent muting yourself
fix error message when lots of channels are present

* change alias for channelunmute
Be more verbose for creating default mute role

* add `[p]activemutes` to show current mutes in the server and time remaining on the mutes

* improve resolution of unmute time

* black

* Show indefinite mutes in activemutes and only show the current servers mutes in activemutes

* replace message.created_at with timezone aware timezone

* remove "server" from activemutes to clean up look since channelmutes will show channel

* better cache management, add tracking for manual muted role removal in the cache and modlog cases

* Fix keyerror in mutes command when unsuccessful mutes

* add typing indicator and improve config settings

* flake8 issue

* add one time message when attempting to mute without a role set, consume rate limits across channels for overwrite mutes

* Don't clear the whole guilds settings when a mute is finished. Optimize server mutes to better handle migration to API method later. Fix typehints.

* Utilize usage to make converter make more sense

* remove decorator permission checks and fix doc strings

* handle role changes better

* More sanely handle channel mutes return and improve failed mutes dialogue. Re-enable task cleaner. Reduce wait time to improve resolution of mute time.

* Handle re-mute on leave properly

* fix unbound error in overwrites mute

* revert the revert the revert git is hard...

* and remove old mutes

* make voicemutes less yelly

* fix error when no args present in mute commands

* update docstrings

* address review

* black

* oops

* fix voicemutes

* Remove _voice_perm_check from mod since it's now in mutes cog

* remove naive datetimes
prevent muting the bot
prevent muting yourself
fix error message when lots of channels are present

* change alias for channelunmute
Be more verbose for creating default mute role

* add `[p]activemutes` to show current mutes in the server and time remaining on the mutes

* improve resolution of unmute time

* black

* Show indefinite mutes in activemutes and only show the current servers mutes in activemutes

* replace message.created_at with timezone aware timezone

* remove "server" from activemutes to clean up look since channelmutes will show channel

* better cache management, add tracking for manual muted role removal in the cache and modlog cases

* Fix keyerror in mutes command when unsuccessful mutes

* add typing indicator and improve config settings

* flake8 issue

* add one time message when attempting to mute without a role set, consume rate limits across channels for overwrite mutes

* Don't clear the whole guilds settings when a mute is finished. Optimize server mutes to better handle migration to API method later. Fix typehints.

* Utilize usage to make converter make more sense

* remove decorator permission checks and fix doc strings

* handle role changes better

* More sanely handle channel mutes return and improve failed mutes dialogue. Re-enable task cleaner. Reduce wait time to improve resolution of mute time.

* Handle re-mute on leave properly

* fix unbound error in overwrites mute

* remove mutes.pt

* remove reliance on mods is_allowed_by_hierarchy since we don't have a setting to control that anyways inside this.

* black

* fix hierarchy check

* wtf

* Cache mute roles for large bots

* fix lint

* fix this error

* Address review 1

* lint

* fix string i18n issue

* remove unused typing.Coroutine import and fix i18n again

* missed this docstring

* Put voiceban and voiceunban back in mod where it's more appropriate

* Address review 2 electric boogaloo

* Make voicemutes use same methods as channel mute

* black

* handle humanize_list doesn't accept generators

* update voicemutes docstrings

* make voiceperm check consistent with rest of error handling

* bleh

* fix modlog case spam when overrides are in place

* <a:pandaexplode:639975629793787922>

* bleck

* use total_seconds() instead of a dict, sorry everyone already using this lmao

* <:excited:474074780887285776> This should be everything

* black

* fix the things

* bleh

* more cleanup

* lmao hang on

* fix voice mutes thingy

* Title Case Permissions

* oh I see

* I'm running out of funny one-liners for commit messages

* oof

* ugh

* let's try this

* voicemutes manage_permissions

* Cleanup mutes if they expire when member is not present

* black

* linters go brr

Co-authored-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
2020-10-26 02:52:11 +01:00