【发布时间】:2020-08-26 12:44:00
【问题描述】:
我制作了一个通过 webhook 发送嵌入的脚本,它工作得很好,但我正在尝试将其转换为通过机器人发送到同一个频道。我似乎无法弄清楚(我以前从未使用过该机器人来发送嵌入内容。)
async def start(keyword):
SOME CODE HERE
await embeded(channel)
async def embeded(channel):
# Discord Embed Setup
embed = Embed(
description=f"[**eBay Link**]({eBayLink})",
color=0x0d0d22,
timestamp='now' # sets the timestamp to current time
)
embed.set_author(name=Titles)
embed.add_field(name='Average', value=Averages, inline=True)
embed.add_field(name='Lowest', value=Lowests, inline=True)
embed.add_field(name='Highest', value=Highests, inline=True)
embed.add_field(name='Margin', value=Margins, inline=True)
embed.add_field(name='Postage', value=Postages, inline=True)
embed.set_footer(text='TEST', icon_url='IMAGE')
embed.set_thumbnail(image.get_attribute('src'))
await channel.send(embed=embed)
print("Embed sent to discord!")
@client.event
async def on_ready():
print("Bot is online!")
@client.event
async def on_message(message):
if message.content.startswith('!flip '):
keyword = message.content.split('!flip ')[1]
await start(keyword, channel)
client.run(token)
我得到了错误
await start(keyword, channel)
NameError: name 'channel' is not defined
【问题讨论】:
-
您要将嵌入发送到哪里?
-
发出命令的同一频道
标签: python discord.py