函数不返回embed discord.py

函数不返回embed discord.py,discord.py,Discord.py,我对函数有问题: 为了避免在我决定创建这个函数时为每个字符串重写相同的100个字符串,该函数将返回嵌入,但不幸的是,它没有返回相同的字符串。 我没有错误,所以我不明白问题出在哪里 代码功能: def rob_true(): ratm=随机。随机范围(50500) 经济系统[id\U其他][“钱包”]-=ratm 如果经济型系统[id\U其他][“钱包”]

我对函数有问题: 为了避免在我决定创建这个函数时为每个字符串重写相同的100个字符串,该函数将返回嵌入,但不幸的是,它没有返回相同的字符串。 我没有错误,所以我不明白问题出在哪里

代码功能:

def rob_true():
ratm=随机。随机范围(50500)
经济系统[id\U其他][“钱包”]-=ratm
如果经济型系统[id\U其他][“钱包”]<0:
负数钱包=经济型钱包系统[id\U其他][“钱包”]
ratm=ratm+负电荷
经济型系统[id\U其他][“钱包”]=0
经济系统[id\U作者][“钱包”]+=ratm
如果ratm<100:
嵌入=不和谐。嵌入(
title=“Rob!”,
description=f“非sei stato molto FORTUNAO.\nHai rubato solo{ratm}€a{other.name}”,
颜色=0x03c03c
)
embed.set_作者(
name=f“{ctx.author.name}”,
icon_url=f“{ctx.author.avatar_url}”
)
嵌入.set_缩略图(url=ctx.guild.icon_url)
如果100
全部代码:

