试图跟踪 roblox 用户名是否在组中,如果是,他的角色是什么,但它不起作用并告诉我他不在组中

问题描述 投票:0回答:0
API_URL = "https://groups.roblox.com/v2/groups/{}/roles"

@client.event
async def on_message(message):
    if message.content.startswith('!info'):
        inputs = message.content.split(' ')
        group_link = inputs[1]
        roblox_username = inputs[2]
        
        # Extract group ID from group link
        group_id = re.findall(r'\d+', group_link)[0]
        
        await message.channel.send(f"Getting information for {roblox_username} in Group {group_id}...")
        
        # Get group roles for the specified user
        response = requests.get(API_URL.format(group_id), params={"userIds": roblox_username})
        data = response.json()
        
        group_info = []
        if 'data' in data:
            user = data['data'][0]['user']
            for role in user['roles']:
                role_name = role['name']
                group_info.append(f"**{role_name}** in Group {group_id}")
            
        if not group_info:
            group_info.append(f"{roblox_username} is not in Group {group_id}")
        
        embed = discord.Embed(title=f"Roblox Information for {roblox_username} in Group {group_id}", color=0x00ff00)
        embed.add_field(name="Group Membership", value="\n".join(group_info), inline=False)
        
        await message.channel.send(embed=embed)

says that im not in the group

im actually in the group

我希望实际工作,并且知道用户名存在并且在组中并且具有角色

告诉我我做错了什么并给我发送修改后的代码使其工作谢谢

discord discord.py roblox
© www.soinside.com 2019 - 2024. All rights reserved.