我正在开发一个应用程序Bot,该机器人在DM中询问问题并保存答案。我只有一个小问题,那就是我想在嵌入的指定通道中发送答案。但是我找不到其他方法,而不是用await applychannel.send(embed=Embed)
来做,但这不起作用,它会打印一个错误。
错误:
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:\Users\itzbe\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "C:\Users\itzbe\Desktop\Discord\Bot\Python Test Object\cogs\command.py", line 85, in on_raw_reaction_add
await applychannel.send(embed=Embed)
AttributeError: 'NoneType' object has no attribute 'send'
@commands.Cog.listener()
async def on_raw_reaction_add(self, payload):
messageID = payload.message_id
if messageID == 736553190853574769:
def check(m):
return m.author == payload.member and m.guild is None and not payload.member.bot
applychannel = self.client.get_channel(736553190853574769)
frage1 = 'Wie heißt du in Reallife?'
frage2 = 'Wie heißt du auf Discord?'
frage3 = 'Wie lautet dein Name auf Epic?'
frage4 = 'Wie alt bist du?'
frage5 = 'Wie viele Arena-Punkte hast du?'
frage6 = 'Hast du Preisgelder gewonnen?'
frage7 = 'Für welches Team bewirbst du dich?'
if payload.emoji.name == '?':
await payload.member.send(frage1)
answer1 = await self.client.wait_for('message', check=check)
await payload.member.send(frage2)
answer2 = await self.client.wait_for('message', check=check)
await payload.member.send(frage3)
answer3 = await self.client.wait_for('message', check=check)
await payload.member.send(frage4)
answer4 = await self.client.wait_for('message', check=check)
await payload.member.send(frage5)
answer5 = await self.client.wait_for('message', check=check)
await payload.member.send(frage6)
answer6 = await self.client.wait_for('message', check=check)
await payload.member.send(frage7)
answer7 = await self.client.wait_for('message', check=check)
YesOrNo = await payload.member.send('Fertig! Bist du sicher, dass du deine Bewerbung abschicken willst?')
await YesOrNo.add_reaction('✅')
await YesOrNo.add_reaction('❌')
try:
reaction, user = await self.client.wait_for("reaction_add", timeout=60.0, check=lambda reaction, user: self.client.user != user)
if str(reaction.emoji) == '✅':
Embed = discord.Embed(
title=f'Bewerbung von {payload.member}',
color=discord.Colour.lighter_grey(),
timestamp=datetime.utcnow(),
description=f'**{frage1}** \n {answer1.content} \n\n '
f'**{frage2}** \n {answer2.content} \n\n '
f'**{frage3}** \n {answer3.content} \n\n '
f'**{frage4}** \n {answer4.content} \n\n'
f'**{frage5}** \n {answer5.content} \n\n'
f'**{frage6}** \n {answer6.content} \n\n'
f'**{frage7}** \n {answer7.content} \n\n'
)
await applychannel.send(embed=Embed)
await payload.member.send('Gesendet! Wir werden uns in denn naechsten 48 Studen melden, falls nicht bitte melde dich im Support!')
return
except asyncio.TimeoutError:
await payload.member.send('Bewerbung wurde unterbrochen!')
else:
await payload.member.send('Bewerbung wurde unterbrochen!')
答案 0 :(得分:0)
出现该错误的原因是
applychannel = self.client.get_channel(736553190853574769)
返回一个NoneType
对象。它返回None
的原因是因为736553190853574769
是无效的频道ID。要解决此问题,请尝试找到正确的频道ID,然后它应该可以正常工作。