From f38026fcb12879359d5689190afaff2b52a4a1b9 Mon Sep 17 00:00:00 2001 From: xenofem Date: Sun, 9 Aug 2020 19:54:29 -0400 Subject: [PATCH 1/4] send schedule as individual messages per pair --- waggle-dance.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/waggle-dance.py b/waggle-dance.py index bde3988..fe415d9 100755 --- a/waggle-dance.py +++ b/waggle-dance.py @@ -182,9 +182,9 @@ 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))) for matching in schedule: - announcement = 'Next round starting in 30 seconds:\n' - announcement += '\n'.join('{0} and {1} in {2}'.format(a.mention, b.mention, c.name) for ((a, b), c) in zip(matching, pollination_channels)) - await message.channel.send(announcement) + 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: From 9e9c2cde1cc1e62ee10ab44a3a5776de7bcf056d Mon Sep 17 00:00:00 2001 From: xenofem Date: Sun, 9 Aug 2020 20:06:31 -0400 Subject: [PATCH 2/4] only move people if they're still in the pollination channels --- waggle-dance.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/waggle-dance.py b/waggle-dance.py index fe415d9..36cbd63 100755 --- a/waggle-dance.py +++ b/waggle-dance.py @@ -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) From 1cb7712884a1442f1b7c734e08e4d5d0c39d31bc Mon Sep 17 00:00:00 2001 From: xenofem Date: Tue, 29 Sep 2020 10:00:05 -0400 Subject: [PATCH 3/4] API change made us try and fail to actually mention blocked users in DMs, don't do that --- waggle-dance.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/waggle-dance.py b/waggle-dance.py index 36cbd63..1e5edbf 100755 --- a/waggle-dance.py +++ b/waggle-dance.py @@ -221,22 +221,22 @@ async def handle_dm(message): discriminator = match.group(2) matching_users = [u for u in client.users if u.name == name and u.discriminator == discriminator] if len(matching_users) == 0: - await message.channel.send("sorry, I can't find user {}, it looks like they're not in any of the discords I'm in".format(handle)) + await message.channel.send("sorry, I can't find user {}, it looks like they're not in any of the discords I'm in".format(handle), allowed_mentions=discord.AllowedMentions.none()) else: target = matching_users[0].id if target in get_blocks().get(requester, []): - await message.channel.send("removing {} from your list of blocked users for pollination".format(handle)) + await message.channel.send("removing {} from your list of blocked users for pollination".format(handle), allowed_mentions=discord.AllowedMentions.none()) remove_block(requester, target) else: - await message.channel.send("adding {} to your list of blocked users for pollination".format(handle)) + await message.channel.send("adding {} to your list of blocked users for pollination".format(handle), allowed_mentions=discord.AllowedMentions.none()) add_block(requester, target) blocks = get_blocks().get(requester, []) if len(blocks) == 0: await message.channel.send("you currently don't have anyone blocked for pollination") else: - await message.channel.send("your current list of blocked users for pollination is:\n{}".format('\n'.join('@{}#{}'.format(u.name, u.discriminator) for u in [client.get_user(uid) for uid in blocks] if u is not None))) - await message.channel.send("to block or unblock a user, DM me their handle, like @creep#0000. to see this message and your list of blocked users, DM me something random. buzz buzz!") + await message.channel.send("your current list of blocked users for pollination is:\n{}".format('\n'.join('@{}#{}'.format(u.name, u.discriminator) for u in [client.get_user(uid) for uid in blocks] if u is not None)), allowed_mentions=discord.AllowedMentions.none()) + await message.channel.send("to block or unblock a user, DM me their handle, like @creep#0000. to see this message and your list of blocked users, DM me something random. buzz buzz!", allowed_mentions=discord.AllowedMentions.none()) @client.event async def on_ready(): From e8e9baebd88d08b6df5db55941af6a99532c034d Mon Sep 17 00:00:00 2001 From: xenofem Date: Tue, 29 Sep 2020 14:55:27 -0400 Subject: [PATCH 4/4] now need to explicitly enable members intent --- waggle-dance.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/waggle-dance.py b/waggle-dance.py index 1e5edbf..bd80fee 100755 --- a/waggle-dance.py +++ b/waggle-dance.py @@ -109,7 +109,9 @@ async def countdown(channel): with open('config.json') as f: config = json.load(f) -client = discord.Client() +intents = discord.Intents.default() +intents.members = True +client = discord.Client(intents=intents) async def handle_guild_message(message): if not message.content.startswith('!waggle'):