Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new optional param to [p]muteset senddm for auto unmute dm #6366

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions redbot/cogs/mutes/mutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(self, bot: Red):
"muted_users": {},
"default_time": 0,
"dm": False,
"dm_auto_unmute": False,
"show_mod": False,
}
self.config.register_global(schema_version=0)
Expand Down Expand Up @@ -344,9 +345,10 @@ async def _auto_unmute_user(self, guild: discord.Guild, data: dict):
_("Automatic unmute"),
until=None,
)
await self._send_dm_notification(
member, author, guild, _("Server unmute"), _("Automatic unmute")
)
if dm_auto_unmute:
await self._send_dm_notification(
member, author, guild, _("Server unmute"), _("Automatic unmute")
)
else:
chan_id = await self.config.guild(guild).notification_channel()
notification_channel = guild.get_channel(chan_id)
Expand Down Expand Up @@ -452,9 +454,10 @@ async def _auto_channel_unmute_user_multi(
modlog_reason,
until=None,
)
await self._send_dm_notification(
member, author, guild, _("Server unmute"), _("Automatic unmute")
)
if dm_auto_unmute:
await self._send_dm_notification(
member, author, guild, _("Server unmute"), _("Automatic unmute")
)
self._channel_mute_events[guild.id].set()
if any(results):
reasons = {}
Expand Down Expand Up @@ -531,9 +534,10 @@ async def _auto_channel_unmute_user(
until=None,
channel=channel,
)
await self._send_dm_notification(
member, author, channel.guild, notification_title, _("Automatic unmute")
)
if dm_auto_unmute:
await self._send_dm_notification(
member, author, channel.guild, notification_title, _("Automatic unmute")
)
return None
else:
error_msg = _(
Expand Down Expand Up @@ -794,14 +798,19 @@ async def muteset(self, ctx: commands.Context):
@muteset.command()
@commands.guild_only()
@commands.mod_or_permissions(manage_channels=True)
async def senddm(self, ctx: commands.Context, true_or_false: bool):
async def senddm(self, ctx: commands.Context, true_or_false: bool, send_unmute_dm: Optional[bool] = None):
"""Set whether mute notifications should be sent to users in DMs."""
await self.config.guild(ctx.guild).dm.set(true_or_false)
if send_unmute_dm is None:
await self.config.guild(ctx.guild).dm_auto_unmute.set(true_or_false)
else:
await self.config.guild(ctx.guild).dm_auto_unmute.set(send_unmute_dm)
if true_or_false:
await ctx.send(_("I will now try to send mute notifications to users DMs."))
else:
await ctx.send(_("Mute notifications will no longer be sent to users DMs."))


@muteset.command()
@commands.guild_only()
@commands.mod_or_permissions(manage_channels=True)
Expand Down