@client.command()
async def rob_(ctx, other: discord.Member=None):
    #PRE-INIZIO: Primissime cose che deve fare il comando prima di iniziare, di solito cancellare se si vuole il messaggio del comando.
    await ctx.message.delete()
    id_author = str(ctx.author.id)
    #ERRORI: Settaggio dei vari errori che darà il comando se non viene eseguito perfettamente.
    embed = discord.Embed(
        color=0xa61022
    )
    if not other:
        embed.set_author(
            name="Per favore specifica la persona che vuoi rubare!",
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return
    id_other = str(other.id)
    if id_author not in economy_system:
        embed.set_author(
            name=f"{ctx.author.name} prima di accedere a questo comando devi creare un account!"
        )
        await ctx.send(embed=embed, delete_after=10)
        await client.get_command("superdaily").reset_cooldown(ctx)
        return
    if id_other not in economy_system:
        embed.set_author(
            name=f"{other.name} non ha un account!"
        )
        await ctx.send(embed=embed, delete_after=10)
        return
    #INSERIMENTO: Qui iniziamo a definire le variabili che serviranno al nostro comando
    template = [
        ("1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", 0, 1, 0, 3, 2, 0,)
    ]
    reac1, reac2, reac3, reac4, reac5, reac6, res1, res2, res3, res4, res5, res6 = random.choice(template)
    print(reac1, reac2, reac3, reac4, reac5, reac6, res1, res2, res3, res4, res5, res6)
    count = 0
    value = 0
    if res1 == 1:
        value1 = reac1
    if res2 == 1:
        value1 = reac2
    if res3 == 1:
        value1 = reac3
    if res4 == 1:
        value1 = reac4
    if res5 == 1:
        value1 = reac5
    if res6 == 1:
        value1 = reac6
    if res1 == 2:
        value2 = reac1
    if res2 == 2:
        value2 = reac2
    if res3 == 2:
        value2 = reac3
    if res4 == 2:
        value2 = reac4
    if res5 == 2:
        value2 = reac5
    if res6 == 2:
        value2 = reac6
    if res1 == 3:
        value3 = reac1
    if res2 == 3:
        value3 = reac2
    if res3 == 3:
        value3 = reac3
    if res4 == 3:
        value3 = reac4
    if res5 == 3:
        value3 = reac5
    if res6 == 3:
        value3 = reac6
    print(value1, value2, value3)
    #USCITA: Da qui tutte il comando verrà eseguito con tutte le azioni che vogliamo, questa parte può essere la più lunga
    embed = discord.Embed(
        title="Rob!",
        description="Per rubare dei soldi bisogna essere veloci senza farsi scoprire!\nCerto non saprai se ruberai tanto o poco ma l'importante è non farsi sgamare!\n\nHai 5 secondi di tempo per cliccare 3 reazione nel seguente ordine scritte su **status**\n__N.B Il tempo partirà non appena lo status ti darà le 3 reazioni__\n**STATUS**: Aggiungendo le reazioni...",
        color=0x003399
    )
    embed.set_author(
        name=f"{ctx.author.name}",
        icon_url=f"{ctx.author.avatar_url}"
    )
    embed.set_thumbnail(url=ctx.guild.icon_url)
    message = await ctx.send(embed=embed)
    await message.add_reaction(reac1)
    await message.add_reaction(reac2)
    await message.add_reaction(reac3)
    await message.add_reaction(reac4)
    await message.add_reaction(reac5)
    await message.add_reaction(reac6)
    embed = discord.Embed(
        title="Rob!",
        description=f"**STATUS**:\n {value1}  **->**  {value2} **->** {value3}",
        color=0x003399
    )
    embed.set_author(
        name=f"{ctx.author.name}",
        icon_url=f"{ctx.author.avatar_url}"
    )
    embed.set_thumbnail(url=ctx.guild.icon_url)
    await message.edit(embed=embed)
    def rob_check(reaction, user):
        return user == ctx.author and str(reaction.emoji) in [reac1, reac2, reac3, reac4, reac5, reac6]
    def rob_true():
        #inserted above
    #def rob_false()
    while True:
        try:
            reaction, user = await client.wait_for("reaction_add", timeout=5, check=rob_check)
            if str(reaction.emoji) == reac1:
                count = count + 1
                if count == 1:
                    if res1 == 1:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 2:
                    if res1 == 2:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 3:
                    if res1 == 3:
                        rob_true()
                        return
                    else:
                        await message.delete()
                        return
            if str(reaction.emoji) == reac2:
                count = count + 1
                if count == 1:
                    if res2 == 1:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 2:
                    if res2 == 2:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 3:
                    if res2 == 3:
                        rob_true()
                        return
                    else:
                        await message.delete()
                        return
            if str(reaction.emoji) == reac3:
                count = count + 1
                if count == 1:
                    if res3 == 1:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 2:
                    if res3 == 2:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 3:
                    if res3 == 3:
                        rob_true()
                        return
                    else:
                        await message.delete()
                        return
            if str(reaction.emoji) == reac4:
                count = count + 1
                if count == 1:
                    if res4 == 1:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 2:
                    if res4 == 2:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 3:
                    if res4 == 3:
                        if economy_system[id_other]["wallet"] == 0:
                            embed = discord.Embed(
                                title="Rob!",
                                description=f"{other.name} non ha nulla quindi non guadagni nulla!",
                                color=0xa61022
                            )
                            embed.set_author(
                                name=f"{ctx.author.name}",
                                icon_url=f"{ctx.author.avatar_url}"
                            )
                            embed.set_thumbnail(url=ctx.guild.icon_url)
                            await message.edit(embed=embed)
                            return
                        rob_true()
                        await ctx.send(embed=embed)
                        _save()
                        return
                    else:
                        await message.delete()
                        return
            if str(reaction.emoji) == reac5:
                count = count + 1
                if count == 1:
                    if res5 == 1:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 2:
                    if res5 == 2:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 3:
                    if res5 == 3:
                        rob_true()
                        return
                    else:
                        await message.delete()
                        return
            if str(reaction.emoji) == reac6:
                count = count + 1
                if count == 1:
                    if res6 == 1:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 2:
                    if res6 == 2:
                        value = value + 1
                    else:
                        await message.delete()
                        return
                if count == 3:
                    if res6 == 3:
                        rob_true()
                        return
                    else:
                        await message.delete()
                        return
        except asyncio.TimeoutError:
            print("ok")
            break
代码现在还不完整,我只是测试这个函数,不幸的是它给了我这个错误。 有什么办法可以解决吗


注意:我问这个问题是因为我在任何地方都没有找到它,我认为它在将来可能会很有用。这可能是因为您只是返回嵌入,而不是发送它。因此,每次调用
rob_true()
,您都需要通过执行
wait ctx.send(embed=rob_true())
(代替调用
rob_true()
)发送返回的嵌入。

在第7行(整个代码)中没有标题
embed=discord.embed(color=0xa61022)
。另外,请尝试编写一个简单的代码,我们不想阅读所有的行。这与标题有什么关系?事情是一样的。如果代码很长,否则您将无法理解任何内容。