diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..11a35f8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.7-alpine + +COPY requirements.txt / + +RUN apk add --update --no-cache --virtual .tmp-build-deps \ + make libffi-dev musl-dev gcc \ + && apk add ffmpeg \ + && pip3 install -r /requirements.txt + +COPY audio /moai +COPY settings.json /moai +COPY main.py /moai + +WORKDIR /moai + +USER 1337 + +CMD ["python3", "main.py"] diff --git a/README.md b/README.md index 86a7853..2af0424 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Requires `ffmpeg`. Install requirements: `python3 -m pip -U -r requirements.txt`. +Run with `docker compose up --build`. + ## Settings Requires a `settings.json`: diff --git a/moai.mp3 b/audio/moai.mp3 similarity index 100% rename from moai.mp3 rename to audio/moai.mp3 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2c94040 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: '3.3' +services: + moai-bot: + container_name: moai-bot + build: . + image: moai-bot diff --git a/main.py b/main.py index 0ac123c..42fd910 100644 --- a/main.py +++ b/main.py @@ -9,8 +9,7 @@ try: except Exception as e: print(e) -intents = discord.Intents.default() -intents.message_content = True +intents = discord.Intents.all() bot = commands.Bot( command_prefix=settings['prefix'], description='Moai', @@ -34,15 +33,14 @@ async def stone(ctx): await ctx.send('🗿') -@bot.command() -async def moai(ctx): +async def play(ctx, src: str): # delete message await ctx.message.delete() vc = ctx.author.voice.channel if vc: connection = await vc.connect() - connection.play(discord.FFmpegPCMAudio(source="moai.mp3")) + connection.play(discord.FFmpegPCMAudio(source=src)) # instantly disconnect, after audio is done playing while connection.is_playing(): @@ -51,4 +49,10 @@ async def moai(ctx): else: print("User is not in a channel!") + +@bot.command() +async def moai(ctx): + await play(ctx, "audio/moai.mp3") + + bot.run(settings['token'])