commit 19e154fed4d91cc05b26aae24ab6db3ea2b2e5a8 Author: didas72 Date: Mon Dec 8 17:48:45 2025 +0000 Initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e664cda --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.14-slim + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y ffmpeg && \ + rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache-dir discord.py pynacl + +WORKDIR /app +COPY main.py . +COPY sus_trimmed.mp3 . + +RUN useradd -m appuser && \ + chown -R appuser:appuser /app + +USER appuser + +CMD ["python", "-u", "main.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2a16c67 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,5 @@ +services: + castigo_bot: + image: castigo_bot + container_name: castigo_bot + restart: unless-stopped diff --git a/main.py b/main.py new file mode 100644 index 0000000..4aba9ff --- /dev/null +++ b/main.py @@ -0,0 +1,60 @@ +from discord import Intents, Interaction, VoiceState, Member, FFmpegPCMAudio, VoiceClient +from discord.ext import commands + + +DISCORD_TOKEN = "MTQ0NzYyNjkxMDEzNzA2MTQ2Ng.GZ-Snw.suZpiacdFgR2hyD6KtqlpdTFVCRxv3kgGa9hS8" +PASTALANDIA = 929432463099461694 +CASTIGO = 1429535766710714439 +FILENAME = "sus_trimmed.mp3" + +intents = Intents.default() +intents.voice_states = True +client = commands.Bot(command_prefix="/", intents=intents) +voice_client: VoiceClient + +@client.event +async def on_ready(): + print(f"We have logged in as {client.user}") + try: + synced = await client.tree.sync() + print(f"Synced {len(synced)} command(s)") + except Exception as e: + print(f"Failed to sync commands: {e}") + + +@client.tree.command(name="ping", description="Check the bot's latency.") +async def ping(interaction: Interaction): + latency = client.latency * 1000 + await interaction.response.send_message(f"Pong! Latency: {latency:.2f}ms") + + +@client.event +async def on_voice_state_update(member: Member, before: VoiceState, after: VoiceState): + global voice_client + + print("Event") + if before.channel and before.channel.id == CASTIGO and (not after.channel or after.channel.id != CASTIGO): + channel = before.channel + if len(channel.members) <= 1: + await voice_client.disconnect() + + if not (after.channel and after.channel.id == CASTIGO and (not before.channel or before.channel.id != CASTIGO)): return + + print("Yeee") + channel = after.channel + try: + print("Connecting") + voice_client = await channel.connect(self_deaf=True) + print("Connected") + except: + return + + print("Sourcing") + source = FFmpegPCMAudio(FILENAME) + print("Starting") + voice_client.play(source) + print("Playing") + + +if __name__ == "__main__": + client.run(DISCORD_TOKEN) diff --git a/sus_trimmed.mp3 b/sus_trimmed.mp3 new file mode 100644 index 0000000..c84899e Binary files /dev/null and b/sus_trimmed.mp3 differ