Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

python - Discord.py Trying to take multiple things from and Api and put them into a single Embed

So rn in the api i have it search for an entries with a certain name and get all the following info. All the info gets put into a single embed then it goes onto the next one i want all the entries to fit into 1 embed and Multipler Feilds any help would be Appreciated.

API:http://arkdedicated.com/xbox/cache/unofficialserverlist.json

    @commands.command(name="xbu", aliases=["xboxunofficial"])
    async def xbu(self, ctx, *, name):
        response = requests.get("http://arkdedicated.com/xbox/cache/unofficialserverlist.json")
        data = response.json()
        keys = ["Name", "IP", "Port", "NumPlayers", "DayTime", "MapName", "DayTime"]
        for item in data:
            if name.lower() in item["Name"].lower():
                embed = discord.Embed(color=GLOBAL)
                embed.add_field(name='Name: ', value=f'{item["Name"]}', inline=False)
                embed.add_field(name='Map: ', value=f'{item["MapName"]}', inline=True)
                embed.add_field(name='Day:',value=f'{item["DayTime"]}', inline=True)
                embed.add_field(name='Players: ', value=f'{item["NumPlayers"]}', inline=True)
                embed.add_field(name='IP: ', value=f'{item["IP"]}', inline=False)
                embed.add_field(name='Port: ', value=f'{item["Port"]}', inline=False)
                await ctx.send(embed=embed)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...