Не работает антибот система discord.py

Всем привет! Недавно сделал анти-бот систему но включение работает но отключение не работает. То-есть при отключении бот должен перестать кикать других ботов которых добавляют, но бот все равно кикает.

@bot.command()
@commands.has_permissions(administrator=True)
@commands.cooldown(1, 35, commands.BucketType.guild)
async def antibots(ctx, arg):
    with open('antibots.json','r') as f:
        key = json.load(f)
    if arg == "on":
        key[f"{ctx.guild.id}"]=str("on")
        await ctx.channel.send(embed=discord.Embed(title="Анти Бот система", description=":yess: **АНТИ-БОТ** успешно включен.", color=0x2F3136))
    elif arg == "off":
        key[f"{ctx.guild.id}"]=str("off")
        embed = discord.Embed(title="Анти Бот система", description=":yess: **АНТИ-БОТ** успешно выключен.", color=0x2F3136)
    else: 
        embed = discord.Embed(title="Ошибочка", description="напиши `on` или  `off` чтобы включить или выключить")
    await ctx.send(embed=embed)
    
    with open('antibots.json','w',encoding='utf-8') as f:
        json.dump(key,f,indent=4,ensure_ascii=False)
@bot.event
async def on_member_join(member):
    if (member.bot):
        with open('antibots.json', 'r') as f:
            key = json.load(f)
        if f'{member.guild.id}' not in key:
            pass
        else:
            print(f"{member.name} кикнут | АНТИ-БОТ СИСТЕМА")
            await member.kick()

Ответы (0 шт):