无法从MongoDB中提取信息

2024-05-04 02:47:14 发布

您现在位置:Python中文网/ 问答频道 /正文

每次尝试从数据库中提取有关用户的信息都会返回None

我的代码:

@bot.command()
async def warnings(ctx, user:discord.Member = None):
    client = MongoClient('connection')
    db = client.gettingStarted
    collection = db.Warning
    if user == None:
        await ctx.send('Please give a valid user')
    else:
        x = collection.find_one({"id":f"{user.id}"})
        print(x)

有什么问题吗