diff --git a/cogs/inquiry.py b/cogs/inquiry.py index 94b143c..b9af578 100644 --- a/cogs/inquiry.py +++ b/cogs/inquiry.py @@ -6,6 +6,7 @@ from os import getenv from .utils.colors import EMBED_COLOR, SUCCESS, INQUIRY, REPLY from .utils.formatting import get_date, get_time, format_footer +from .utils.helpers import create_ticket load_dotenv() @@ -99,15 +100,8 @@ async def callback(self, inter: nextcord.Interaction) -> None: person = await inter.guild.fetch_member(self.person) id = person.id name = person.name - category = nextcord.utils.get(inter.guild.categories, id=CLOSED_CATEGORY) - new_channel = await category.create_text_channel( - name=f"ticket-{name}", - reason=f"Created ticket for {id} - {name}", - topic=id, - ) - await inter.response.send_message( - f"Ticket created: <#{new_channel.id}>", ephemeral=True - ) + new_channel = await create_ticket(inter, person, CLOSED_CATEGORY) + # inquiry again emb = nextcord.Embed() emb.color = INQUIRY diff --git a/cogs/utils/helpers.py b/cogs/utils/helpers.py new file mode 100644 index 0000000..172404a --- /dev/null +++ b/cogs/utils/helpers.py @@ -0,0 +1,16 @@ +import nextcord + + +async def create_ticket( + inter: nextcord.Interaction, person: nextcord.Member, category +) -> nextcord.TextChannel: + category = nextcord.utils.get(inter.guild.categories, id=category) + new_channel: nextcord.TextChannel = await category.create_text_channel( + name=f"ticket-{person.name}", + reason=f"Created ticket for {person.id} - {person.name}", + topic=id, + ) + await inter.response.send_message( + f"Ticket created: <#{new_channel.id}>", ephemeral=True + ) + return new_channel