@bot.tree.command(name="add_user", description="Add a new user to the database")
@app_commands.describe(preset="Choose a plan preset, e.g., Titan_C2_1 / Titan_API_1",username="Choose a username for the customer",password="Choose a password for the customer")
async def add_user(
interaction: discord.Interaction,
preset: str, # preset jako str z listy
username: str,
password: str
):
await interaction.response.defer(ephemeral=True, thinking=True)
if preset.upper() not in ["Titan_C2_1", "Titan_C2_2", "Titan_C2_3", "Titan_C2_4", "Titan_C2_5", "Titan_API_1", "Titan_API_2", "Titan_API_3", "Titan_API_4", "Titan_API_5",]:
await interaction.response.send_message("**Wpisany zły preset, syntax: `Titan_C2_{nr presetu}` **/** `Titan_API_{nr presetu}`.**", ephemeral=True)
return
# Sprawdzenie uprawnień użytkownika
allowed_roles = ["1262872297648427059"]
user_roles = [str(role.id) for role in interaction.user.roles]
if not any(role_id in allowed_roles for role_id in user_roles):
await interaction.followup.send("Nie masz uprawnień do użycia tej komendy.", ephemeral=True)
return
# Wysyłanie żądania do API
url = f"API"
response = requests.get(url)
content = response.json()
if response.status_code == 200 and content.get("error") != "true":
await interaction.followup.send(f"Successfully added new user with name {username}, password {password}, and plan preset {preset}", ephemeral=True)
else:
error_reason = content.get("message", "Unknown error")
await interaction.followup.send(f"Error! {error_reason}", ephemeral=True)
#i cant sync new commands
1 messages · Page 1 of 1 (latest)
so wut is disnake
its not
;-;
Solved!
Marked the thread as solved. If your question has not been answered, please open a new thread in #1019642966526140566.
solved it with
async def on_ready():
print(f'Logged in as {bot.user}! Synchronizing commands...')
await bot.tree.sync() # Synchronizuje komendy z serwerem Discord
print('Commands synchronized.')