2 回答
TA贡献1893条经验 获得超10个赞
尝试使用
for activity in member.activities: print(type(activity), activity)
查看每个活动的实例类型和活动,这样您就可以看到实际需要匹配的内容:
TA贡献1810条经验 获得超5个赞
我能够确定我应该使用哪种类型的活动,对于自定义状态,使用的类型是CustomActivity,对于丰富的存在游戏,我只是使用了一个声明else。
代码:
for activity in member.activities:
if isinstance(activity, Game):
name = activity.name
Type = "Playing"
Activity = f"{name}"
elif isinstance(activity, Streaming):
name2 = activity.name
name3 = activity.platform
Type = "Streaming"
Activity = f"{name2} on {name3}"
elif isinstance(activity, Spotify):
name4 = activity.title
name5 = activity.artists
Type = "Listening to Spotify"
Activity = f"**Song Name**:{name4}\n**Song Artists:**{name5}"
elif isinstance(activity, CustomActivity):
name6 = activity.name
Type = "Custom Status"
Custom = f"{name6}"
else:
name7 = activity.name
Type = "Playing"
Activity = f"{name7}"
添加回答
举报