Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.7k 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...