only move people if they're still in the pollination channels

This commit is contained in:
xenofem 2020-08-09 20:06:31 -04:00
parent f38026fcb1
commit 9e9c2cde1c

View file

@ -181,33 +181,34 @@ async def handle_guild_message(message):
await message.channel.send("{} Welcome to pollination! You'll be randomly paired up, moved into separate voice channels, spend some time chatting, and then move to a new channel and meet somebody else. Each round will last 5 minutes, and there'll be {} rounds total. I'll announce when your time is nearly up so you can wrap up your conversations, and I'll automatically move you to a different voice channel at the start of each new round. If you keep this text channel open, you'll get audible countdowns via text-to-speech at the end of each round. **Feel free to leave at any time if you need to. You won't get moved into new voice channels if you disconnect from voice.** If you find yourself alone in a channel, the person you were paired with for that round may have left; just relax and take a break for 5 minutes. Have fun!".format(mention_all, len(schedule)))
first_round = True
for matching in schedule:
await message.channel.send('Next round starting in 30 seconds:')
for ((a, b), c) in zip(matching, pollination_channels):
await message.channel.send('{0} and {1} in {2}'.format(a.mention, b.mention, c.name))
await countdown(message.channel)
for ((a, b), c) in zip(matching, pollination_channels):
try:
await a.move_to(c)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(a, e), file=sys.stderr)
try:
await b.move_to(c)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(b, e), file=sys.stderr)
for (pair, c) in zip(matching, pollination_channels):
for u in pair:
if u.voice is not None and ((first_round and u.voice.channel == main_voice_channel) or u.voice.channel in pollination_channels):
try:
await u.move_to(c)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(u, e), file=sys.stderr)
await asyncio.sleep(60*3)
await message.channel.send('Round ending in 2 minutes {}'.format(mention_all))
await asyncio.sleep(60)
await message.channel.send('Round ending in 1 minute {}'.format(mention_all))
await asyncio.sleep(30)
first_round = False
await message.channel.send('Returning to main channel in 30 seconds {}'.format(mention_all))
await countdown(message.channel)
for u in participants:
try:
await u.move_to(main_voice_channel)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(u, e), file=sys.stderr)
if u.voice is not None and u.voice.channel in pollination_channels:
try:
await u.move_to(main_voice_channel)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(u, e), file=sys.stderr)
await delete_if_possible(pollination_channels)