[Warnings] Add setting for warn channel and DMing warns toggle #2929

Merged
Ianardo-DiCaprio merged 30 commits from patch-1 into V3/develop 2020-03-12 21:18:00 +01:00
Ianardo-DiCaprio commented 2019-08-12 10:20:14 +02:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

This adds commands requested in #2800. It allows to toggle warns being sent to DM's, allows to toggle warns being sent to a channel on a server and has a command to set the channel the warns get sent to, if no channel is set it gets sent to the channel the [p]warn command was used in.

### Type - [ ] Bugfix - [x] Enhancement - [ ] New feature ### Description of the changes This adds commands requested in #2800. It allows to toggle warns being sent to DM's, allows to toggle warns being sent to a channel on a server and has a command to set the channel the warns get sent to, if no channel is set it gets sent to the channel the [p]warn command was used in.
palmtree5 (Migrated from github.com) reviewed 2019-08-12 10:20:14 +02:00
Twentysix26 (Migrated from github.com) reviewed 2019-08-12 10:20:14 +02:00
DevilXD (Migrated from github.com) requested changes 2019-08-17 11:00:06 +02:00
DevilXD (Migrated from github.com) left a comment

Just couple of changes.

Also, from the original issue:

(...) option to warn a user (i.e. ping them) in set guild channel and/or just warn that user in channel where the [p]warn command was issued.

This could be slightly hard to understand, at least for me. I've commented on the original issue, but basically - there already is an option to log warnings into the modlog channel. A second channel with warnings only could be made public tho, so I guess there is some logic behind having it like this ¯\_(ツ)_/¯

Just couple of changes. Also, from the original issue: > (...) option to warn a user (i.e. ping them) in set guild channel and/or just warn that user in channel where the [p]warn command was issued. This could be slightly hard to understand, at least for me. I've commented on the original issue, but basically - there already is an option to log warnings into the modlog channel. A second channel with warnings only could be made public tho, so I guess there is some logic behind having it like this ¯\\\_(ツ)\_/¯
DevilXD (Migrated from github.com) commented 2019-08-17 10:09:13 +02:00

This not toggle should either be in the if statement itself, or this line removed and the send messages swapped.

This `not toggle` should either be in the if statement itself, or this line removed and the send messages swapped.
DevilXD (Migrated from github.com) commented 2019-08-17 10:16:14 +02:00

This really should be just suppressed, if they don't care about mod actions, that's entirely on them.

This really should be just suppressed, if they don't care about mod actions, that's entirely on them.
DevilXD (Migrated from github.com) commented 2019-08-17 10:17:57 +02:00

I don't get the point of this. One shouldn't enforce those, if someone likes to have both of them disabled and still use warns, this should be possible without getting an annoying message on every usage.

I don't get the point of this. One shouldn't enforce those, if someone likes to have both of them disabled and still use warns, this should be possible without getting an annoying message on every usage.
DevilXD (Migrated from github.com) requested changes 2019-08-17 21:28:52 +02:00
DevilXD (Migrated from github.com) commented 2019-08-17 20:57:34 +02:00

Since the purpose of this is to suppress the exception, I recommend contextlib.suppress() and making sure the only thing inside the suppress block is the await user.send(...) part.

Since the purpose of this is to suppress the exception, I recommend `contextlib.suppress()` and making sure the only thing inside the suppress block is the `await user.send(...)` part.
Jackenmen (Migrated from github.com) requested changes 2020-01-17 20:49:41 +01:00
Jackenmen (Migrated from github.com) left a comment

Looks good, I know it looks like a lot of review comments, but these are all just minor string improvements =)

Looks good, I know it looks like a lot of review comments, but these are all just minor string improvements =)
Jackenmen (Migrated from github.com) commented 2020-01-17 20:20:16 +01:00

This file should be called 2929.enhance.rst not 2929.enhance.rst.txt

This file should be called `2929.enhance.rst` not `2929.enhance.rst.txt`
@ -76,6 +84,55 @@ class Warnings(commands.Cog):
else:
Jackenmen (Migrated from github.com) commented 2020-01-17 19:22:56 +01:00
            await ctx.send(_("Warnings will no longer be sent to users in DMs."))
```suggestion await ctx.send(_("Warnings will no longer be sent to users in DMs.")) ```
Jackenmen (Migrated from github.com) commented 2020-01-17 19:23:44 +01:00
            await ctx.send(_("Warnings will now be sent to users in DMs."))
```suggestion await ctx.send(_("Warnings will now be sent to users in DMs.")) ```
Jackenmen (Migrated from github.com) commented 2020-01-17 19:26:37 +01:00
        """Toggle whether warnings should be sent to users in DMs."""
```suggestion """Toggle whether warnings should be sent to users in DMs.""" ```
Jackenmen (Migrated from github.com) commented 2020-01-17 19:35:47 +01:00
        """Set the channel where warnings should be sent to.

        Leave empty to use the channel `[p]warn` command was called in.
        """
