Fix reason variable shadowing in [p]massban (#4575)

This commit is contained in:
jack1142 2020-11-07 03:44:59 +01:00 committed by GitHub
parent 0089380bfd
commit a7ec40664e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -462,14 +462,15 @@ class KickBanMixin(MixinMeta):
# Call `ban_user()` method for all users that turned out to be guild members. # Call `ban_user()` method for all users that turned out to be guild members.
for user_id, member in members.items(): for user_id, member in members.items():
try: try:
success, reason = await self.ban_user( # using `reason` here would shadow the reason passed to command
success, failure_reason = await self.ban_user(
user=member, ctx=ctx, days=days, reason=reason, create_modlog_case=True user=member, ctx=ctx, days=days, reason=reason, create_modlog_case=True
) )
if success: if success:
banned.append(user_id) banned.append(user_id)
else: else:
errors[user_id] = _("Failed to ban user {user_id}: {reason}").format( errors[user_id] = _("Failed to ban user {user_id}: {reason}").format(
user_id=user_id, reason=reason user_id=user_id, reason=failure_reason
) )
except Exception as e: except Exception as e:
errors[user_id] = _("Failed to ban user {user_id}: {reason}").format( errors[user_id] = _("Failed to ban user {user_id}: {reason}").format(