您如何制作一个机器人,在几秒钟后,在Discord.py中删除了受欢迎的嵌入并删除嵌入的嵌入
这是我的代码,但似乎不起作用。我很抱歉,但我仍然是新手,但是,我非常感谢您的帮助和批评者。
import discord
from discord.ext import commands
client = commands.Bot(command_prefix=prefix,
intents=discord.Intents.all())
@client.event
async def on_message_join(member):
channel = client.get_channel(channelid)
count = member.guild.member_count
embed=discord.Embed(title=f"Welcome to {member.guild.name}", description=f"Hello there {member.name}!", footer=count)
embed.set_thumbnail(url=member.avatar_url)
await channel.send(embed=embed)
time.sleep(5)
message.delete(embed)
Here's my code but it seems like it doesn't work. I'm so sorry but, I'm still a newbie but, I would very much appreciate your help and critics.
import discord
from discord.ext import commands
client = commands.Bot(command_prefix=prefix,
intents=discord.Intents.all())
@client.event
async def on_message_join(member):
channel = client.get_channel(channelid)
count = member.guild.member_count
embed=discord.Embed(title=f"Welcome to {member.guild.name}", description=f"Hello there {member.name}!", footer=count)
embed.set_thumbnail(url=member.avatar_url)
await channel.send(embed=embed)
time.sleep(5)
message.delete(embed)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正确的不符合事件是抓住一个人加入您的不和谐的是:
而不是
on_message_join
轻松删除您可以首先使其成为字符串的消息:
然后获取ID:然后获取它:
然后删除它:
将其删除:
The correct discord event to catch that a person joins your discord is:
rather than
on_message_join
To easily delete the message you can first make it a string:
then get it's id by:
then fetch it:
then delete it:
只需使用
delete_after =秒
,这是您想要的Just use
delete_after=seconds
, this exactly what's your wanted根据,您可以在5秒后编辑消息对象,然后将新的
嵌入
参数设置为无
,这似乎是您在这里追求的。以下是您可以更改代码执行此操作的方式。
除非您要删除整个消息,否则您只需使用
delete_after
即可获得此消息。According to the discord.py docs, you could edit the message object after 5 seconds and then just set the new
embed
parameter toNone
, this seems to be what you're after here.Below is a way you can alter your code to do this.
Unless you want the entire message deleted, then you can just use
delete_after
in order to obtain this.