Change up recording process. use a modal to edit text values.
This commit is contained in:
@@ -3,6 +3,7 @@ Contained commands and views for record commands.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
|
from discord import TextInputStyle
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from config import DakinyConfig
|
from config import DakinyConfig
|
||||||
@@ -52,10 +53,15 @@ class RecordCog(commands.Cog, name="Record Commands"):
|
|||||||
if host is None:
|
if host is None:
|
||||||
host = interaction.user
|
host = interaction.user
|
||||||
|
|
||||||
|
embed: nextcord.Embed = nextcord.Embed(title=name, description="")
|
||||||
|
embed.add_field(name="Participants", value="")
|
||||||
|
embed.add_field(name="Non-Discord Participants", value="")
|
||||||
|
|
||||||
await interaction.response.send_message(
|
await interaction.response.send_message(
|
||||||
"Select all members who participated!",
|
"Select all members who participated!",
|
||||||
view=EventView(host, name, self.bot.config),
|
view=EventView(host, name, self.bot.config),
|
||||||
ephemeral=True,
|
ephemeral=True,
|
||||||
|
embed=embed,
|
||||||
)
|
)
|
||||||
|
|
||||||
# add points to table
|
# add points to table
|
||||||
@@ -85,6 +91,12 @@ class EventView(nextcord.ui.View):
|
|||||||
await interaction.response.send_message("Cancelling", ephemeral=True)
|
await interaction.response.send_message("Cancelling", ephemeral=True)
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
|
@nextcord.ui.button(label="Edit", style=nextcord.ButtonStyle.blurple, row=1)
|
||||||
|
async def edit(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||||
|
await interaction.response.send_modal(
|
||||||
|
ParticipantModal(interaction.message.embeds[0])
|
||||||
|
)
|
||||||
|
|
||||||
@nextcord.ui.button(label="Confirm", style=nextcord.ButtonStyle.green, row=1)
|
@nextcord.ui.button(label="Confirm", style=nextcord.ButtonStyle.green, row=1)
|
||||||
async def confirm(
|
async def confirm(
|
||||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||||
@@ -100,3 +112,44 @@ class EventView(nextcord.ui.View):
|
|||||||
)
|
)
|
||||||
await event_channel.send(msg)
|
await event_channel.send(msg)
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
|
|
||||||
|
class ParticipantModal(nextcord.ui.Modal):
|
||||||
|
def __init__(self, embed):
|
||||||
|
super().__init__(
|
||||||
|
"Add non-discord members as participats!",
|
||||||
|
timeout=5 * 60,
|
||||||
|
)
|
||||||
|
self.embed: nextcord.Embed = embed
|
||||||
|
self.name: nextcord.ui.TextInput = nextcord.ui.TextInput(
|
||||||
|
required=True,
|
||||||
|
label="Event Name",
|
||||||
|
default_value=self.embed.title,
|
||||||
|
)
|
||||||
|
self.description: nextcord.ui.TextInput = nextcord.ui.TextInput(
|
||||||
|
required=False,
|
||||||
|
label="Event Description",
|
||||||
|
default_value=self.embed.description,
|
||||||
|
style=TextInputStyle.paragraph,
|
||||||
|
placeholder="Add a description if desired.",
|
||||||
|
max_length=1000,
|
||||||
|
)
|
||||||
|
self.participants: nextcord.ui.TextInput = nextcord.ui.TextInput(
|
||||||
|
required=False,
|
||||||
|
label="Usernames",
|
||||||
|
style=TextInputStyle.paragraph,
|
||||||
|
placeholder="Please separate usernames with a new line.",
|
||||||
|
default_value=self.embed.fields[1].value,
|
||||||
|
)
|
||||||
|
self.add_item(self.name)
|
||||||
|
self.add_item(self.description)
|
||||||
|
self.add_item(self.participants)
|
||||||
|
|
||||||
|
async def callback(self, interaction: nextcord.Interaction):
|
||||||
|
self.embed.title = self.name.value
|
||||||
|
self.embed.description = self.description.value
|
||||||
|
self.embed.set_field_at(
|
||||||
|
index=1, name="Non-Discord Participants", value=self.participants.value
|
||||||
|
)
|
||||||
|
|
||||||
|
await interaction.response.edit_message(embed=self.embed)
|
||||||
|
|||||||
Reference in New Issue
Block a user