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`.
|
Requires `ffmpeg`. Install requirements: `python3 -m pip -U -r requirements.txt`.
|
||||||
|
|
||||||
|
Run with `docker compose up --build`.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
Requires a `settings.json`:
|
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:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.all()
|
||||||
intents.message_content = True
|
|
||||||
bot = commands.Bot(
|
bot = commands.Bot(
|
||||||
command_prefix=settings['prefix'],
|
command_prefix=settings['prefix'],
|
||||||
description='Moai',
|
description='Moai',
|
||||||
@@ -34,15 +33,14 @@ async def stone(ctx):
|
|||||||
await ctx.send('🗿')
|
await ctx.send('🗿')
|
||||||
|
|
||||||
|
|
||||||
@bot.command()
|
async def play(ctx, src: str):
|
||||||
async def moai(ctx):
|
|
||||||
# delete message
|
# delete message
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
|
|
||||||
vc = ctx.author.voice.channel
|
vc = ctx.author.voice.channel
|
||||||
if vc:
|
if vc:
|
||||||
connection = await vc.connect()
|
connection = await vc.connect()
|
||||||
connection.play(discord.FFmpegPCMAudio(source="moai.mp3"))
|
connection.play(discord.FFmpegPCMAudio(source=src))
|
||||||
|
|
||||||
# instantly disconnect, after audio is done playing
|
# instantly disconnect, after audio is done playing
|
||||||
while connection.is_playing():
|
while connection.is_playing():
|
||||||
@@ -51,4 +49,10 @@ async def moai(ctx):
|
|||||||
else:
|
else:
|
||||||
print("User is not in a channel!")
|
print("User is not in a channel!")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
async def moai(ctx):
|
||||||
|
await play(ctx, "audio/moai.mp3")
|
||||||
|
|
||||||
|
|
||||||
bot.run(settings['token'])
|
bot.run(settings['token'])
|
||||||
|
|||||||
Reference in New Issue
Block a user