```suggestion """Set the channel where warnings should be sent to. Leave empty to use the channel `[p]warn` command was called in. """ ```
Jackenmen (Migrated from github.com) commented 2020-01-17 20:16:02 +01:00
            await ctx.send(_("Warnings will now be sent in the channel command was used in."))
```suggestion await ctx.send(_("Warnings will now be sent in the channel command was used in.")) ```
Jackenmen (Migrated from github.com) commented 2020-01-17 20:17:35 +01:00
        """
        Toggle if warnings should be sent to a channel set with `[p]warningset warnchannel`
        """
```suggestion """ Toggle if warnings should be sent to a channel set with `[p]warningset warnchannel` """ ```
Jackenmen (Migrated from github.com) commented 2020-01-17 20:18:14 +01:00
            await ctx.send(_("Warnings will now be sent to set warn channel."))
```suggestion await ctx.send(_("Warnings will now be sent to set warn channel.")) ```
Jackenmen (Migrated from github.com) commented 2020-01-17 20:18:56 +01:00
            await ctx.send(_("Warns will no longer be sent in the channel."))
```suggestion await ctx.send(_("Warns will no longer be sent in the channel.")) ```
Jackenmen (Migrated from github.com) commented 2020-01-17 20:10:08 +01:00

If message about warning is sent in different channel, it would be good to still know that command worked from the channel command was sent in, so adding tick here as well would help that.

                channel = warn_channel
                await ctx.tick()
If message about warning is sent in different channel, it would be good to still know that command worked from the channel command was sent in, so adding tick here as well would help that. ```suggestion channel = warn_channel await ctx.tick() ```
Jackenmen (Migrated from github.com) reviewed 2020-01-23 17:26:59 +01:00
Jackenmen (Migrated from github.com) commented 2020-01-23 17:26:59 +01:00

I saw you marked this as resolved, but from the looks of it you renamed wrong file ;)

I saw you marked this as resolved, but from the looks of it you renamed wrong file ;)
Drapersniper (Migrated from github.com) requested changes 2020-01-23 22:35:20 +01:00
Drapersniper (Migrated from github.com) commented 2020-01-23 22:27:40 +01:00

Dont take it as a definitive thing but according to https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/.github/CONTRIBUTING.md#47-using-towncrier

This should be 2929.feature.rst

Dont take it as a definitive thing but according to https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/.github/CONTRIBUTING.md#47-using-towncrier This should be `2929.feature.rst`
@ -1,3 +1,4 @@
import contextlib
Drapersniper (Migrated from github.com) commented 2020-01-23 22:31:36 +01:00

Note really a necesity but...

from collections import namedtuple
from typing import Union, Optional

import contextlib
import discord

should be

import contextlib
from collections import namedtuple
from typing import Union, Optional

import discord

This one is just a nitpick for import organization 😈

Note really a necesity but... ``` from collections import namedtuple from typing import Union, Optional import contextlib import discord ``` should be ``` import contextlib from collections import namedtuple from typing import Union, Optional import discord ``` This one is just a nitpick for import organization 😈
@ -76,6 +84,55 @@ class Warnings(commands.Cog):
else:
Drapersniper (Migrated from github.com) commented 2020-01-23 22:28:13 +01:00

This should be:

                _("The warn channel has been set to {channel}.").format(channel=channel.mention)
This should be: ```suggestion _("The warn channel has been set to {channel}.").format(channel=channel.mention) ```
Drapersniper (Migrated from github.com) commented 2020-01-23 22:28:41 +01:00

This should be:

        Toggle if warnings should be sent to a channel set with `[p]warningset warnchannel`.
This should be: ```suggestion Toggle if warnings should be sent to a channel set with `[p]warningset warnchannel`. ```
Drapersniper (Migrated from github.com) commented 2020-01-23 22:29:19 +01:00

As a user i'd expect this to show a name/mention of the channel
await ctx.send(_("Warnings will now be sent to set warn channel."))

As a user i'd expect this to show a name/mention of the channel ` await ctx.send(_("Warnings will now be sent to set warn channel."))`
Drapersniper (Migrated from github.com) commented 2020-01-23 22:29:37 +01:00

As a user i'd expect this to show a name/mention of the channel
await ctx.send(_("Warns will no longer be sent in the channel."))

As a user i'd expect this to show a name/mention of the channel `await ctx.send(_("Warns will no longer be sent in the channel."))`
Drapersniper (Migrated from github.com) commented 2020-01-23 22:34:30 +01:00

I know it's not ideal but we shouldn't say this in the affirmative, perhaps it should be changed to "I will try to send warning to user in DMs." since users can for example block the bot - it's not guaranteed that warned users will get a warning.
Same applied to the toggle off message.

I know it's not ideal but we shouldn't say this in the affirmative, perhaps it should be changed to `"I will try to send warning to user in DMs."` since users can for example block the bot - it's not guaranteed that warned users will get a warning. Same applied to the toggle off message.
Drapersniper (Migrated from github.com) commented 2020-01-23 22:32:59 +01:00

The DM feature .. are we expecting it to only send it via DM or send DM as an aditional thing?

