mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-09 12:48:54 -05:00
Remove unused try except blocks in modlog.create_case() usage (#4095)
This commit is contained in:
parent
0cc04706f6
commit
6cef336417
@ -56,7 +56,6 @@ class Events(MixinMeta):
|
|||||||
"Failed to ban member for mention spam in server {}.".format(guild.id)
|
"Failed to ban member for mention spam in server {}.".format(guild.id)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -68,9 +67,6 @@ class Events(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
print(e)
|
|
||||||
return False
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
return _("An unexpected error occurred.")
|
return _("An unexpected error occurred.")
|
||||||
|
|
||||||
if create_modlog_case:
|
if create_modlog_case:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -128,11 +127,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
return _(
|
|
||||||
"The user was banned but an error occurred when trying to "
|
|
||||||
"create the modlog entry: {reason}"
|
|
||||||
).format(reason=e)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -230,7 +224,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -242,8 +235,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("Done. That felt good."))
|
await ctx.send(_("Done. That felt good."))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@ -415,7 +406,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
else:
|
else:
|
||||||
banned.append(user_id)
|
banned.append(user_id)
|
||||||
|
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -427,8 +417,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
errors["0"] = _("Failed to create modlog case: {reason}").format(reason=e)
|
|
||||||
await show_results()
|
await show_results()
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@ -499,7 +487,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
await ctx.send(_("Something went wrong while banning."))
|
await ctx.send(_("Something went wrong while banning."))
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -510,8 +497,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
reason,
|
reason,
|
||||||
unban_time,
|
unban_time,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("Done. Enough chaos for now."))
|
await ctx.send(_("Done. Enough chaos for now."))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@ -585,7 +570,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
"{}({}) softbanned {}({}), deleting 1 day worth "
|
"{}({}) softbanned {}({}), deleting 1 day worth "
|
||||||
"of messages.".format(author.name, author.id, user.name, user.id)
|
"of messages.".format(author.name, author.id, user.name, user.id)
|
||||||
)
|
)
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -597,8 +581,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("Done. Enough chaos."))
|
await ctx.send(_("Done. Enough chaos."))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@ -635,7 +617,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
await ctx.send(_("Something went wrong while attempting to kick that member."))
|
await ctx.send(_("Something went wrong while attempting to kick that member."))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -647,8 +628,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=case_channel,
|
channel=case_channel,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@ -677,7 +656,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
await ctx.send(_("Something went wrong while attempting to unban that user."))
|
await ctx.send(_("Something went wrong while attempting to unban that user."))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -689,8 +667,6 @@ class KickBanMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("Unbanned that user from this server."))
|
await ctx.send(_("Unbanned that user from this server."))
|
||||||
|
|
||||||
if await self.config.guild(guild).reinvite_on_unban():
|
if await self.config.guild(guild).reinvite_on_unban():
|
||||||
|
|||||||
@ -103,7 +103,6 @@ class MuteMixin(MixinMeta):
|
|||||||
|
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
author = ctx.author
|
author = ctx.author
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -115,8 +114,6 @@ class MuteMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("User is now allowed to speak and listen in voice channels"))
|
await ctx.send(_("User is now allowed to speak and listen in voice channels"))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@ -147,7 +144,6 @@ class MuteMixin(MixinMeta):
|
|||||||
await ctx.send(_("That user is already muted and deafened server-wide!"))
|
await ctx.send(_("That user is already muted and deafened server-wide!"))
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -159,8 +155,6 @@ class MuteMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("User has been banned from speaking or listening in voice channels"))
|
await ctx.send(_("User has been banned from speaking or listening in voice channels"))
|
||||||
|
|
||||||
@commands.group()
|
@commands.group()
|
||||||
@ -190,7 +184,6 @@ class MuteMixin(MixinMeta):
|
|||||||
success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
|
success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -202,8 +195,6 @@ class MuteMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=channel,
|
channel=channel,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("Muted {user} in channel {channel.name}").format(user=user, channel=channel)
|
_("Muted {user} in channel {channel.name}").format(user=user, channel=channel)
|
||||||
)
|
)
|
||||||
@ -237,7 +228,6 @@ class MuteMixin(MixinMeta):
|
|||||||
success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
|
success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -249,8 +239,6 @@ class MuteMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=channel,
|
channel=channel,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await channel.send(_("User has been muted in this channel."))
|
await channel.send(_("User has been muted in this channel."))
|
||||||
else:
|
else:
|
||||||
await channel.send(issue)
|
await channel.send(issue)
|
||||||
@ -270,7 +258,6 @@ class MuteMixin(MixinMeta):
|
|||||||
success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
|
success, issue = await self.mute_user(guild, channel, author, user, audit_reason)
|
||||||
mute_success.append((success, issue))
|
mute_success.append((success, issue))
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -282,8 +269,6 @@ class MuteMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("User has been muted in this server."))
|
await ctx.send(_("User has been muted in this server."))
|
||||||
|
|
||||||
@commands.group()
|
@commands.group()
|
||||||
@ -316,7 +301,6 @@ class MuteMixin(MixinMeta):
|
|||||||
success, message = await self.unmute_user(guild, channel, author, user, audit_reason)
|
success, message = await self.unmute_user(guild, channel, author, user, audit_reason)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -328,8 +312,6 @@ class MuteMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=channel,
|
channel=channel,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("Unmuted {user} in channel {channel.name}").format(user=user, channel=channel)
|
_("Unmuted {user} in channel {channel.name}").format(user=user, channel=channel)
|
||||||
)
|
)
|
||||||
@ -363,7 +345,6 @@ class MuteMixin(MixinMeta):
|
|||||||
success, message = await self.unmute_user(guild, channel, author, user, audit_reason)
|
success, message = await self.unmute_user(guild, channel, author, user, audit_reason)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
guild,
|
guild,
|
||||||
@ -375,8 +356,6 @@ class MuteMixin(MixinMeta):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=channel,
|
channel=channel,
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("User unmuted in this channel."))
|
await ctx.send(_("User unmuted in this channel."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("Unmute failed. Reason: {}").format(message))
|
await ctx.send(_("Unmute failed. Reason: {}").format(message))
|
||||||
@ -398,19 +377,9 @@ class MuteMixin(MixinMeta):
|
|||||||
success, message = await self.unmute_user(guild, channel, author, user, audit_reason)
|
success, message = await self.unmute_user(guild, channel, author, user, audit_reason)
|
||||||
unmute_success.append((success, message))
|
unmute_success.append((success, message))
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot, guild, ctx.message.created_at, "sunmute", user, author, reason, until=None,
|
||||||
guild,
|
|
||||||
ctx.message.created_at,
|
|
||||||
"sunmute",
|
|
||||||
user,
|
|
||||||
author,
|
|
||||||
reason,
|
|
||||||
until=None,
|
|
||||||
)
|
)
|
||||||
except RuntimeError as e:
|
|
||||||
await ctx.send(e)
|
|
||||||
await ctx.send(_("User has been unmuted in this server."))
|
await ctx.send(_("User has been unmuted in this server."))
|
||||||
|
|
||||||
async def mute_user(
|
async def mute_user(
|
||||||
|
|||||||
@ -480,7 +480,6 @@ class Warnings(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
if not dm_failed:
|
if not dm_failed:
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
try:
|
|
||||||
reason_msg = _(
|
reason_msg = _(
|
||||||
"{reason}\n\nUse `{prefix}unwarn {user} {message}` to remove this warning."
|
"{reason}\n\nUse `{prefix}unwarn {user} {message}` to remove this warning."
|
||||||
).format(
|
).format(
|
||||||
@ -502,8 +501,6 @@ class Warnings(commands.Cog):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@ -615,7 +612,6 @@ class Warnings(commands.Cog):
|
|||||||
current_point_count -= user_warnings[warn_id]["points"]
|
current_point_count -= user_warnings[warn_id]["points"]
|
||||||
await member_settings.total_points.set(current_point_count)
|
await member_settings.total_points.set(current_point_count)
|
||||||
user_warnings.pop(warn_id)
|
user_warnings.pop(warn_id)
|
||||||
try:
|
|
||||||
await modlog.create_case(
|
await modlog.create_case(
|
||||||
self.bot,
|
self.bot,
|
||||||
ctx.guild,
|
ctx.guild,
|
||||||
@ -627,7 +623,5 @@ class Warnings(commands.Cog):
|
|||||||
until=None,
|
until=None,
|
||||||
channel=None,
|
channel=None,
|
||||||
)
|
)
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user