General development process

- new cog commands
- new voice cog
- new requirements.txt
- adjusted readme
- added Dockerfile for faster deployment (still WIP)
- other general things
This commit is contained in:
CramMK
2020-01-23 15:57:30 +00:00
parent 10c65cfda4
commit a653476e9c
14 changed files with 217 additions and 52 deletions

76
cogs/voice.py Normal file
View File

@@ -0,0 +1,76 @@
"""
Make Aqua be able to join voice channel and play audio:
- join
- leave
- play
https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
"""
# IMPORTS
import discord
from discord.ext import commands
from discord.utils import get
# COG INIT
class Voice(commands.Cog):
def __init__(self, bot):
self.bot = bot
# COG BODY
@commands.command(name="join", aliases=["j"])
@commands.guild_only()
async def join(self, ctx):
"""
Tries to join the author's current voice channel
"""
channel = ctx.message.author.voice.channel
if not channel:
ctx.send:("You're not connected to a voice channel!")
return
voice = get(bot.voice_clients, guild=ctx.guild)
if voice and voice.is_connected():
await voice.move_to(channel)
else:
voice = await channel.connect()
await ctx.send(f"`Joined {channel}!`")
""" useless?
await voice.disconnect()
if voice and voice.is_connected():
await voice.move_to(channel)
else:
voice = await channel.connect()
await ctx.send(f"`Joined {channel}!`")
"""
@commands.command(name="leave", aliases=["quit, l"])
@commands.guild_only()
async def leave(self, ctx):
"""
Leaves the voice channel, if connected
"""
channel = ctx.message.author.voice.channel
voice = get(bot.voice_clients, guild=ctx.guild)
if voice and voice.is_connected():
await voice.disconnect()
await ctx.send(f"`Left {channel}!`")
else:
ctx.send("I'm not connected to a channel!")
@commands.command(name="play", aliases=["p"])
@commands.guild_only()
async def play(self, ctx, url: str):
"""
Plays music from YT link specifies
"""
# TODO
ctx.send("This module is not working yet!")
# COG ENDING
def setup(bot):
bot.add_cog(Voice(bot))