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

[ModLog] Prevent duplicate kwarg error #2848

Conversation

Tobotimus
Copy link
Member

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.

Signed-off-by: Toby Harradine <[email protected]>
@Tobotimus Tobotimus added this to the 3.1.3 milestone Jul 10, 2019
@Tobotimus Tobotimus requested a review from palmtree5 as a code owner July 10, 2019 11:48
Copy link
Member

@Flame442 Flame442 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Signed-off-by: Toby Harradine <[email protected]>
@Tobotimus
Copy link
Member Author

@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 mikeshardmind merged commit e34eca5 into Cog-Creators:V3/develop Jul 13, 2019
@Tobotimus Tobotimus deleted the V3/bugfix/modlog_duplicate_kwarg branch July 13, 2019 01:35
@Jackenmen Jackenmen added the Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing. label Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants