listen to reactions on announcement
This commit is contained in:
parent
484ce6683c
commit
cb5f9f195f
24
main.py
24
main.py
|
@ -13,17 +13,17 @@ cinemas = dict()
|
||||||
async def cinema(ctx):
|
async def cinema(ctx):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@cinema.command("create")
|
@cinema.command("create")
|
||||||
@commands.bot_has_permissions(manage_channels=True)
|
@commands.bot_has_permissions(manage_channels=True)
|
||||||
async def cinema_create(ctx, name, link=None):
|
async def cinema_create(ctx, name, link=None):
|
||||||
# create permissions overwrites, so noone is allowed to join initially
|
# create permissions overwrites, so noone is allowed to join initially
|
||||||
overwrites = {
|
overwrites = { ctx.guild.default_role: PermissionOverwrite(connect=False, view_channel=True) }
|
||||||
ctx.guild.default_role: PermissionOverwrite(connect=False)
|
bot_overwrite = PermissionOverwrite(view_channel=True, manage_channels=True, manage_permissions=True, connect=True)
|
||||||
}
|
|
||||||
|
|
||||||
# create voice channel and register
|
# create voice channel and register
|
||||||
voice_channel = await ctx.guild.create_voice_channel(name, overwrites=overwrites, category=ctx.channel.category)
|
voice_channel = await ctx.guild.create_voice_channel(name, overwrites=overwrites, category=ctx.channel.category)
|
||||||
cinemas[ctx.message.id] = voice_channel
|
await voice_channel.set_permissions(bot.user, overwrite=bot_overwrite)
|
||||||
|
|
||||||
# create embed for series/movie
|
# create embed for series/movie
|
||||||
# not implemented yet.
|
# not implemented yet.
|
||||||
|
@ -32,5 +32,17 @@ async def cinema_create(ctx, name, link=None):
|
||||||
announcement = await ctx.channel.send("React to this.")
|
announcement = await ctx.channel.send("React to this.")
|
||||||
await announcement.add_reaction("\U0001F3AB")
|
await announcement.add_reaction("\U0001F3AB")
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
bot.run('')
|
bot.run('MzU4NTU5Njc3MDgyMTA3OTA0.Wbz8uA.jCvxjFY6NgWhXikqnZC5DWuQAa8')
|
Loading…
Reference in New Issue