Add docker
This commit is contained in:
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@@ -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"]
|
||||
@@ -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`:
|
||||
|
||||
|
||||
6
docker-compose.yml
Normal file
6
docker-compose.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
version: '3.3'
|
||||
services:
|
||||
moai-bot:
|
||||
container_name: moai-bot
|
||||
build: .
|
||||
image: moai-bot
|
||||
14
main.py
14
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'])
|
||||
|
||||
Reference in New Issue
Block a user