Discord.py服务器启动事件

2024-05-04 06:00:21 发布

您现在位置:Python中文网/ 问答频道 /正文

如果一个新的消息提升了服务器,比如一个服务器得到提升的事件或者类似的事情,有没有一种发送消息的方法

@commands.Cog.listener()
async def server_get_boosted(self, member):
    print(str(member))

像这样的东西


Tags: 方法self服务器消息getasyncserverdef
2条回答

没有直接的方法可以做到这一点。这不是对discord.py的限制,Discord API根本不提供这样的事件

但是,硝基助推器会自动分配一个不可撤销的“硝基助推器”角色,您可以查询该角色作为解决方法

您可以通过检查用户在on_member_update事件中是否有一个新角色——“硝基助推器一号”来实现这一点

资料来源:this feature request

没有专门在服务器boost上发送的事件

但是,当发送服务器boost消息时,会触发on_message事件。消息将具有MessageTypepremium_guild_subscription

所以你可以这样说:

@client.event
async def on_message(message):
    if message.type == discord.MessageType.premium_guild_subscription:
        print(str(message.author))

资料来源:

MessageType

premium_guild_subscription

相关问题 更多 >