Jump to content

Developments in ChatGPT in developing Discord bots for Politics and War


Parapet
 Share

Recommended Posts

Good morning/afternoon/whatever,

I have come to announce perhaps the creation of the first Discord bot that specifically uses the Politics and War API that was created entirely using ChatGPT. For those of you who are unaware, ChatGPT is an online free to use AI that can do various things when prompted with instructions. A few weeks ago, I became interested in ChatGPT after seeing its extensive usage by people online who are a lot smarter than me. So, I started to wonder if this technology could potentially bridge the technological gap between those who can code and those who cannot. After creating such an account, I quickly discovered that the bot was aware of the Politics and War API and it seemed to vaguely understand it. That is when I embarked on a personal project to see if somehow or someway, I could get ChatGPT to create a basic discord bot that functions with the API and most importantly, that bot had to function without the need for any amount debugging. To get to the point, the results are very promising to say the least. While ChatGPT struggled extensively with it trying to use old imports for Discord bots, I eventually figured out a prompt for it to create a bot for a primitive discord bot that grabbed basic nation information. There are no other features. This is the culmination of just under 8 hours of tinkering and playing around with various prompts. The following is the exact prompt that was used for this proof-of-concept bot. 
 

Quote

Create a discord bot that uses the politicsandwar.com API network to create a lists the city count, score, war policy, soldiers, tanks, aircraft, ships, missiles, and nukes of a nation in an embedded and also uses import interactions but does not use discord_slash but does not use a prefix. Should be able to go /nation to do the command. does not use discord_components that uses intents

This prompt created the following code output, I have of course omitted my API key and the token. Should work as so: /nation (Nation ID here)
import discord
import requests

client = discord.Client(intents=discord.Intents.all())

@client.event
async def on_ready():
    print('Logged in as {0.user}'.format(client.user))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('/nation'):
        nation_id = message.content.split(' ')[1]
        response = requests.get(f'https://politicsandwar.com/api/nation/id={nation_id}&key=API_KEY')
        if response.status_code == 200:
            nation = response.json()
            nation_info = (
                f'**Nation:** {nation["name"]}\n'
                f'**City count:** {nation["cities"]}\n'
                f'**Score:** {nation["score"]}\n'
                f'**War policy:** {nation["war_policy"]}\n'
                f'**Soldiers:** {nation["soldiers"]}\n'
                f'**Tanks:** {nation["tanks"]}\n'
                f'**Aircraft:** {nation["aircraft"]}\n'
                f'**Ships:** {nation["ships"]}\n'
                f'**Missiles:** {nation["missiles"]}\n'
                f'**Nukes:** {nation["nukes"]}'
            )
            embed = discord.Embed(title="Nation Info", description=nation_info, color=0x00ff00)
            await message.channel.send(embed=embed)
        else:
            await message.channel.send('Error retrieving nation information.')

client.run('TOKEN')

This code output when assuming the token and API key is done correctly of course does the following:
image.png

While compared to the behemoth of Locutus or any other half respectable Discord bot with more than an ounce of work, it is not that impressive. However, what is impressive is the fact that not a single human developed the code for this PNW Discord bot to work. Is it a milestone? I don't know. Nor do I know the road ahead for this technology. I don't even know if I am the first one to do this with the PNW API and ChatGPT specifically. But I present it wide open to the world of PNW to get the message out there that this is possible now. I see the gap in technology that exists in PNW as a major filter that alliances must overcome. I commend Borg and other various players for doing such fantastic work on making technology as accessible as possible to address this gap in capability. But despite this, there still exists a development gap between macro alliance technology and micro alliance technology generally speaking (Not true however for all macros or micros, just broadly speaking here). But I also acknowledge the limitations that such AI currently has as well as it was a struggle to put it lightly just getting this very basic script to pop out and successfully to run all in one go without any debugging. However, I am also a firm believer that this technology will only get better given enough time. As such, the question remains of what happens here? Well, I suspect knowing this community that many of you will range from being skeptical to calling me an outright moron for even posting these findings here. While I say true, this isn't exactly revolutionary, I do think this is something that is worth reporting on and publishing for the public eye to see. While I think we are far ways away from ChatGPT replacing all of PNW coders, I do think it is something that is worth investigating and/or keeping an eye on. I also know for a fact that knowing how many smart people there are in this community, I have no doubts that someone else will make better use of it than I have. But this does make me excited to see what is coming and to see what clever ways people use this for. Go wild. Cheers. 
 
 


 

  • Like 4
  • Upvote 1

New_project.gifcf0bd5053f8f832e358f460636c6065443cf1c9a
For legal reasons any statement I make is always alleged

Link to comment
Share on other sites

Put this in Orbis Central. This is an Orbis Central worthy post.

  • Like 1

