Discord.py-如何使“调情命令”真正起作用?

时间:2020-04-28 17:02:51

标签: discord.py

该命令有效,但是当您调情时将不会显示正确的消息。它只会显示您和别人调情时发送的消息。

@client.command()
async def flirt(ctx, *, user):
    flirts = ["I wish I was your mirror, so that I could look at you every morning.",
    "When I need a pick me up, I just think of your laugh and it makes me smile.",
    "Sweet dreams… I hope I’m in them.",
    "If I had a candy bar for every time I thought of you, I would be fat.",
    "My heart skips a beat every time I think of you. Or maybe it’s more of a somersault.",
    "For some reason every love song makes me think of you…",
    "It’s said that nothing lasts forever. Will you be my nothing?",
    "I’m lucky because I have plans for today, for tomorrow, for the week, and for my whole life—to make you happy.",
    " I don’t think about very many things, and I don’t think for very long, but when I do think, it invariably tends to be about you.",
    "It’s not my fault that I fell for you, you tripped me!",
    "I guess your parents are bakers, because they made you such a cutie pie!",
    "You might fall from a mountain, or you might fall from a tree, but the perfect way for you to fall, is to fall in love with me."]

    if user != ctx.message.author:
        await ctx.send(str(user) + ", " + str(ctx.message.author.mention) + " flirted with you! They said: \"" + random.choice(flirts) + "\"")
    elif user == ctx.message.author:
        await ctx.send(str(ctx.message.author.mention) + ", I flirted with you! I said: \"" + random.choice(flirts) + "\"")

1 个答案:

答案 0 :(得分:1)

您可以使用转换器从命令调用中获取User对象:

@client.command()
async def flirt(ctx, *, user: discord.User):
    if user != ctx.message.author:
        await ctx.send(f'{user.mention}, {ctx.message.author.mention} flirted with you! They said: "{random.choice(flirts)}"')
    elif user == ctx.message.author:
        await ctx.send(f'{ctx.message.author.mention}, I flirted with you! I said: "{random.choice(flirts)}"')