Update
This commit is contained in:
parent
e3cd8475ae
commit
7604b1e1f0
1 changed files with 33 additions and 2 deletions
35
gameutils.py
35
gameutils.py
|
@ -7,10 +7,41 @@ import aiohttp
|
|||
from urllib.parse import urlparse
|
||||
import os
|
||||
|
||||
|
||||
class GameView(nextcord.ui.View):
|
||||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
|
||||
@nextcord.ui.button(
|
||||
label="Next Turn", style=nextcord.ButtonStyle.green, custom_id="gameutils:nextturn"
|
||||
)
|
||||
@nextcord.ext.application_checks.has_permissions(manage_roles=True)
|
||||
async def approve(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||
ogmsg = interaction.message.content.split("\n")
|
||||
ogmsg.pop(0)
|
||||
message = "It has been decreed..\n"
|
||||
found = False
|
||||
for i in ogmsg:
|
||||
if i.startswith("~"):
|
||||
message = message + i + "\n"
|
||||
continue
|
||||
if not found:
|
||||
i = "~~" + i + "~~"
|
||||
turnping = i.split("<")[1].split(">")[0]
|
||||
found = True
|
||||
message = message + i + "\n"
|
||||
continue
|
||||
else:
|
||||
message = message + i + "\n"
|
||||
await interaction.response.edit_message(message)
|
||||
await interaction.followup.send(f"<{turnping}> it is now your turn!")
|
||||
return
|
||||
|
||||
class gameutils(commands.Cog):
|
||||
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
bot.add_view(GameView())
|
||||
|
||||
@nextcord.slash_command(
|
||||
name="turngen",
|
||||
|
@ -24,8 +55,8 @@ class gameutils(commands.Cog):
|
|||
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, allowed_mentions=nextcord.AllowedMentions.none())
|
||||
await interaction.followup.send(f"{users[0]} it is now your turn!")
|
||||
await interaction.response.send_message(message, view=GameView(), allowed_mentions=nextcord.AllowedMentions.none())
|
||||
await interaction.followup.send(f"<@{users[0]}> it is now your turn!")
|
||||
|
||||
|
||||
def setup(bot: commands.Bot):
|
||||
|
|
Loading…
Reference in a new issue