[Mod] Enhanced [p]hackban #2164

Merged
Twentysix26 merged 7 commits from V3/greedy_mod into V3/develop 2019-01-05 03:29:06 +01:00
Twentysix26 commented 2018-10-01 02:15:05 +02:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

This PR makes use of the recently introduced Greedy and Optional to enhance the [p]hackban command, allowing multiple user IDs to be passed. It also adds the optional "message deletion days" parameter.

Work in progress and not completely tested yet (especially the modlog's case creation)
Feedback welcome

### Type - [ ] Bugfix - [X] Enhancement - [ ] New feature ### Description of the changes This PR makes use of the recently introduced Greedy and Optional to enhance the `[p]hackban` command, allowing multiple user IDs to be passed. It also adds the optional "message deletion days" parameter. Work in progress and not completely tested yet (especially the modlog's case creation) Feedback welcome
palmtree5 (Migrated from github.com) reviewed 2018-10-01 02:15:05 +02:00
Kowlin (Migrated from github.com) reviewed 2018-10-01 02:30:59 +02:00
Kowlin (Migrated from github.com) left a comment
No description provided.
Black went on its own way and said that our int's aren't good enough.
Twentysix26 (Migrated from github.com) reviewed 2018-10-01 09:27:08 +02:00
Twentysix26 (Migrated from github.com) commented 2018-10-01 09:27:08 +02:00

I think it does that for readability but it's not really useful for us in this case. I guess we have to tweak it a bit.

I think it does that for readability but it's not really useful for us in this case. I guess we have to tweak it a bit.
Twentysix26 (Migrated from github.com) reviewed 2018-10-02 01:39:16 +02:00
@ -473,0 +445,4 @@
text += "\n".join(errors.values())
for p in pagify(text):
await ctx.send(p)
Twentysix26 (Migrated from github.com) commented 2018-10-02 01:39:16 +02:00

Edge case still to be fixed here: at the moment if the invoked ban fails, the banning is still successful as far as the hackban command is concerned.

Edge case still to be fixed here: at the moment if the invoked ban fails, the banning is still successful as far as the hackban command is concerned.
Twentysix26 commented 2018-10-02 23:33:26 +02:00 (Migrated from github.com)

I think I covered all the edge cases after the last commit. Should be ready to be tested fully.

I think I covered all the edge cases after the last commit. Should be ready to be tested fully.
Kowlin commented 2018-10-02 23:58:23 +02:00 (Migrated from github.com)

Gonna give it a shot.

Gonna give it a shot.
aikaterna commented 2018-10-06 00:36:20 +02:00 (Migrated from github.com)

If you hackban someone and the mod-log channel is not set to a channel, you get this error:

[05/10/2018 15:28] INFO mod hackban 525: aikaterna(15449707214864****) hackbanned 49561788060847****
[05/10/2018 15:28] ERROR events on_error 191: Exception in modlog_case_create
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 225, in _run_event
    await coro(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/redbot/cogs/mod/mod.py", line 1620, in on_modlog_case_create
    mod_channel = await modlog.get_modlog_channel(case.guild)
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/redbot/core/modlog.py", line 694, in get_modlog_channel
    raise RuntimeError("Failed to get the mod log channel!")
RuntimeError: Failed to get the mod log channel!

I'm not sure if this is the case on brand new installs, this was on a bot that had a mod-log channel set and then removed and when that removal occurs the mod-log channel saved in the settings.json is set as "null" for that guild.

If you hackban someone and the mod-log channel is not set to a channel, you get this error: ``` [05/10/2018 15:28] INFO mod hackban 525: aikaterna(15449707214864****) hackbanned 49561788060847**** [05/10/2018 15:28] ERROR events on_error 191: Exception in modlog_case_create Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 225, in _run_event await coro(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/redbot/cogs/mod/mod.py", line 1620, in on_modlog_case_create mod_channel = await modlog.get_modlog_channel(case.guild) File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/redbot/core/modlog.py", line 694, in get_modlog_channel raise RuntimeError("Failed to get the mod log channel!") RuntimeError: Failed to get the mod log channel! ``` I'm not sure if this is the case on brand new installs, this was on a bot that had a mod-log channel set and then removed and when that removal occurs the mod-log channel saved in the settings.json is set as "null" for that guild.
Twentysix26 commented 2018-10-08 00:34:46 +02:00 (Migrated from github.com)

@aikaterna Is this related to what this PR introduces? I'm doing the same call (and error handling) as the other commands so if this is a separate problem it might be worth opening a dedicated issue

@aikaterna Is this related to what this PR introduces? I'm doing the same call (and error handling) as the other commands so if this is a separate problem it might be worth opening a dedicated issue
Twentysix26 commented 2018-10-14 02:15:18 +02:00 (Migrated from github.com)

I put the whole [p]ban logic into its own function, so that it can be used by both commands. This was necessary to handle the [p]ban invocation from [p]hackban cleanly: before, if any error occurred, it would send a separate message for it. So, for example, if 9 bans out of 10 failed, you would get the [p]hackban's "results" message plus 9 separate messages coming from [p]ban.

I put the whole `[p]ban` logic into its own function, so that it can be used by both commands. This was necessary to handle the `[p]ban` invocation from `[p]hackban` cleanly: before, if any error occurred, it would send a separate message for it. So, for example, if 9 bans out of 10 failed, you would get the `[p]hackban`'s "results" message plus 9 separate messages coming from `[p]ban`.
mikeshardmind commented 2018-10-14 02:17:45 +02:00 (Migrated from github.com)

I'd like to take a look at this later, but I'm in favor of anything that de-duplicates shared logic, and moves as much out of command objects as is sane to do (increases ability for things written to be used by other things sanely).

I'd like to take a look at this later, but I'm in favor of anything that de-duplicates shared logic, and moves as much out of command objects as is sane to do (increases ability for things written to be used by other things sanely).
Sign in to join this conversation.
No reviewers
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!2164
No description provided.