[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>
This commit is contained in:
Dav
2021-01-23 10:29:18 +00:00
committed by GitHub
parent 2ce4a275fc
commit aa0ee3385d
3 changed files with 166 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import List, Tuple, Optional, Dict
from typing import List, Tuple, Optional, Dict, Union
from datetime import datetime
import discord
@@ -25,3 +25,15 @@ class MixinMeta(ABC):
ctx: commands.Context, user_voice_state: Optional[discord.VoiceState], **perms: bool
) -> bool:
raise NotImplementedError()
@abstractmethod
async def _send_dm_notification(
self,
user: Union[discord.User, discord.Member],
moderator: Optional[Union[discord.User, discord.Member]],
guild: discord.Guild,
mute_type: str,
reason: Optional[str],
duration=None,
):
raise NotImplementedError()