Answer the question
In order to leave comments, you need to log in
What is my mistake?
I can't figure out what's wrong. Help me please.
Error: SyntaxError: invalid syntax
Error in line
elif warns + 1 >= cursor.fetchone()[0]:
@commands.command()
@commands.has_permission(kick_members=True, ban_members=True)
async def warn(self, ctx, member: discord.abc.User, *reason):
member = ctx.guild.get_member(member.id)
cursor.execute(f"SELECT warns FROM guild_users_{ctx.guild.id} WHERE id = {member.id}")
warns = cursor.fetchone()[0]
if reason==[]:
txt('moderation.warn.no_reason', [], ctx)
if ctx.author==member:
await ctx.send(txt('moderation.warn.yourself', [], ctx))
elif Bot.user==member:
await ctx.send(txt('moderation.warn.me', [], ctx))
else:
cursor.execute(f"UPDATE guild_users_{ctx.guild.id} SET warns = {warns+1} WHERE id = {member.id}")
conn.commit()
cursor.execute(f"SELECT warn_ban FROM guilds_settings WHERE id = {ctx.guild.id}")
if warns + 1 >= cursor.fetchone()[0]:
await member.ban(reason=txt('moderation.warn.ban', [], ctx))
await ctx.send(txt('moderation.warn.ban.result', [str(member), str(ctx.author), reason, warns+1], ctx))
cursor.execute(f"SELECT warn_kick FROM guilds_settings WHERE id = {ctx.guild.id}")
elif warns + 1 >= cursor.fetchone()[0]:
await member.kick(reason=txt('moderation.warn.kick', [], ctx))
await ctx.send(txt('moderation.warn.kick.result', [str(member), str(ctx.author), reason, warns+1], ctx))
else:
await ctx.send(txt('moderation.warn.result', [str(member), str(ctx.author), reason, warns+1], ctx))
Answer the question
In order to leave comments, you need to log in
Before cursor.execute(f"SELECT warn_kick FROM guilds_settings WHERE id = {ctx.guild.id}") put a tab
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question