From c9cf63a92ba771771dd85ac49cbd937e9919694f Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 7 Aug 2020 16:31:48 -0700 Subject: [PATCH] getting the invite function ported over --- Dockerfile-test-env | 4 ++-- app/dragon-bot-updated.py | 34 ++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Dockerfile-test-env b/Dockerfile-test-env index 275ac55b..bc473b6e 100644 --- a/Dockerfile-test-env +++ b/Dockerfile-test-env @@ -2,14 +2,14 @@ FROM python:3.8 as builder RUN apt-get update && apt-get install -y gcc python-pip ADD app/requirements.txt /requirements.txt RUN pip install -r requirements.txt -ADD app /app RUN pip install pylint +ADD app /app RUN printf "\n\nTesting your python code for errors\n\n" && \ pylint -E /app/*.py FROM python:alpine COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/ -COPY --from=builder /app /app +ADD app /app WORKDIR /app RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n" diff --git a/app/dragon-bot-updated.py b/app/dragon-bot-updated.py index b4812450..f77c19bc 100644 --- a/app/dragon-bot-updated.py +++ b/app/dragon-bot-updated.py @@ -17,36 +17,54 @@ async def on_ready(): # f'Hi {member.name}, welcome to my ths server!' # ) + +@bot.command(name='invite') +async def invite(ctx): + # Default to creating the invite to the #general channel + # if the user is in a voice channel, try to create the invite there + invite_channel = ctx.message.channel + try: + if ctx.message.author.voice.channel: + invite_channel = ctx.message.author.voice.channel + except AttributeError: + pass + invite = await invite_channel.create_invite( + destination=invite_channel, + max_uses=1, + max_age=3600 + ) + await ctx.send(invite) + @bot.command(name='corona') async def corona(ctx): - + import corona result = corona.parse_message(ctx.message.content) - + await ctx.send(embed=result) @bot.command(name='stock') async def stock(ctx): - + import stock result = stock.parse_message(ctx.message.content) - + await ctx.send(embed=result) @bot.command(name='flows') async def flows(ctx): - + import river_stats result = river_stats.get_stats() - + await ctx.send(result) @bot.command(name='8ball') async def eight_ball(ctx): - + import eight_ball result = eight_ball.check_8ball(ctx.message.content) - + await ctx.send(result) @bot.command(name='purge')