generated from nhcarrigan/template
chore: lints
CI / dependency-pin-check-python (pull_request) Successful in 4s
CI / dependency-pin-check-typescript (pull_request) Successful in 4s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 55s
CI / python (pull_request) Successful in 9m25s
CI / typescript (pull_request) Successful in 9m46s
CI / dependency-pin-check-python (pull_request) Successful in 4s
CI / dependency-pin-check-typescript (pull_request) Successful in 4s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 55s
CI / python (pull_request) Successful in 9m25s
CI / typescript (pull_request) Successful in 9m46s
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Create private voice channels for each team in the specified category.
|
||||
"""Create private voice channels for each team in the specified category.
|
||||
Each channel will be visible and joinable only by the team's role.
|
||||
"""
|
||||
|
||||
import json
|
||||
import requests
|
||||
import time
|
||||
import os
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
# Discord configuration
|
||||
BOT_TOKEN = os.environ["DISCORD_BOT_TOKEN"]
|
||||
@@ -33,10 +32,8 @@ TEAMS = {
|
||||
"Sage Marigold": {"role_id": "1464315153599299803"},
|
||||
}
|
||||
|
||||
HEADERS = {
|
||||
"Authorization": f"Bot {BOT_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
HEADERS = {"Authorization": f"Bot {BOT_TOKEN}", "Content-Type": "application/json"}
|
||||
|
||||
|
||||
def create_voice_channel(team_name, role_id):
|
||||
"""Create a voice channel with specific permissions"""
|
||||
@@ -50,14 +47,14 @@ def create_voice_channel(team_name, role_id):
|
||||
"id": GUILD_ID, # @everyone role ID is same as guild ID
|
||||
"type": 0, # Role type
|
||||
"deny": "1049600", # VIEW_CHANNEL (1 << 10) + CONNECT (1 << 20) = 1049600
|
||||
"allow": "0"
|
||||
"allow": "0",
|
||||
},
|
||||
{
|
||||
"id": role_id, # Team role
|
||||
"type": 0, # Role type
|
||||
"allow": "1049600", # VIEW_CHANNEL + CONNECT
|
||||
"deny": "0"
|
||||
}
|
||||
"deny": "0",
|
||||
},
|
||||
]
|
||||
|
||||
data = {
|
||||
@@ -67,7 +64,7 @@ def create_voice_channel(team_name, role_id):
|
||||
"permission_overwrites": permission_overwrites,
|
||||
"user_limit": 0, # No user limit
|
||||
"bitrate": 64000, # 64 kbps
|
||||
"rtc_region": None # Auto-select region
|
||||
"rtc_region": None, # Auto-select region
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=HEADERS, json=data)
|
||||
@@ -82,9 +79,13 @@ def create_voice_channel(team_name, role_id):
|
||||
time.sleep(retry_after)
|
||||
return create_voice_channel(team_name, role_id)
|
||||
else:
|
||||
print(f"✗ Failed to create channel for {team_name}: {response.status_code} - {response.text}")
|
||||
print(
|
||||
f"✗ Failed to create channel for {team_name}: "
|
||||
f"{response.status_code} - {response.text}"
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
print(f"Creating private voice channels for {len(TEAMS)} teams...")
|
||||
print(f"Category ID: {CATEGORY_ID}")
|
||||
@@ -116,5 +117,6 @@ def main():
|
||||
print(" - Has no user limit")
|
||||
print(" - Uses 64 kbps bitrate")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user