Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arma_get_players working #120

Merged
merged 5 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
small fixes
  • Loading branch information
Karlish-git committed Mar 23, 2024
commit ab22228fe13eda99cf2d9c1220daa375ac5083f8
35 changes: 19 additions & 16 deletions src/commands/arma_get_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import pandas as pd


async def get_players():
"""
Gets the list of players that have played on the Arma server.
Expand All @@ -18,9 +19,9 @@ async def get_players():
url = f"https://{host}/attendance"

headers = {
'content-type': "application/json",
'x-apikey': api_key,
'cache-control': "no-cache"
"content-type": "application/json",
"x-apikey": api_key,
"cache-control": "no-cache",
}

# Open asynchronous HTTP session and get the collection of players.
Expand All @@ -37,11 +38,20 @@ async def get_players():

# Prepare the data for a pandas DataFrame.
for x, y in enumerate(records):
new_records.append((y["Profile_Name"], y["Missions_Attended"],
y["Date_Of_Last_Mission"].split("T")[0], y["Steam_UID"]))

df = pd.DataFrame(new_records, index=None,
columns=("Name", "Missions Attended", "Last Seen", "Steam UID"))
new_records.append(
(
y["Profile_Name"],
y["Missions_Attended"],
y["Date_Of_Last_Mission"].split("T")[0],
y["Steam_UID"],
)
)

df = pd.DataFrame(
new_records,
index=None,
columns=("Name", "Missions Attended", "Last Seen", "Steam UID"),
)

return f"```{df.to_string(index=False)}\nTotal Players Tracked: {len(df)}```"

Expand All @@ -56,14 +66,7 @@ class ArmAGetDB(commands.Cog):
"""

@commands.slash_command(dm_permission=True)
async def arma(self, inter):
pass

@arma.sub_command()
async def get_players(
self,
inter: disnake.ApplicationCommandInteraction
):
async def arma_get_players(self, inter: disnake.ApplicationCommandInteraction):
"""
Display a list of players that have played on the Arma server.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ async def on_connect():
# everything below here will only run on the first connect

try:

logging.info("Connected to Discord. Initializing Database.")
await init_database(get_mongo_uri(), "FUBot")
except Exception as e:
Expand All @@ -67,6 +66,7 @@ async def on_connect():
bot.load_extension("commands.squad_markup")
bot.load_extension("commands.ps2_lookup")
bot.load_extension("commands.arma_upload_map")
bot.load_extension("commands.arma_get_db")
# bot.load_extension("loggers.discord_logger")
# bot.load_extension("loggers.ps2_outfit_members")
# bot.load_extension("loggers.ps2_outfit_online_logger")
Expand Down