Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions integration_bot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ async def usersync_self(self, interaction: discord.Interaction) -> None:
token = login()
teams = get_teams_with_users(token)
await assign_roles_to_member(interaction.user, teams, True)
await interaction.followup.send("✅ User sync for yourself completed successfully.")
await interaction.followup.send("✅ User sync for yourself completed successfully.", ephemeral = True)
except AttributeError:
await interaction.followup.send(f"❌ Error during user sync: You must execute this command in a server channel.", ephemeral = True)
except Exception as e:
await interaction.followup.send(f"❌ Error during user sync for yourself: {str(e)}")
await interaction.followup.send(f"❌ Error during user sync for yourself: {str(e)}", ephemeral = True)

@app_commands.command(name='cleanupteams', description="Nettoie les rôles, salons et retire le rôle 'Nouveau'")
async def cleanupteams(self, interaction: discord.Interaction) -> None:
Expand Down
4 changes: 4 additions & 0 deletions integration_bot/utils/login.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import os
import requests
import urllib3

# Disable SSL warnings when verify=False is used
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

def login() -> str:
api_url:str = os.getenv("API_URL") + "/auth/login"
Expand Down
3 changes: 3 additions & 0 deletions integration_bot/utils/teams.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
import requests

# Disable SSL warnings when verify=False is used
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

def get_teams_with_factions(token: str) -> list:
url = os.getenv("API_URL") + "/team/admin/teamswithfactions"
headers = {"Authorization": f"Bearer {token}"}
Expand Down
8 changes: 6 additions & 2 deletions integration_bot/utils/users.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import os
import logging
import requests

# Disable SSL warnings when verify=False is used
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

def get_teams_with_users(token: str) -> list:
url = os.getenv("API_URL") + "/team/admin/teamswithusers"
headers = {"Authorization": f"Bearer {token}"}
print(f"[FETCH] Fetching teams with users...")
logging.info(f"[FETCH] Fetching teams with users...")
response = requests.get(url, headers=headers, verify=False)
if response.status_code == 200:
data = response.json().get('data', [])
print(f"[FETCH] Retrieved {len(data)} teams.")
logging.info(f"[FETCH] Retrieved {len(data)} teams.")
return data
else:
print(f"[FETCH] Failed to fetch teams. Status: {response.status_code}, Response: {response.text}")
Expand Down