From 484ce6683cb0437f759e59fdd6d526c3d5f8c344 Mon Sep 17 00:00:00 2001 From: fanyx Date: Fri, 14 May 2021 01:10:58 +0200 Subject: [PATCH] Create voice channels from command. --- .gitignore | 6 ++++++ README.md | 4 ++-- main.py | 36 ++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 main.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40ccb12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +* +!.gitignore +!main.py +!README.md +!requirements.txt +!url.py \ No newline at end of file diff --git a/README.md b/README.md index 621f6fa..df535b8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # a bot for cinemas -a small bot that facilitates permissions for watch togethers. open a "cinema" via a register command and have people unlock join permissions via reactions to your opening message. +a small bot that facilitates permissions for watch togethers. open a "cinema" via a register command and have people unlock join permissions via reactions to your announcement message. ## configuration -nothing yet. \ No newline at end of file +configuration is done inside the source code. documentation about this will grow with the project. \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..ce680e4 --- /dev/null +++ b/main.py @@ -0,0 +1,36 @@ +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 + +@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 + overwrites = { + ctx.guild.default_role: PermissionOverwrite(connect=False) + } + + # create voice channel and register + voice_channel = await ctx.guild.create_voice_channel(name, overwrites=overwrites, category=ctx.channel.category) + cinemas[ctx.message.id] = voice_channel + + # 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") + +if __name__ == "__main__": + bot.run('') \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7d7341c --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +discord.py>=1.7.2