The DM feature .. are we expecting it to only send it via DM or send DM as an aditional thing?
Jackenmen (Migrated from github.com) reviewed 2020-01-23 22:46:05 +01:00
Jackenmen (Migrated from github.com) commented 2020-01-23 22:46:05 +01:00

We expect it to send to DM as an additional thing, this is a separate setting.

We expect it to send to DM as an additional thing, this is a separate setting.
Jackenmen (Migrated from github.com) requested changes 2020-01-24 03:10:19 +01:00
Jackenmen (Migrated from github.com) left a comment

One thing I didn't notice in first review.
Once this and UX stuff pointed out by Draper gets handled, this should be ready to go.

One thing I didn't notice in first review. Once this and UX stuff pointed out by Draper gets handled, this should be ready to go.
Jackenmen (Migrated from github.com) commented 2020-01-24 03:04:37 +01:00

Sinbad pointed out that this needs handling for cases when bot can't send the message in set channel.
Preferred way of doing this would be first checking if bot has permission to send messages in the channel and also catching any HTTP exception that occurs when sending the message.

            if channel.permissions_for(guild.me).send_messages:
                with contextlib.suppress(discord.HTTPException):
                    await channel.send(
                        _("{user} has been warned.").format(user=user.mention), embed=em
                    )
Sinbad pointed out that this needs handling for cases when bot can't send the message in set channel. Preferred way of doing this would be first checking if bot has permission to send messages in the channel and also catching any HTTP exception that occurs when sending the message. ```suggestion if channel.permissions_for(guild.me).send_messages: with contextlib.suppress(discord.HTTPException): await channel.send( _("{user} has been warned.").format(user=user.mention), embed=em ) ```
FixedThink commented 2020-01-25 02:30:50 +01:00 (Migrated from github.com)

Would it be possible to inform the author about the DM not being sent if it's enabled?
If the DM fails, the kick/ban will still succeed, but the bot will send a message like "This user did not receive your case as they have either blocked the bot or disabled DMs." I think this will be much better then just sending a DM without any sort of feedback as of what happened to it.

The reason for this is that (to me at least) it tends to happen that someone says they have never been informed about why they're kicked/muted/whatever, but that there is no way for a staff member to actually verify whether that's true or whether they're 🙈. In other words it would ease a lot of moderation arguments and such, especially with warnings.

Would it be possible to inform the author about the DM not being sent if it's enabled? If the DM fails, the kick/ban will still succeed, but the bot will send a message like `"This user did not receive your case as they have either blocked the bot or disabled DMs."` I think this will be much better then just sending a DM without any sort of feedback as of what happened to it. The reason for this is that (to me at least) it tends to happen that someone *says* they have never been informed about why they're kicked/muted/whatever, but that there is no way for a staff member to actually verify whether that's true or whether they're 🙈. In other words it would ease a lot of moderation arguments and such, *especially* with warnings.
Jackenmen commented 2020-01-25 16:59:53 +01:00 (Migrated from github.com)

@FixedThink It would be possible but in my opinion this shouldn't be part of this PR, I would advice making a separate issue with a request for this enhancement.

@FixedThink It would be possible but in my opinion this shouldn't be part of this PR, I would advice making a separate issue with a request for this enhancement.
Jackenmen (Migrated from github.com) requested changes 2020-01-26 04:12:23 +01:00
Jackenmen (Migrated from github.com) left a comment

This should be the only needed change before this can be approved.

This should be the only needed change before this can be approved.
@ -76,6 +84,55 @@ class Warnings(commands.Cog):
else:
Jackenmen (Migrated from github.com) commented 2020-01-26 04:09:51 +01:00

channel.mention won't work here because:
a) channel variable isn't a channel object
b) warn channel might not be set at all - bot should then say it will send warnings in the channel command was used in

`channel.mention` won't work here because: a) `channel` variable isn't a channel object b) warn channel might not be set at all - bot should then say it will send warnings in the channel command was used in
Jackenmen (Migrated from github.com) requested changes 2020-01-26 23:29:35 +01:00
@ -76,6 +84,55 @@ class Warnings(commands.Cog):
else:
Jackenmen (Migrated from github.com) commented 2020-01-26 23:29:33 +01:00

This should say that warnings will now be sent to the channel command was used in, instead of saying that channel hasn't been set.
And no need to use .format if there's nothing to be replaced.

This should say that warnings will now be sent to the channel command was used in, instead of saying that channel hasn't been set. And no need to use `.format` if there's nothing to be replaced.
Jackenmen (Migrated from github.com) requested changes 2020-01-27 15:13:20 +01:00
@ -76,6 +84,55 @@ class Warnings(commands.Cog):
else:
Jackenmen (Migrated from github.com) commented 2020-01-27 15:10:00 +01:00

Like I said, it should say that warnings will be sent to the channel warn command was used in, similarly to what's said in line 114. Current string isn't true.

Like I said, it should say that warnings will be sent to the channel warn command was used in, similarly to what's said in line 114. Current string isn't true.
Jackenmen (Migrated from github.com) approved these changes 2020-03-12 21:15:10 +01:00
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!2929
No description provided.