From 252883c8f190cd7e6dcf79dd9110541acb7013d1 Mon Sep 17 00:00:00 2001 From: Selyss <99344963+Selyss@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:14:03 -0500 Subject: [PATCH] move AdView to views --- cogs/inquiry.py | 25 +++---------------------- views/ad.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 views/ad.py diff --git a/cogs/inquiry.py b/cogs/inquiry.py index 9c0affb..da87835 100644 --- a/cogs/inquiry.py +++ b/cogs/inquiry.py @@ -6,13 +6,13 @@ from os import getenv from .utils.colors import EMBED_COLOR, SUCCESS, INQUIRY, REPLY, AD_EM_COLOR from .utils.formatting import format_footer +from views.ad import AdView load_dotenv() - +PAID_CATEGORY = int(getenv("PAID_CATEGORY")) CLOSED_CATEGORY = int(getenv("CLOSED_CATEGORY")) TICKET_CATEGORY = int(getenv("TICKET_CATEGORY")) -PAID_CATEGORY = int(getenv("PAID_CATEGORY")) REQUEST_CHANNEL = int(getenv("REQUEST_CHANNEL")) ADVERTISING_ROLE = int(getenv("ADVERTISING_ROLE")) AD_CHANNEL = int(getenv("AD_CHANNEL")) @@ -176,7 +176,7 @@ async def accept(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): await new_channel.send( content=f"<@{inter.user.id}> <@{ADVERTISING_ROLE}>", embed=em, - view=AdView(), + view=AdView(PAID_CATEGORY), ) emb = nextcord.Embed() emb.color = AD_EM_COLOR @@ -210,25 +210,6 @@ async def quickresponse(self, btn: nextcord.ui.Button, inter: nextcord.Interacti await inter.response.send_modal(QuickResponse(msg, content)) -class AdView(nextcord.ui.View): - def __init__(self) -> None: - super().__init__(timeout=None) - - @nextcord.ui.button( - label="Mark Paid", style=nextcord.ButtonStyle.green, custom_id="ticket:paid" - ) - async def paid(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): - if isinstance(inter.channel, nextcord.TextChannel): - category = nextcord.utils.get(inter.guild.categories, id=PAID_CATEGORY) - await inter.channel.edit(category=category) - em = nextcord.Embed() - em.color = SUCCESS - em.title = ":checkmark: Payment Received" - em.description = """Thank you for your purchase!\nIf you haven't already, please send your advertisement message and ensure if you are using any custom/nitro-accessed Emojis that they are present within the Discord you are advertising (emojis from our server are fine, too).\n\nIf another advertisement was recently posted, out of courtesy it will be given a reasonable amount of uptime before yours is posted.""" - em.set_footer(text=format_footer(inter.user.id)) - await inter.response.send_message(embed=em) - - class AdForm(nextcord.ui.Modal): def __init__(self) -> None: super().__init__( diff --git a/views/ad.py b/views/ad.py new file mode 100644 index 0000000..ce47b71 --- /dev/null +++ b/views/ad.py @@ -0,0 +1,23 @@ +import nextcord +from cogs.utils.colors import SUCCESS +from cogs.utils.formatting import format_footer + + +class AdView(nextcord.ui.View): + def __init__(self, paid_category=None) -> None: + super().__init__(timeout=None) + self.paid_category = paid_category + + @nextcord.ui.button( + label="Mark Paid", style=nextcord.ButtonStyle.green, custom_id="ticket:paid" + ) + async def paid(self, btn: nextcord.ui.Button, inter: nextcord.Interaction): + if isinstance(inter.channel, nextcord.TextChannel): + category = nextcord.utils.get(inter.guild.categories, id=self.paid_category) + await inter.channel.edit(category=category) + em = nextcord.Embed() + em.color = SUCCESS + em.title = ":checkmark: Payment Received" + em.description = """Thank you for your purchase!\nIf you haven't already, please send your advertisement message and ensure if you are using any custom/nitro-accessed Emojis that they are present within the Discord you are advertising (emojis from our server are fine, too).\n\nIf another advertisement was recently posted, out of courtesy it will be given a reasonable amount of uptime before yours is posted.""" + em.set_footer(text=format_footer(inter.user.id)) + await inter.response.send_message(embed=em)