Skip to content

Commit

Permalink
move AdView to views
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Dec 17, 2023
1 parent 81f9fcf commit 252883c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
25 changes: 3 additions & 22 deletions cogs/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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__(
Expand Down
23 changes: 23 additions & 0 deletions views/ad.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 252883c

Please sign in to comment.