2021-05-14 01:10:58 +02:00
|
|
|
from discord.ext import commands
|
|
|
|
from discord import Permissions, PermissionOverwrite
|
|
|
|
|
|
|
|
# init bot
|
|
|
|
bot = commands.Bot(command_prefix="!")
|
|
|
|
|
|
|
|
# init registered cinemas
|
|
|
|
# subject to change -> save on disk
|
|
|
|
cinemas = dict()
|
|
|
|
|
|
|
|
@bot.group("cinema")
|
|
|
|
@commands.guild_only()
|
|
|
|
async def cinema(ctx):
|
|
|
|
pass
|
|
|
|
|
2021-05-21 19:51:45 +02:00
|
|
|
|
2021-05-14 01:10:58 +02:00
|
|
|
@cinema.command("create")
|
|
|
|
@commands.bot_has_permissions(manage_channels=True)
|
|
|
|
async def cinema_create(ctx, name, link=None):
|
|
|
|
# create permissions overwrites, so noone is allowed to join initially
|
2021-05-21 19:51:45 +02:00
|
|
|
overwrites = { ctx.guild.default_role: PermissionOverwrite(connect=False, view_channel=True) }
|
|
|
|
bot_overwrite = PermissionOverwrite(view_channel=True, manage_channels=True, manage_permissions=True, connect=True)
|
|
|
|
|
2021-05-14 01:10:58 +02:00
|
|
|
# create voice channel and register
|
|
|
|
voice_channel = await ctx.guild.create_voice_channel(name, overwrites=overwrites, category=ctx.channel.category)
|
2021-05-21 19:51:45 +02:00
|
|
|
await voice_channel.set_permissions(bot.user, overwrite=bot_overwrite)
|
2021-05-14 01:10:58 +02:00
|
|
|
|
|
|
|
# create embed for series/movie
|
|
|
|
# not implemented yet.
|
|
|
|
|
|
|
|
# send announcement and create author reaction
|
|
|
|
announcement = await ctx.channel.send("React to this.")
|
|
|
|
await announcement.add_reaction("\U0001F3AB")
|
|
|
|
|
2021-05-21 19:51:45 +02:00
|
|
|
# create cinema entry in cache
|
|
|
|
cinemas[announcement.id] = voice_channel.id
|
|
|
|
|
|
|
|
|
|
|
|
@bot.listen('on_reaction_add')
|
|
|
|
async def on_reaction_registered_messages(reaction, user):
|
|
|
|
if reaction.message.id in cinemas.keys() and user.id != bot.user.id:
|
|
|
|
voice_channel = bot.get_channel(cinemas.pop(reaction.message.id))
|
|
|
|
await voice_channel.delete(reason="Cinema was closed.")
|
|
|
|
print(cinemas)
|
|
|
|
|
|
|
|
|
2021-05-14 01:10:58 +02:00
|
|
|
if __name__ == "__main__":
|
2021-05-21 19:51:45 +02:00
|
|
|
bot.run('MzU4NTU5Njc3MDgyMTA3OTA0.Wbz8uA.jCvxjFY6NgWhXikqnZC5DWuQAa8')
|