【发布时间】:2022-02-03 02:15:54
【问题描述】:
我试图弄清楚如何从我的 Discord 机器人发送的消息中删除嵌入。开个玩笑,我做了一个机器人来“审查”某些链接,但这并不意味着,机器人会重新发布链接本身。假设来自机器人的任何消息中只有一个链接,我该如何防止发生链接嵌入,或者让机器人立即删除嵌入?
不是this question 的重复,因为我不知道链接是什么,所以我不能只找到某个子字符串并在其周围加上尖括号。
我的代码如下:
if any(substring in message.content.lower() for substring in ["www.example.com", "www.wikipedia.com"]):
msg = await message.channel.send(f"{message.author.mention} is out of line!"
f"\n> {message.content}\nThis misdeed has been noted, "
"and future transgressions will result in severe penalties.")
# remove embeds here?
await message.delete()
(此外,如果有更好的方法来执行if 语句,请告诉我。)
【问题讨论】:
标签: python python-3.x discord discord.py