From ba4eed25389c47da2c4b78759a10a32c1498ff2d Mon Sep 17 00:00:00 2001 From: insert Date: Sat, 10 Aug 2024 22:45:06 -0400 Subject: [PATCH] Update --- gameutils.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gameutils.py b/gameutils.py index 9c7b6d1..6d996c0 100644 --- a/gameutils.py +++ b/gameutils.py @@ -33,14 +33,18 @@ class GameView(nextcord.ui.View): try: turnping = ogmsg[i+1].split("<")[1].split(">")[0] except IndexError: - message = message + "The turn is over" + message = message + "The round is over" turnover = True continue else: message = message + ogmsg[i] + "\n" if turnover: await interaction.response.edit_message(content=message,view=None) - await interaction.followup.send(f"The turn has concluded") + try: + await interaction.message.unpin() + except: + pass + await interaction.followup.send(f"The round has concluded") else: await interaction.response.edit_message(content=message) await interaction.followup.send(f"<{turnping}> it is now your turn!") @@ -67,13 +71,25 @@ class gameutils(commands.Cog): default_member_permissions=nextcord.Permissions(manage_roles=True), ) @nextcord.ext.application_checks.has_permissions(manage_roles=True) - async def turngen(self, interaction: nextcord.Interaction, role: nextcord.Role, turnmessage: str): + async def turngen(self, interaction: nextcord.Interaction, role: nextcord.Role, turnmessage: str, disadvantagerole: nextcord.Role = nextcord.SlashOption(required=False)): message = f"{turnmessage}\n" + if disadvantagerole: + disusers = disadvantagerole.members users = role.members + users = list(set(users) - set(disusers)) random.shuffle(users) for i in range(len(users)): message = message + f"{str(i+1)}\. <@{users[i].id}>\n" - await interaction.response.send_message(message, view=GameView(), allowed_mentions=nextcord.AllowedMentions.none()) + if disadvantagerole: + random.shuffle(disusers) + for i in range(len(disusers)): + message = message + f"{str(i+1)}\. <@{users[i].id}> **disadventage**\n" + sentmsg = await interaction.response.send_message(message, view=GameView(), allowed_mentions=nextcord.AllowedMentions.none()) + try: + sentmsg = await sentmsg.fetch() + await sentmsg.pin() + except: + pass await interaction.followup.send(f"<@{users[0].id}> it is now your turn!")