[ModLog] Prevent duplicate kwarg error #2848

Merged
Tobotimus merged 2 commits from V3/bugfix/modlog_duplicate_kwarg into V3/develop 2019-07-13 02:17:00 +02:00
Tobotimus commented 2019-07-10 13:48:17 +02:00 (Migrated from github.com)

The name key used to be set in the Config for casetypes.

Resolves this traceback:

Traceback (most recent call last):
  File "discord/ext/commands/core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "redbot/cogs/mod/kickban.py", line 223, in ban
    user=user, ctx=ctx, days=days, reason=reason, create_modlog_case=True
  File "redbot/cogs/mod/kickban.py", line 114, in ban_user
    channel=None,
  File "redbot/core/modlog.py", line 647, in create_case
    case_type = await get_casetype(action_type, guild)
  File "redbot/core/modlog.py", line 699, in get_casetype
    casetype = CaseType.from_json(name, data)
  File "redbot/core/modlog.py", line 466, in from_json
    return cls(name=name, **data, **kwargs)
TypeError: type object got multiple values for keyword argument 'name'
The `name` key used to be set in the Config for casetypes. Resolves this traceback: ``` Traceback (most recent call last): File "discord/ext/commands/core.py", line 79, in wrapped ret = await coro(*args, **kwargs) File "redbot/cogs/mod/kickban.py", line 223, in ban user=user, ctx=ctx, days=days, reason=reason, create_modlog_case=True File "redbot/cogs/mod/kickban.py", line 114, in ban_user channel=None, File "redbot/core/modlog.py", line 647, in create_case case_type = await get_casetype(action_type, guild) File "redbot/core/modlog.py", line 699, in get_casetype casetype = CaseType.from_json(name, data) File "redbot/core/modlog.py", line 466, in from_json return cls(name=name, **data, **kwargs) TypeError: type object got multiple values for keyword argument 'name' ```
palmtree5 (Migrated from github.com) reviewed 2019-07-10 13:48:17 +02:00
Flame442 (Migrated from github.com) requested changes 2019-07-12 23:48:39 +02:00
Flame442 (Migrated from github.com) left a comment

I made a case (by hackbanning a random person), ran [p]modlogset resetcases, then tried to do [p]case 1. Rather than saying "That case does not exist for that server", it errored with the following error:

Exception in command 'case'
Traceback (most recent call last):
  File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\redbot\cogs\modlog\modlog.py", line 106, in case
    await ctx.send(embed=await case.message_content(embed=True))
  File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\redbot\core\modlog.py", line 207, in message_content
    filter_invites(f"{self.user} ({self.user.id})")
AttributeError: 'NoneType' object has no attribute 'id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\discord\ext\commands\bot.py", line 863, in invoke
    await ctx.command.invoke(ctx)
  File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\discord\ext\commands\core.py", line 728, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\discord\ext\commands\core.py", line 88, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'

This error does not appear following the same steps on my current 3.1.2 bot. All case numbers error after clearing cases (so [p]case 222 also throws an error), but when a new case is created that number works as normal.

I made a case (by hackbanning a random person), ran `[p]modlogset resetcases`, then tried to do `[p]case 1`. Rather than saying "That case does not exist for that server", it errored with the following error: ```py Exception in command 'case' Traceback (most recent call last): File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped ret = await coro(*args, **kwargs) File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\redbot\cogs\modlog\modlog.py", line 106, in case await ctx.send(embed=await case.message_content(embed=True)) File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\redbot\core\modlog.py", line 207, in message_content filter_invites(f"{self.user} ({self.user.id})") AttributeError: 'NoneType' object has no attribute 'id' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\discord\ext\commands\bot.py", line 863, in invoke await ctx.command.invoke(ctx) File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\discord\ext\commands\core.py", line 728, in invoke await injected(*ctx.args, **ctx.kwargs) File "c:\users\flame\desktop\random\testingredbot\reddev\venv\lib\site-packages\discord\ext\commands\core.py", line 88, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id' ``` This error does not appear following the same steps on my current 3.1.2 bot. All case numbers error after clearing cases (so `[p]case 222` also throws an error), but when a new case is created that number works as normal.
Tobotimus commented 2019-07-13 02:02:09 +02:00 (Migrated from github.com)

@Flame442 I believe that should be a separate issue, it's unrelated to this PR. Was likely caused by the ModLog config redesign PR.

@Flame442 I believe that should be a separate issue, it's unrelated to this PR. Was likely caused by the ModLog config redesign PR.
mikeshardmind (Migrated from github.com) approved these changes 2019-07-13 02:15:41 +02: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!2848
No description provided.