Added basic event recording. No points being tracked yet.
build_develop / build (push) Successful in 34s
build_develop / build (push) Successful in 34s
This commit is contained in:
+43
-18
@@ -5,6 +5,8 @@ Contained commands and views for record commands.
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
from config import DakinyConfig
|
||||
|
||||
|
||||
class RecordCog(commands.Cog, name="Record Commands"):
|
||||
"""
|
||||
@@ -50,28 +52,51 @@ class RecordCog(commands.Cog, name="Record Commands"):
|
||||
if host is None:
|
||||
host = interaction.user
|
||||
|
||||
msg: str = f"Event {name} was hosted by <@{host.id}>."
|
||||
await interaction.response.send_message(
|
||||
"Select all members who participated!",
|
||||
view=EventView(host, name, self.bot.config),
|
||||
ephemeral=True,
|
||||
)
|
||||
|
||||
await interaction.response.send_message(msg, ephemeral=True, view=EventView())
|
||||
|
||||
# create view to add members
|
||||
# add points to table
|
||||
|
||||
|
||||
class EventParticipants(nextcord.ui.UserSelect):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(
|
||||
min_values=1,
|
||||
max_values=25,
|
||||
)
|
||||
|
||||
async def callback(self, interaction: nextcord.Interaction):
|
||||
await interaction.response.send_message(f"members selected: {self.values}")
|
||||
|
||||
|
||||
class EventView(nextcord.ui.View):
|
||||
def __init__(self):
|
||||
def __init__(self, host: nextcord.Member, name: str, config: DakinyConfig):
|
||||
super().__init__()
|
||||
|
||||
# Adds the dropdown to our view object.
|
||||
self.add_item(EventParticipants())
|
||||
self.host: nextcord.Member = host
|
||||
self.name: str = name
|
||||
self.config: DakinyConfig = config
|
||||
|
||||
self.event_participants = nextcord.ui.UserSelect(
|
||||
min_values=1,
|
||||
max_values=25,
|
||||
placeholder="Select all participants",
|
||||
row=0,
|
||||
)
|
||||
|
||||
self.add_item(self.event_participants)
|
||||
|
||||
@nextcord.ui.button(label="Cancel", style=nextcord.ButtonStyle.red, row=1)
|
||||
async def cancel(
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
):
|
||||
await interaction.response.send_message("Cancelling", ephemeral=True)
|
||||
self.stop()
|
||||
|
||||
@nextcord.ui.button(label="Confirm", style=nextcord.ButtonStyle.green, row=1)
|
||||
async def confirm(
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
):
|
||||
msg = f"Event: {self.name}\n"
|
||||
msg += f"Hosted by: <@{self.host.id}>\n\n"
|
||||
msg += "Participants:\n"
|
||||
for participant in self.event_participants.values.members:
|
||||
msg += f"<@{participant.id}>\n"
|
||||
|
||||
event_channel: nextcord.TextChannel = interaction.guild.get_channel(
|
||||
self.config.params.event_post_channel_id
|
||||
)
|
||||
await event_channel.send(msg)
|
||||
self.stop()
|
||||
|
||||
Reference in New Issue
Block a user