python - 嵌入命令不会发送,所有其他嵌入都会发送
问题描述
尽管所有其他嵌入都在工作,而且这是直接复制和粘贴,但“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."
解决方案
它看起来像是users[ctx.message.author.id]["chips"]
一个Member
对象。尝试显式获取其字符串表示以在嵌入中使用:
embed.add_field(name= "Chips", value=str(users[ctx.message.author.id]["chips"]), inline=False)
推荐阅读
- c++ - c ++如何从排序内容中禁用向量迭代?
- javascript - 接受网络通知后,网站在浏览器没有打开该网站的标签时可以发送通知吗?
- mongodb - MongoDB:通过给定名称和用户名查询用户的最佳方式
- javascript - 模块是否会阻止使用 DOMContentLoaded 侦听器的需要?
- json - 有什么方法可以在 json 模式中定义总字符限制?
- android - 添加实现 'com.google.firebase:firebase-analytics:17.2.2' 使实现 'com.android.support:appcompat-v7:28.0.0' 用红色下划线
- c++ - 构建 TF micro hello world: make: *** [tensorflow/lite/micro/examples/hello_world/Makefile.inc:34: test_hello_world_test] 错误 1
- css - 如何在网格中放置画布圆形进度条?
- javascript - 即使我在不同的选项卡上,您能否在浏览器上以全性能运行 Javascript?
- unity3d - 有没有办法让对象只与 Unity 中的某些 Tilemap 发生碰撞?