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

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (34)

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

我已经尝试使用bot.say()来查看通道是否是问题,我已经尝试重新安排嵌入语句以尽可能接近发送声明。代码中的所有其他嵌入使用相同的格式,几乎没有任何更改,我甚至复制粘贴它以使其准确。我尝试评论它的所有部分,唯一可能导致它的部分是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."
提问于
用户回答回答于

它看起来像是users[ctx.message.author.id]["chips"]一个Member对象。尝试显式获取其在嵌入中使用的字符串表示形式:

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

扫码关注云+社区

领取腾讯云代金券