Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,20 @@ intents.message_content = True
|
|
43 |
client = discord.Client(intents=intents)
|
44 |
tree = app_commands.CommandTree(client)
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
@tree.command(name="list", description="List all available voices")
|
|
|
47 |
async def voice_list(interaction: discord.Interaction):
|
48 |
await interaction.response.defer()
|
49 |
available_voices = get_available_voices()
|
@@ -69,6 +82,7 @@ async def voice_autocomplete(
|
|
69 |
][:25]
|
70 |
|
71 |
@tree.command(name="create", description="Create a voice message")
|
|
|
72 |
@app_commands.describe(
|
73 |
text="Text to convert to speech",
|
74 |
voice_name="Select a voice to use",
|
@@ -81,7 +95,7 @@ async def voice_create(
|
|
81 |
interaction: discord.Interaction,
|
82 |
text: str,
|
83 |
voice_name: str,
|
84 |
-
stability: float = 0.
|
85 |
clarity: float = 0.75,
|
86 |
style: float = 0.5
|
87 |
):
|
@@ -156,9 +170,9 @@ async def on_ready():
|
|
156 |
status=discord.Status.online
|
157 |
)
|
158 |
|
159 |
-
# Sync commands
|
160 |
-
|
161 |
-
logger.info(f"Synced {
|
162 |
except Exception as e:
|
163 |
logger.error(f"Failed to sync commands: {e}")
|
164 |
|
|
|
43 |
client = discord.Client(intents=intents)
|
44 |
tree = app_commands.CommandTree(client)
|
45 |
|
46 |
+
# Define your server ID (replace this with your actual server ID)
|
47 |
+
MY_GUILD_ID = discord.Object(id=int(os.getenv('DISCORD_GUILD_ID', '0')))
|
48 |
+
|
49 |
+
# Add a check for the correct guild
|
50 |
+
def is_in_my_guild():
|
51 |
+
async def predicate(interaction: discord.Interaction) -> bool:
|
52 |
+
if interaction.guild_id != MY_GUILD_ID.id:
|
53 |
+
await interaction.response.send_message("This command can only be used in the authorized server.", ephemeral=True)
|
54 |
+
return False
|
55 |
+
return True
|
56 |
+
return app_commands.check(predicate)
|
57 |
+
|
58 |
@tree.command(name="list", description="List all available voices")
|
59 |
+
@is_in_my_guild()
|
60 |
async def voice_list(interaction: discord.Interaction):
|
61 |
await interaction.response.defer()
|
62 |
available_voices = get_available_voices()
|
|
|
82 |
][:25]
|
83 |
|
84 |
@tree.command(name="create", description="Create a voice message")
|
85 |
+
@is_in_my_guild()
|
86 |
@app_commands.describe(
|
87 |
text="Text to convert to speech",
|
88 |
voice_name="Select a voice to use",
|
|
|
95 |
interaction: discord.Interaction,
|
96 |
text: str,
|
97 |
voice_name: str,
|
98 |
+
stability: float = 0.5,
|
99 |
clarity: float = 0.75,
|
100 |
style: float = 0.5
|
101 |
):
|
|
|
170 |
status=discord.Status.online
|
171 |
)
|
172 |
|
173 |
+
# Sync commands only for specific guild
|
174 |
+
await tree.sync(guild=MY_GUILD_ID)
|
175 |
+
logger.info(f"Synced commands for guild {MY_GUILD_ID.id}")
|
176 |
except Exception as e:
|
177 |
logger.error(f"Failed to sync commands: {e}")
|
178 |
|