Discord.py:on_member_join突然停止工作

时间:2020-10-18 06:17:38

标签: python discord.py

我正在尝试以下代码:

@app.post("/refresh-token", response_model=schema.Token)
def refresh_token(request: schema.TokenItem, dbs: Session = Depends(get_db)):

    refresh_token = request.refresh_token
    # print('refresh_data', refresh_data)

    token_user = crud.get_access_from_refresh_token(dbs, refresh_token = refresh_token)

    login_token = dependencies.create_login_token(user = token_user, refresh_token = refresh_token)

    return login_token

def get_access_from_refresh_token(db: Session, refresh_token: str):
    # print('in get access token', refresh_token)

    payload = jwt.decode(refresh_token, settings.SECRET_KEY, algorithms=[settings.ALGORITHM])
    token_data = schema.TokenPayload(**payload)
    token_user = get_user(db, user_id=token_data.sub)

    return token_user

def create_login_token(user: models.User, refresh_token: str):
    access_token_expires = timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES)
    userdata = {
        'user_id': user.id,
        'email': user.email,
        'provider_type': user.provider_type,
        'is_active': user.is_active,
        'is_super_user': user.is_super_user
    }

    access_token = security.create_access_token(
        user.id, expires_delta=access_token_expires
    )

    return {
        "access_token": access_token,
        "refresh_token": refresh_token,
        "token_type": "bearer",
        "user": userdata
    }

我以前的@bot.event async def on_member_join(member): print("works") for channel in member.guild.text_channels: if channel.name == 'general': await channel.send("Welcome to " + member.guild.name + ", " + member + "!") 事件运行正常,但是由于某种原因,它不再可用。我试图更新到discord.py 1.5。任何帮助将不胜感激。

我没有任何错误。

1 个答案:

答案 0 :(得分:1)

<div id="emojiTable"></div> 1.5.0现在支持discord API的Privileged Gateway Intent。为了能够利用服务器数据,您需要:

enter image description here

Server Members Intent