首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >检测Discord.py中的嵌入

检测Discord.py中的嵌入
EN

Stack Overflow用户
提问于 2021-03-29 09:48:37
回答 1查看 101关注 0票数 0

我正在尝试制作一个discord.py机器人,它将响应其他人发送的嵌入“拖延”、“拖延”和“拖延”之类的词语。我正在尝试使用一种方法,在这种方法中,机器人将,希望,检测到嵌入中的这些单词,并用“no u”回复所述嵌入。

这是我到目前为止的代码:

代码语言:javascript
运行
复制
import discord
import os

client = discord.Client()

@client.event
async def on_message(message):
     if text in message.content or any(embed_contains(embed, "procastination", "procasting", 
     "procrastination", "procrasting", "do") for embed in message.embeds):
         await message.channel.send("no u")

有没有更有效的方法来解决这个问题呢?

EN

回答 1

Stack Overflow用户

发布于 2021-03-29 10:02:34

您需要对示例代码进行一些调整才能完美执行,但以下是您可以尝试的内容:

代码语言:javascript
运行
复制
    async def on_message(self, message):
        # First check if the message contains an embed.
        if message.embeds:  # -> Returns a List[Embed]
            # Check to see if XXXX is in the embeds description/title etc.
            if 'XXXX' in message.embeds[0].description:
                ...  # Do what you want here
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66847834

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档