嵌入命令不会发送,所有其他嵌入都会发送

时间:2019-04-16 09:48:20

标签: python discord discord.py

尽管所有其他Embed都正常工作,并且这是直接复制和粘贴,但是“ await bot.send_message(ctx.message.channel,embed = embed)”一直在日志中发送错误,但我不明白它。大多数人都称“ Bot”为客户

我已经尝试过使用bot.say()来查看通道是否是问题所在,并且我已经尝试过重新排列embed语句以声明尽可能靠近发送方的位置。代码中的所有其他嵌入几乎都使用相同的格式,几乎没有任何更改,我什至将其粘贴粘贴以使其准确无误。我尝试注释掉它的所有部分,可能导致它的唯一部分是add_field语句之一或初始设置,但是我之前已经使用过。

                title = "Rock Paper Scissors", 
                description = ctx.message.author.name, 
                color = discord.Color.red()
            )

            if(winner == "tie"):

                embed.set_thumbnail(url = "//https://i.imgur.com/RcnDdIR.png")
                embed.add_field(name= "Winner", value= "It was a tie! Both chose " + choice + "!", inline=False)
                embed.add_field(name= "Chips", value= users[ctx.message.author.id]["chips"], inline=False)

                await bot.send_message(ctx.message.channel, embed=embed)
                economy["rps"]["played"] += 1

                print (ctx.message.author.name + " Played Rock Paper Scissors, but tied")

                f = open(logname, "a")
                f.write(ctx.message.author.name + " Played Rock Paper Scissors, but tied\n")
                f.close()

"THE ERROR CODE
The Casiino is open
Running on Casiino
ID: 566778084175642635
Wildcard Played Rock Paper Scissors, but tied
Ignoring exception in command rps
Traceback (most recent call last):
  File "C:\Users\cjwil\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\cjwil\Desktop\casiino\bot.py", line 479, in rps
    await bot.send_message(ctx.message.channel, embed=embed)
  File "C:\Users\cjwil\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 1152, in send_message
    data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
  File "C:\Users\cjwil\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 200, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\cjwil\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\cjwil\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\cjwil\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: BAD REQUEST (status code: 400)"```

"I want The embed to send without any issues and without throwing errors."

1 个答案:

答案 0 :(得分:0)

It looks like users[ctx.message.author.id]["chips"] is a Member object. Try explicitly getting its string representation to use in the embed:

embed.add_field(name= "Chips", value=str(users[ctx.message.author.id]["chips"]), inline=False)