Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Dec 19, 2023
1 parent 658c5c3 commit d411b61
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
36 changes: 24 additions & 12 deletions cogs/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async def callback(self, inter: nextcord.Interaction) -> None:
person = await inter.guild.fetch_member(self.person)
id = person.id
name = person.name
nick = person.nick
category = nextcord.utils.get(inter.guild.categories, id=CLOSED_CATEGORY)
new_channel = await category.create_text_channel(
name=f"ticket-{name}",
Expand All @@ -99,7 +100,7 @@ async def callback(self, inter: nextcord.Interaction) -> None:
# inquiry again
emb = nextcord.Embed()
emb.color = INQUIRY
emb.set_author(name=f"{name} inquired:", icon_url=person.avatar)
emb.set_author(name=f"{nick} inquired:", icon_url=person.avatar)
emb.description = self.message
emb.set_footer(text=format_footer(id))
await new_channel.send(
Expand Down Expand Up @@ -138,21 +139,23 @@ async def accept(self, btn: nextcord.ui.Button, inter: nextcord.Interaction):
person = await inter.guild.fetch_member(msg)
id = person.id
name = person.name
category = nextcord.utils.get(inter.guild.categories, id=AD_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
)
nick = person.nick
await inter.message.delete()
em = nextcord.Embed()
if inter.channel.id == AD_CHANNEL:
# IS AD
category = nextcord.utils.get(inter.guild.categories, id=AD_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
)
em.color = SUCCESS
em.set_author(
name=f"{name} requested an advertisement:", icon_url=person.avatar
name=f"{nick} requested an advertisement:", icon_url=person.avatar
)
em.description = content
em.set_footer(text=format_footer(id))
Expand All @@ -173,8 +176,17 @@ async def accept(self, btn: nextcord.ui.Button, inter: nextcord.Interaction):

else:
# IS NOT AD
category = nextcord.utils.get(inter.guild.categories, id=TICKET_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
)
em.color = INQUIRY
em.set_author(name=f"{name} inquired:", icon_url=person.avatar)
em.set_author(name=f"{nick} inquired:", icon_url=person.avatar)
em.description = content
em.set_footer(text=format_footer(id))

Expand Down
3 changes: 2 additions & 1 deletion cogs/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class CloseRequest(nextcord.ui.View):
def __init__(self, inter: nextcord.Interaction, old_channel: nextcord.TextChannel):
def __init__(self, inter=None, old_channel=None):
super().__init__(timeout=60)
self.inter = inter
self.old_channel = old_channel
Expand Down Expand Up @@ -59,6 +59,7 @@ async def on_ready(self) -> None:

if not self.persistent_views_added:
self.bot.add_view(CloseView())
self.bot.add_view(CloseRequest())
self.persistent_views_added = True

@slash_command(name="close", description="close a ticket")
Expand Down

0 comments on commit d411b61

Please sign in to comment.