Discord.py disable pinging


if "USER ID" in user_message.lower(
) and username != "Ticket Tool" and "Jack PA " not in username:
await message.delete()
await message.channel.send(
f'{username} Please do not ping the owners they are very busy. nIf you need them open a ticket in 📩︱open-a-ticket'
)

如何禁用角色和用户ID的ping ?我是否也可以让我的管理员/管理团队可以ping我,它不会删除

既然您似乎已经有了发送消息的用户的对象,根据Discord API文档,您可以使用ctx.guild.get_member(user_id)来获取消息发送者的成员对象。然后,该对象拥有一个名为"角色"的属性;其中列出消息发送方所属的所有角色。然后,您可以根据允许的角色id检查这些,如果用户不在任何允许的角色中,则删除消息。

关于第二个问题,你的user对象已经拥有一个名为"id"即发送用户的用户ID。只需将其与允许的用户列表进行比较。

最新更新