TCM3_1_281x175.png.d5f909d45f36d3dcb3722580e7b7ecc2.png
Coal Duke (Imperator Emeritus) of The Coal Mines
Diety Emeritus of The Immortals, Patres Conscripti (President Emeritus) of the Independent Republic of Orange Nations, Lieutenant Emeritus of Black Skies, Imperator Emeritus of the Valyrian Freehold, Imperator Emeritus of the Divine Phoenix, Prefect Emeritus of Carthago, Regent Emeritus of the New Polar Order

 

Link to comment
Share on other sites

Screw a follow up post lets do it now. After less than a half an hours work I present yet another breakthrough. I now bring the ability for all to be able to collect publicly information of alliances on mass. Thanks to ChatGPT and my testing, I now present a functional example by which ChatGPT can create a script that uses PNW API to create a detailed sheet of every nation in a particular alliance. Have fun. Simply put in the alliance ID you want then put in your API key. Easy as pie. 

 

Quote

Create a python script that uses the politicsandwar.com API network to create a lists the city count, score, war policy, soldiers, tanks, aircraft, ships, missiles, nukes, missilelpad, nuclearresfac, iron dome, vitaldefsys, propaganda bureau, spy satellite and pirate economy, of a all nations inside a specified alliance and compile it into a spreadsheet using an integer index and compensate for missing values

import requests
import pandas as pd

# Enter your alliance ID and API key below
alliance_id = "8900"
api_key = "API_KEY_HERE"

# Define a function to return a value or "N/A" if the value is missing
def get_value_or_na(data, key):
    value = data.get(key)
    if value is None:
        return "N/A"
    else:
        return value

# Fetch the list of nations in the alliance
url = f"https://politicsandwar.com/api/nations/?alliance_id={alliance_id}&key={api_key}"
response = requests.get(url)
if response.status_code == 200:
    nations = response.json()
    if isinstance(nations, str):
        print("Error fetching nations:", nations)
        exit()
    nation_ids = [nation["nationid"] for nation in nations["nations"]]
else:
    print("Error fetching nations:", response.text)
    exit()

# Fetch the nation data for each nation
nation_data = []
for nation_id in nation_ids:
    url = f"https://politicsandwar.com/api/nation/id={nation_id}&key={api_key}"
    response = requests.get(url)
    if response.status_code == 200:
        nation = response.json()
        nation_info = {
            "name": get_value_or_na(nation, "name"),
            "nationid": get_value_or_na(nation, "nationid"),
            "cities": get_value_or_na(nation, "cities"),
            "score": get_value_or_na(nation, "score"),
            "war_policy": get_value_or_na(nation, "war_policy"),
            "projects": get_value_or_na(nation, "projects"),
            "soldiers": get_value_or_na(nation, "soldiers"),
            "tanks": get_value_or_na(nation, "tanks"),
            "aircraft": get_value_or_na(nation, "aircraft"),
            "ships": get_value_or_na(nation, "ships"),
            "missiles": get_value_or_na(nation, "missiles"),
            "nukes": get_value_or_na(nation, "nukes"),
            "missilelpad": get_value_or_na(nation, "missilelpad"),
            "nuclearresfac": get_value_or_na(nation, "nuclearresfac"),
            "iron_dome": get_value_or_na(nation, "iron_dome"),
            "vitaldefsys": get_value_or_na(nation, "vitaldefsys"),
            "prop_bureau": get_value_or_na(nation, "prop_bureau"),
            "spy_satellite": get_value_or_na(nation, "spy_satellite"),
            "pirate_economy": get_value_or_na(nation, "pirate_economy")
        }
        nation_data.append(nation_info)
    else:
        print("Error fetching nation data:", response.text)

# Create a Pandas DataFrame with the nation data
df = pd.DataFrame(nation_data, columns=["name", "nationid", "cities", "score", "war_policy", "projects", "soldiers", "tanks", "aircraft", "ships", "missiles", "nukes", "missilelpad", "nuclearresfac", "iron_dome", "vitaldefsys", "prop_bureau", "spy_satellite", "pirate_economy"])

# Write the DataFrame to a spreadsheet
filename = f"{alliance_id}_nation_data.xlsx"
df.to_excel(filename, index=False)
print(f"Nation data written to {filename}")

The above prompt made the code below and created the output below.
image.png?width=1010&height=910
This is yet another example of how ChatGPT can help micros close the gap in terms of technology when compared to the larger macros they have to compete with. I post this here to show you while there are some funky things with this, wither either changes to the prompt or a half decent coder, one can make this into a very functional sheet. 
 

  • Upvote 3

New_project.gifcf0bd5053f8f832e358f460636c6065443cf1c9a
For legal reasons any statement I make is always alleged

Link to comment
Share on other sites

This is actually more interesting than the time I asked ChatGPT to go into the kitchen and get us something to eat.

Which to be fair ended with my doorbell ringing and a sandwich delivery from Subway along with a can of motor oil with a straw in it.    

Tech is amazing.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and the Guidelines of the game and community.