【发布时间】:2020-12-13 02:41:50
【问题描述】:
我正在制作一个不和谐的 ModMail 机器人,并且我已经做到了,当有人 dms 机器人时会打开一个频道,但发生的情况是,每次有人 DM 机器人时,它都会打开另一个频道。例如,如果我有一次向机器人发送 10 条消息的对话; 10 个不同的渠道将被打开。有人知道我怎样才能把它发送到现有的吗?我尝试过使用检查,但我不确定如何实施它们。这是我的代码:
async def on_message(message):
if message.author.id == client.user.id:
return
if message.author != message.author.bot:
await message.add_reaction('✅')
if not message.guild:
guild = client.get_guild(guild)
c = None
for channel in guild.text_channels: # check every channel
if channel.name == "❗ticket-{message.author.id}":
c = channel # channel found, stop looking
break
if c is None: # if no channel was found
c = await guild.create_text_channel('❗ticket-{message.author.id}')
embed = Embed(color=discord.Color.orange())
embed.add_field(name="**????ModMail Support????**",
value=f"User Mention: {message.author.mention}\nUsername: **{message.author}**\nUser-ID: **{message.author.id}**\n\n__**Content**__\n{message.content}")
await c.send(embed=embed)
提前非常感谢! :)
【问题讨论】:
-
那个代码没有任何意义
标签: discord.py discord.py-rewrite