more error logic

master
michael 2020-07-21 20:46:56 -07:00
parent f99c6df770
commit 20dca04361
1 changed files with 31 additions and 21 deletions

10
bot.py
View File

@ -227,6 +227,7 @@ async def mute(ctx, target_user:discord.User):
muting_users.remove(target_user) muting_users.remove(target_user)
if vote_passed: if vote_passed:
try:
# Add to muted_users # Add to muted_users
muted_users.append(target_user) muted_users.append(target_user)
# add temp. role for mute, edit role position to take precedence over other roles # add temp. role for mute, edit role position to take precedence over other roles
@ -249,6 +250,8 @@ async def mute(ctx, target_user:discord.User):
# Remove from muted_users # Remove from muted_users
muted_users.remove(target_user) muted_users.remove(target_user)
except discord.ext.commands.errors.CommandInvokeError:
await error_admin_targeted(ctx)
@bot.command() @bot.command()
async def kick(ctx, target_user:discord.User): async def kick(ctx, target_user:discord.User):
@ -265,7 +268,10 @@ async def kick(ctx, target_user:discord.User):
vote_passed = await take_vote(ctx, "Kick `{}`?".format(target_user), KICK_VOTE_TIME, MIN_KICK_VOTERS) vote_passed = await take_vote(ctx, "Kick `{}`?".format(target_user), KICK_VOTE_TIME, MIN_KICK_VOTERS)
if vote_passed: if vote_passed:
try:
await ctx.guild.kick(target_user) await ctx.guild.kick(target_user)
except discord.ext.commands.errors.CommandInvokeError:
await error_admin_targeted(ctx)
kicking_users.remove(target_user) kicking_users.remove(target_user)
@ -285,8 +291,12 @@ async def ban(ctx, target_user:discord.User):
vote_passed = await take_vote(ctx, "Ban `{}`?".format(target_user), BAN_VOTE_TIME, MIN_BAN_VOTERS) vote_passed = await take_vote(ctx, "Ban `{}`?".format(target_user), BAN_VOTE_TIME, MIN_BAN_VOTERS)
if vote_passed: if vote_passed:
try:
await ctx.guild.ban(target_user) await ctx.guild.ban(target_user)
await ctx.send(":crab: :crab: `{}` IS GONE :crab: :crab:".format(target_user.name)) await ctx.send(":crab: :crab: `{}` IS GONE :crab: :crab:".format(target_user.name))
except discord.ext.commands.errors.CommandInvokeError:
await error_admin_targeted(ctx)
banning_users.remove(target_user) banning_users.remove(target_user)