Clean up the output for each group and the hidden replies
This commit is contained in:
parent
723659344b
commit
99d7866bf4
1 changed files with 17 additions and 9 deletions
26
matchy.py
26
matchy.py
|
@ -55,9 +55,9 @@ async def sync(ctx: commands.Context):
|
||||||
await msg.edit(content="Done!")
|
await msg.edit(content="Done!")
|
||||||
|
|
||||||
@bot.tree.command(description = "Match matchees into groups", guilds = list(g for g in guilds if g.id in config.SERVERS))
|
@bot.tree.command(description = "Match matchees into groups", guilds = list(g for g in guilds if g.id in config.SERVERS))
|
||||||
@app_commands.describe(per_group = "Matchees per group (default 3+)", post = "Post to channel")
|
@app_commands.describe(per_group = "Matchees per group (default 3+)", post = "Post to channel", test_people = "Use example test matchees")
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def match(interaction: discord.Interaction, per_group: int = None, post: bool = None):
|
async def match(interaction: discord.Interaction, per_group: int = None, post: bool = None, test_people: bool = False):
|
||||||
"""Match groups of channel members"""
|
"""Match groups of channel members"""
|
||||||
if not per_group:
|
if not per_group:
|
||||||
per_group = 3
|
per_group = 3
|
||||||
|
@ -78,10 +78,13 @@ async def match(interaction: discord.Interaction, per_group: int = None, post: b
|
||||||
|
|
||||||
# Let the channel know the matching is starting
|
# Let the channel know the matching is starting
|
||||||
if post:
|
if post:
|
||||||
await interaction.channel.send(f"{interaction.user.display_name} asked me to match groups of {per_group}! :partying_face:")
|
post = await interaction.channel.send(f"{interaction.user.display_name} asked me to match groups of {per_group}!")
|
||||||
|
|
||||||
# Find all the members in the role
|
# Find all the members in the role
|
||||||
matchees = list( m for m in interaction.channel.members if not m.bot and matchee_role in m.roles)
|
if not test_people:
|
||||||
|
matchees = list( m for m in interaction.channel.members if not m.bot and matchee_role in m.roles)
|
||||||
|
else:
|
||||||
|
matchees = list( m for m in interaction.channel.members) # Test with everyone on the server
|
||||||
logger.info(f"{len(matchees)} matchees found")
|
logger.info(f"{len(matchees)} matchees found")
|
||||||
|
|
||||||
# Shuffle the people for randomness
|
# Shuffle the people for randomness
|
||||||
|
@ -96,8 +99,12 @@ async def match(interaction: discord.Interaction, per_group: int = None, post: b
|
||||||
# Split members into groups and share them
|
# Split members into groups and share them
|
||||||
groups = [matchees[i::num_groups] for i in range(num_groups)]
|
groups = [matchees[i::num_groups] for i in range(num_groups)]
|
||||||
group_msgs = []
|
group_msgs = []
|
||||||
for idx, group in enumerate(groups):
|
for group in groups:
|
||||||
mentions = ", ".join([m.mention for m in group])
|
mentions = [m.mention for m in group]
|
||||||
|
if len(group) > 1:
|
||||||
|
mentions = "{} and {}".format(', '.join(mentions[:-1]), mentions[-1])
|
||||||
|
else:
|
||||||
|
mentions = mentions[0]
|
||||||
logger.info(f"Sending group: {list(m.name for m in group)}")
|
logger.info(f"Sending group: {list(m.name for m in group)}")
|
||||||
group_msgs.append(f"Matched up {mentions}!")
|
group_msgs.append(f"Matched up {mentions}!")
|
||||||
|
|
||||||
|
@ -105,12 +112,13 @@ async def match(interaction: discord.Interaction, per_group: int = None, post: b
|
||||||
if post:
|
if post:
|
||||||
for msg in group_msgs:
|
for msg in group_msgs:
|
||||||
await interaction.channel.send(msg)
|
await interaction.channel.send(msg)
|
||||||
|
await interaction.channel.send("That's all folks, happy matching and remember - DFTBA!")
|
||||||
|
await interaction.response.send_message("All done! :)", ephemeral=True, silent=True)
|
||||||
else:
|
else:
|
||||||
await interaction.response.send_message("\n".join(group_msgs), ephemeral=True, silent=True)
|
await interaction.response.send_message("\n".join(group_msgs), ephemeral=True, silent=True)
|
||||||
|
|
||||||
logger.info(f"Done")
|
logger.info(f"Done")
|
||||||
if post:
|
|
||||||
await interaction.response.send_message("Done :)", ephemeral=True, silent=True)
|
|
||||||
|
|
||||||
# Kick off the bot run cycle
|
# Kick off the bot run cycle
|
||||||
handler = logging.StreamHandler()
|
handler = logging.StreamHandler()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue