Skip to content

Commit

Permalink
Merge pull request #7 from Zalk0/dev
Browse files Browse the repository at this point in the history
Merge dev modifs to main
  • Loading branch information
Zalk0 authored Mar 11, 2024
2 parents b889811 + bded668 commit d333624
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
15 changes: 4 additions & 11 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def __init__(self):
# Declare command tree
self.tree = discord.app_commands.CommandTree(self)

# Variable for storing owners id
# If set manually, it will not fetch from the bot's application info
self.owners = []

# Used to check the first time the bot does the on_ready event
self.first = True

Expand Down Expand Up @@ -115,13 +111,10 @@ async def on_message(self, message: discord.Message):
self.bot_logger.info(f'{self.user} responded to {author}: "{response[0]}"')

async def is_team_member_or_owner(self, author: discord.User) -> bool:
if not self.owners:
app_info = await self.application_info()
if app_info.team:
self.owners = [member.id for member in app_info.team.members]
else:
self.owners = [app_info.owner.id]
return author.id in self.owners
if self.application.team:
return author.id in self.application.team.members
else:
return author.id == self.application.owner.id

# Add a basic HTTP server to check if the bot is up
async def start_server(self):
Expand Down
40 changes: 14 additions & 26 deletions commands/skyblock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import re
from datetime import datetime, timezone
from typing import TYPE_CHECKING

Expand All @@ -27,38 +26,27 @@ def __init__(self):
)
async def mods(self, interaction: discord.Interaction[ChouetteBot]):
await interaction.response.defer(thinking=True)
api_github = "https://api.github.com/repos/"
api_github = "https://api.github.com/repos"
api_modrinth = "https://api.modrinth.com/v2"
async with aiohttp.ClientSession() as session:
async with session.get(
f"{api_github}Dungeons-Guide/Skyblock-Dungeons-Guide/releases/latest"
f"{api_github}/Dungeons-Guide/Skyblock-Dungeons-Guide/releases/latest"
) as response:
dungeonsguide = await response.json()
async with session.get(
f"{api_github}NotEnoughUpdates/NotEnoughUpdates/releases"
) as response:
notenoughupdates = await response.json()
async with session.get(
f"{api_github}Fix3dll/SkyblockAddons/contents/gradle.properties",
headers={"Accept": "application/vnd.github.raw"},
) as response:
content = await response.text()
sba_version = re.search(r"^version\s?=\s?(.*)$", content, re.MULTILINE)
async with session.get(f"{api_github}Fix3dll/SkyblockAddons/actions/runs") as response:
content = await response.json()
for run in content["workflow_runs"]:
if run["head_branch"] == "main" and run["conclusion"] == "success":
skyblockaddons = f"{sba_version.group(1)}+{run['run_number']}"
break
async with session.get(f"{api_github}Skytils/SkytilsMod/releases/latest") as response:
async with session.get(f"{api_modrinth}/project/GGamhqbw/version") as response:
notenoughupdates = (await response.json())[0]
async with session.get(f"{api_modrinth}/project/F35D4vTL/version") as response:
skyblockaddons = (await response.json())[0]
async with session.get(f"{api_github}/Skytils/SkytilsMod/releases/latest") as response:
skytils = await response.json()
await interaction.followup.send(
f"The latest releases are:\n"
f"- Dungeons-Guide: `{dungeonsguide['tag_name']}` "
"The latest releases are:\n"
f"- Dungeons-Guide: `{dungeonsguide['tag_name'].replace('v', '')}` "
f"[link]({dungeonsguide['assets'][0]['browser_download_url']})\n"
f"- NotEnoughUpdates: `{notenoughupdates[0]['tag_name'].replace('v', '')}` "
f"[link]({notenoughupdates[0]['assets'][0]['browser_download_url']})\n"
f"- SkyblockAddons (forked by Fix3dll): `{skyblockaddons}` "
f"[link](https://nightly.link/Fix3dll/SkyblockAddons/workflows/build/main/build_artifacts.zip)\n"
f"- NotEnoughUpdates: `{notenoughupdates['version_number']}` "
f"[link]({notenoughupdates['files'][0]['url']})\n"
f"- SkyblockAddons (forked by Fix3dll): `{skyblockaddons['name'].split('-')[1]}` "
f"[link]({skyblockaddons['files'][0]['url']})\n"
f"- Skytils: `{skytils['tag_name'].replace('v', '')}` "
f"[link]({skytils['assets'][0]['browser_download_url']})"
)
Expand Down

0 comments on commit d333624

Please sign in to comment.