【发布时间】:2021-10-01 22:14:56
【问题描述】:
我有这段代码来检测某人的活动何时设置为流式传输,但是按照我所做的方式(我相当确定有更好的方法),我不确定如何检测它何时是不再设置为流式传输并移除角色。
@client.event
async def on_member_update(before, after):
game = [i for i in after.activities if str(i.type) == "ActivityType.streaming"]
if game:
channel = client.get_channel(848003612121628682)
guild = client.get_guild(762352010463936523)
role = discord.utils.find(lambda r: r.name == 'Live!', guild.roles)
await after.add_roles(role)
await channel.send("<@427155509129379851> someone live")
print(game[0].name)
print(f'{after.name}')
【问题讨论】:
标签: python discord discord.py