Add submit button on group create.

This commit is contained in:
alwayscompiling
2022-12-08 23:16:56 -05:00
parent 411f8ab275
commit 58dbe547bb
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ def setup(bot: commands.Bot):
"""
Adds all command classes to bot.
"""
bot.add_cog(CreateCog())
bot.add_cog(CreateCog(bot))
bot.add_cog(DeleteCog())
bot.add_cog(RefreshCog(bot))
bot.add_cog(SetCog())
+6 -3
View File
@@ -6,10 +6,11 @@ from typing import Optional
import nextcord
from nextcord.ext import commands
from sqlalchemy import select, exc
from sqlalchemy import exc, select
from sqlalchemy.orm import Session
# pylint: disable=import-error
from cogs.submission.submission_views import SubmissionCreateButton
from utilities.sql_data_classes import Category, CategoryGroup, engine
from utilities.utils import MAX_LINE_LENGTH, autofill_groups, send_highscore_message
@@ -19,10 +20,11 @@ class CreateCog(commands.Cog, name="Create Cog"):
Class holds commands for creating things.
"""
def __init__(self) -> None:
def __init__(self, bot: commands.Bot) -> None:
"""
Default constructor for CreateCog class.
"""
self._bot = bot
@nextcord.slash_command(default_member_permissions=nextcord.Permissions(administrator=True))
async def create(self, interaction: nextcord.Interaction):
@@ -147,7 +149,8 @@ class CreateCog(commands.Cog, name="Create Cog"):
try:
session.add(new_group)
session.commit()
await send_highscore_message(session, interaction.guild, new_group)
message: nextcord.Message = await send_highscore_message(session, interaction.guild, new_group)
await message.edit(view=SubmissionCreateButton(self._bot))
await interaction.response.send_message(f'"{group_name}" has been created!', ephemeral=True)
except exc.IntegrityError:
# Category Group already exists in guild