mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-08 12:18:54 -05:00
Handle users leaving the server while we're applying mutes (#3627)
* Handle when users leave a server while we're applying mutes Goddamn guilds with >100 text channels >.< * Damn you tox. * Damn you Bread. * Fixed a bug whereby Guild would always return a success Also handled error checking on NotFound so that the propper handling can be done. * Fixed flake8 compile error (whoops) * Revert "Fixed flake8 compile error (whoops)" This reverts commit ec8b67234733c6812defaa7ca2abeab3794292ad. * Revert "Fixed a bug whereby Guild would always return a success" This reverts commit 8d08ac31af4387e6a1757b4a2e97add55f8633c1. * Apply the lost commits that we actually want Since cherry picking is hard. * Isn't the English language FUN!? * *sigh*
This commit is contained in:
parent
279f0e4f6c
commit
ea3ca66303
@ -22,6 +22,8 @@ mute_unmute_issues = {
|
||||
"permission and the user I'm muting must be "
|
||||
"lower than myself in the role hierarchy."
|
||||
),
|
||||
"left_guild": _("The user has left the server while applying an overwrite."),
|
||||
"unknown_channel": _("The channel I tried to mute the user in isn't found."),
|
||||
}
|
||||
_ = T_
|
||||
|
||||
@ -422,6 +424,11 @@ class MuteMixin(MixinMeta):
|
||||
await channel.set_permissions(user, overwrite=overwrites, reason=reason)
|
||||
except discord.Forbidden:
|
||||
return False, _(mute_unmute_issues["permissions_issue"])
|
||||
except discord.NotFound as e:
|
||||
if e.code == 10003:
|
||||
return False, _(mute_unmute_issues["unknown_channel"])
|
||||
elif e.code == 10009:
|
||||
return False, _(mute_unmute_issues["left_guild"])
|
||||
else:
|
||||
await self.settings.member(user).set_raw(
|
||||
"perms_cache", str(channel.id), value=old_overs
|
||||
@ -460,6 +467,11 @@ class MuteMixin(MixinMeta):
|
||||
await channel.set_permissions(user, overwrite=overwrites, reason=reason)
|
||||
except discord.Forbidden:
|
||||
return False, _(mute_unmute_issues["permissions_issue"])
|
||||
except discord.NotFound as e:
|
||||
if e.code == 10003:
|
||||
return False, _(mute_unmute_issues["unknown_channel"])
|
||||
elif e.code == 10009:
|
||||
return False, _(mute_unmute_issues["left_guild"])
|
||||
else:
|
||||
await self.settings.member(user).clear_raw("perms_cache", str(channel.id))
|
||||
return True, None
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user