laggron42 / Laggrons-Dumb-Cogs

Cogs for Red-DiscordBot made by Laggron
https://discord.gg/WsTGeQM
GNU General Public License v3.0
53 stars 51 forks source link

Running massban on another bot, causes Failed to create a case based on manual ban #163

Closed Skyridr closed 3 years ago

Skyridr commented 3 years ago

I'm not sure if this is related because I ran a massban command on a second RED bot, but for some reason this error popped up in my logs:

[2021-04-18 20:34:46] [ERROR] red.laggron.warnsystem: [Guild 714561624215781530] Failed to create a case based on manual ban. Member: May#0342 (381997401545768962). Author: TWDS Test Bot#1109 (532254555287846923). Reason: Action requested by Skyrider#1337 (ID 133631162894516225).
Traceback (most recent call last):
  File "/home/twds/twds/cogs/CogManager/cogs/warnsystem/warnsystem.py", line 1418, in on_member_ban
    await self.api.warn(
  File "/home/twds/twds/cogs/CogManager/cogs/warnsystem/api.py", line 1089, in warn
    fails = [await warn_member(x, audit_reason) for x in members if x]
  File "/home/twds/twds/cogs/CogManager/cogs/warnsystem/api.py", line 1089, in <listcomp>
    fails = [await warn_member(x, audit_reason) for x in members if x]
  File "/home/twds/twds/cogs/CogManager/cogs/warnsystem/api.py", line 916, in warn_member
    if level > 1 and guild.me.top_role.position <= member.top_role.position:
AttributeError: 'User' object has no attribute 'top_role'

Case does seem to be created when I run massban (core command) on the main bot in a specified channel, but not the same happens if I use my alt bot also with the exact same command. Is it because the bot (alt) is not a user?

I take it it's not specific to massban alone, but thus far the only thing that popped up in my logs.

laggron42 commented 3 years ago

Hmm, I think it's because WarnSystem is setup to create a modlog case when a manual kick or ban is done. Not sure why this is happening, will look into it.

monty-dev commented 3 years ago

if level > 1 and guild.me.top_role.position <= member.top_role.position

By the time WarnSystem sees the ban, the user has left therefore its not a discord.Member is a discord.User. I'll push a PR in a moment.