【发布时间】:2021-10-14 00:32:37
【问题描述】:
我最近一直在尝试这样做,以便当有人键入特定命令时,机器人会删除他们的消息。我之前尝试过的一切都不起作用,所以我完全不知道该怎么做。我是 discord.py 的新手,所以我的知识非常有限。
#making sure the command only works in the specific channel
async def is_channel(ctx):
return ctx.channel.id == 873501773971726346
#the actual code
@client.command(case_sensitive=True)
@commands.check(is_channel)
async def resus(ctx,*, saymsg=None):
if saymsg==None:
return await ctx.send("To reserve a username type - !resus (your discord tag) (the username you want) (if you want verification) You can also add some extra information if you would like. Any spam/troll reservations will result in a warning and or mute.")
sayEmbed = discord.Embed(title=f"{ctx.author.name} Said", color = discord.Color.blue(), description=f"{saymsg}")
sayEmbed.timestamp = ctx.message.created_at
channelf = client.get_channel(873564203535958047)
await channelf.send(embed = sayEmbed)
【问题讨论】:
-
只用
await ctx.message.delete()? -
@Dominik 谢谢,但我是不是把它放在删除用户的消息上?
标签: python python-3.x discord.py