diff --git a/cogs/event.py b/cogs/event.py index f313d19..9b2062a 100644 --- a/cogs/event.py +++ b/cogs/event.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python from discord.ext import commands from discord import app_commands from discord import Interaction diff --git a/config.py b/config.py index 4dec1bb..1bcdb97 100644 --- a/config.py +++ b/config.py @@ -10,9 +10,6 @@ class Config: ADMIN: str = os.getenv("ADMIN_ROLE") WEBOOK: str = os.getenv("WEBHOOK") - # MONGO_URI: str = os.getenv("MONGO_URI") - # MONGO_DBO: str = os.getenv("MONGO_DBO") - SFTP_HOST: str = os.getenv("SFTP_HOST") SFTP_PORT: int = int(os.getenv("SFTP_PORT")) SFTP_USERNAME: str = os.getenv("SFTP_USERNAME") diff --git a/main.py b/main.py index 56937e6..756d430 100644 --- a/main.py +++ b/main.py @@ -5,12 +5,13 @@ import asyncio from src.ReforgerStatsBot import ReforgerStats from config import Config -intents = Intents.default() -intents.message_content = True -bot = ReforgerStats(Config(), "!", intents) - async def main() -> None: + intents = Intents.default() + intents.message_content = True + bot = ReforgerStats(Config(), "!", intents) + async with bot: await bot.start(bot.config.TOKEN) -asyncio.run(main()) +if __name__ == "__main__": + asyncio.run(main()) diff --git a/test.py b/test.py deleted file mode 100644 index 53a7a34..0000000 --- a/test.py +++ /dev/null @@ -1,49 +0,0 @@ -import requests -import time - -webhook = "https://discord.com/api/webhooks/1307501649119543398/N-SWGPSTuvaPEk_u9v7WdMJqKASmk0o8EzvjTFDC_1mqDjqWGybSOVGU1iVDZ-LmBsNJ" - -identities = [ - {"gamertag": "what", "kills": 19, "deaths": 6}, - {"gamertag": "mcdazzzled", "kills": 52, "deaths": 11}, - {"gamertag": "erebus", "kills": 24, "deaths": 14} -] - -def createEmbed(players: list[dict]) -> dict: - sorted_players = sorted(players, key=lambda a: a["kills"], reverse=True) - description = "" - rank = 1 - for player in sorted_players: - description += f"> **{rank}.** {player['gamertag']}\n> ***Kills*** {player['kills']}\n> ***Deaths*** {player['deaths']}\n\n" - rank += 1 - - return { - "embeds": [{ - "title": "Leaderboard", - "description": description - }] - } - -def send(content: dict) -> str | None: - params = { "wait": True } - resp = requests.post(f"{webhook}", json=content, params=params) - return None if resp.status_code != 200 else resp.json()["id"] - -def delete(id: str) -> int: - return requests.delete(f"{webhook}/messages/{id}") - -def update(content: dict, id: str) -> int: - resp = requests.patch(f"{webhook}/messages/{id}", json=content) - return resp.status_code - -content = createEmbed(identities) -message_id = send(content) -if message_id is None: - print("failed") - exit() -print(identities[2]) -identities[0]["kills"] = 30 -time.sleep(4) -content = createEmbed(identities) -code = update(content, message_id) -print(code)