basic volume settings

This commit is contained in:
Bence T. 2025-05-01 12:01:51 +02:00
parent 6d69421305
commit 6c2ce758d6

15
main.py
View file

@ -12,6 +12,10 @@ bot = commands.Bot(command_prefix="..", intents=intents)
# Global variable to hold the current voice client
voice_client = None
# Sets the default volume to 20%, to make headphone users survive
# the volume does not change when the bot is already playing, only new audio
current_volume = 0.20
@bot.event
async def on_ready():
# Construct the invite URL dynamically
@ -62,7 +66,7 @@ async def play(ctx, url: str):
ffmpeg_options = {
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5 -protocol_whitelist file,http,https,tcp,tls,crypto",
"options": "-vn"
"options": f"-vn -af volume={current_volume}"
}
voice_client.play(
@ -84,6 +88,15 @@ async def stop(ctx):
else:
await ctx.send("nem is szól semmi te buzeráns fasz")
@bot.command()
async def volume(ctx, vol: float):
global current_volume
if 0.0 <= vol <= 2.0:
current_volume = vol
await ctx.send(f"hangerő most {vol*100:.0f}%")
else:
await ctx.send("0.0 és 2.0 között add meg te szerencsétlen")
@bot.command()
async def leave(ctx):
global voice_client