mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-20 02:26:32 +01:00
Add the option to update assignees
This commit is contained in:
parent
04f47260e1
commit
663d495460
2 changed files with 34 additions and 19 deletions
|
@ -6,7 +6,8 @@ from typing import Optional
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
import config
|
import config
|
||||||
from utils import Assignments, Tutors, simple_embed_paginator, get_or_none, Student, hyperlink, console
|
from utils import Assignments, Tutors, simple_embed_paginator, get_or_none, Student, hyperlink, console, \
|
||||||
|
SelectAssigneesView
|
||||||
|
|
||||||
BOOL_EMOJI = {True: "\N{white heavy check mark}", False: "\N{cross mark}"}
|
BOOL_EMOJI = {True: "\N{white heavy check mark}", False: "\N{cross mark}"}
|
||||||
|
|
||||||
|
@ -325,24 +326,6 @@ class AssignmentsCog(commands.Cog):
|
||||||
await view.wait()
|
await view.wait()
|
||||||
self.create_kwargs["tutor"] = view.value
|
self.create_kwargs["tutor"] = view.value
|
||||||
|
|
||||||
class SelectAssigneesView(discord.ui.View):
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
self.users = []
|
|
||||||
|
|
||||||
@discord.ui.user_select(placeholder="Select some people...", min_values=0, max_values=20)
|
|
||||||
async def select_users(self, select: discord.ui.Select, interaction2: discord.Interaction):
|
|
||||||
self.disable_all_items()
|
|
||||||
self.users = select.values
|
|
||||||
await interaction2.edit_original_response(view=self)
|
|
||||||
self.stop()
|
|
||||||
|
|
||||||
@discord.ui.button(label="skip", style=discord.ButtonStyle.primary)
|
|
||||||
async def skip(self, _, interaction2: discord.Interaction):
|
|
||||||
self.disable_all_items()
|
|
||||||
await interaction2.edit_original_response(view=self)
|
|
||||||
self.stop()
|
|
||||||
|
|
||||||
assigner = SelectAssigneesView()
|
assigner = SelectAssigneesView()
|
||||||
await msg.edit(
|
await msg.edit(
|
||||||
content="Please select people who've been assigned to this task (leave blank or skip to assign"
|
content="Please select people who've been assigned to this task (leave blank or skip to assign"
|
||||||
|
@ -570,6 +553,19 @@ class AssignmentsCog(commands.Cog):
|
||||||
await interaction.response.send_modal(UpdateDateModal())
|
await interaction.response.send_modal(UpdateDateModal())
|
||||||
await self.update_display(interaction)
|
await self.update_display(interaction)
|
||||||
|
|
||||||
|
@discord.ui.button(label="Update assignees")
|
||||||
|
async def update_assignees(self, _, interaction: discord.Interaction):
|
||||||
|
await interaction.response.defer()
|
||||||
|
|
||||||
|
view = SelectAssigneesView()
|
||||||
|
msg: discord.WebhookMessage = await interaction.followup.send(
|
||||||
|
"Which assignees assigned this project?", view=view
|
||||||
|
)
|
||||||
|
await view.wait()
|
||||||
|
await assignment.update(assignees=[x.id for x in view.users])
|
||||||
|
await msg.delete(delay=5)
|
||||||
|
await self.update_display(interaction)
|
||||||
|
|
||||||
@discord.ui.button(label="Mark as [in]complete", custom_id="complete")
|
@discord.ui.button(label="Mark as [in]complete", custom_id="complete")
|
||||||
async def mark_as_complete(self, _, interaction: discord.Interaction):
|
async def mark_as_complete(self, _, interaction: discord.Interaction):
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
|
|
@ -228,3 +228,22 @@ class TimeTableDaySwitcherView(View):
|
||||||
self.user = user
|
self.user = user
|
||||||
self.cog = instance
|
self.cog = instance
|
||||||
self.current_date = date
|
self.current_date = date
|
||||||
|
|
||||||
|
|
||||||
|
class SelectAssigneesView(discord.ui.View):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.users = []
|
||||||
|
|
||||||
|
@discord.ui.user_select(placeholder="Select some people...", min_values=0, max_values=20)
|
||||||
|
async def select_users(self, select: discord.ui.Select, interaction2: discord.Interaction):
|
||||||
|
self.disable_all_items()
|
||||||
|
self.users = select.values
|
||||||
|
await interaction2.edit_original_response(view=self)
|
||||||
|
self.stop()
|
||||||
|
|
||||||
|
@discord.ui.button(label="skip", style=discord.ButtonStyle.primary)
|
||||||
|
async def skip(self, _, interaction2: discord.Interaction):
|
||||||
|
self.disable_all_items()
|
||||||
|
await interaction2.edit_original_response(view=self)
|
||||||
|
self.stop()
|
||||||
|
|
Loading…
Reference in a new issue