gpt4 book ai didi

python - 防止消息作者使用命令 Discord.py 提及自己

转载 作者:太空宇宙 更新时间:2023-11-04 09:40:02 27 4
gpt4 key购买 nike

试图阻止用户在使用 rob 命令时提及自己。我尝试了 if message.author == user.mention 但它不起作用。

   if message.content.startswith('!rob'):
try:
if message.author == user.mention:
await client.send_message(message.channel, "{} you cant rob yourself! 👊".format(message.author.mention))
except:
pass
else:
if get_dollars(message.author) < 0:
await client.send_message(message.channel, "{} you can't even afford a gun!".format(message.author.mention))
finally:
for user in message.mentions:
if (get_dollars(user)) < 25:
await client.send_message(message.channel, "{} is too broke to rob 🤣".format(user.mention))
elif steal == 1:
print("{} catches {} slippin and sticks them up for ${} 😨🔫".format(message.author.mention, user.mention, stealdollars))
await client.send_message(message.channel, "{} catches {} slippin and sticks them up for ${} 😨🔫".format(message.author.mention, user.mention, stealdollars))
remove_dollars(user, stealdollars)
add_dollars(message.author, stealdollars)
elif steal == 2:
print("{} gets arrested trying to rob {} and has to post $250 bail 👮🚨".format(message.author.mention, user.mention))
await client.send_message(message.channel, "{} gets arrested trying to rob {} and has to post $250 bail 👮🚨".format(message.author.mention, user.mention))
remove_dollars(message.author, 250)
elif steal >= 3:
print("{} kicks {}'s door down but doesn't find any cash 🤬".format(message.author.mention, user.mention))
await client.send_message(message.channel, "{} kicks {}'s door down but doesn't find any cash 🤬".format(message.author.mention, user.mention))

最佳答案

你可以做类似的事情

if message.author in message.mentions:

关于python - 防止消息作者使用命令 Discord.py 提及自己,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52090022/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com