嵌入中的超链接不起作用 (discord.py)

Hyperlinks in an Embed not working (discord.py)

这里有一个棘手的问题...

我有一个字典列表 (top_x_games),我正在循环并将其中的某些元素添加到字符串中。问题是 [here](your_link_goes_here) discord 语法用于在消息中添加可点击的 link 似乎不起作用。这适用于单个字符串的情况,所以我不确定为什么它不在这里。

description2 = ""
for game in top_x_games:
        description2 += f"#{game['rank']}) [{game['name']}]({steam_api.get_game_url(game['name'])}) with f"{(game['player_count'])} players\n"

结果的一个例子是这样的,其中 10 个中随机有 2 个正确地超link url 到 {game['name']} 值,但其他人没有: see screenshot

如有任何帮助或建议,我们将不胜感激!

这是因为使用 steam_api.get_game_url 生成的 URL 包含空格。 URl 不能包含空格,因此 Discord 不会将它们格式化为超链接。

您的问题与 Discord 或 discord.py 无关。