From c92fd0822ddef27b7caa4dab82105093bf146b7a Mon Sep 17 00:00:00 2001 From: Selyss <99344963+Selyss@users.noreply.github.com> Date: Mon, 27 Nov 2023 20:46:44 -0500 Subject: [PATCH] update --- cogs/inquiry.py | 28 ++++++++++++++++------------ cogs/ticket.py | 4 ++-- main.py | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cogs/inquiry.py b/cogs/inquiry.py index 10a3ebe..3b8a210 100644 --- a/cogs/inquiry.py +++ b/cogs/inquiry.py @@ -1,11 +1,11 @@ +from datetime import datetime from nextcord import slash_command from nextcord.ext.commands import Bot, Cog -from datetime import datetime import nextcord import json -with open("config.json", "r") as config_file: +with open("config.json", "r", encoding="utf-8") as config_file: config = json.load(config_file) REQUEST_CHANNEL: int = config["request_channel"] AD_CHANNEL: int = config["advertise_channel"] @@ -18,6 +18,14 @@ ADVERTISING_ROLE: int = 1096584186304942111 +def get_date() -> str: + return datetime.now().strftime("%m/%d/%Y") + + +def get_time() -> str: + return datetime.now().strftime("%-I:%M %p") + + class TicketView(nextcord.ui.View): def __init__(self) -> None: super().__init__(timeout=None) @@ -102,9 +110,7 @@ async def callback(self, inter: nextcord.Interaction) -> None: em.set_author(icon_url=inter.user.avatar, name=inter.user.name) em.add_field(name="**CONTACT REQUEST ACCEPTED**", value="", inline=False) em.add_field(name="**reason**", value=self.details.value, inline=False) - current_date = datetime.now().strftime("%m/%d/%Y") - current_time = datetime.now().strftime("%-I:%M %p") - em.set_footer(text=f"{inter.user.id} • {current_date} • {current_time}") + em.set_footer(text=f"{inter.user.id} • {get_date()} • {get_time()}") await new_channel.send( content=f"<@{inter.user.id}> <@{MARLOW_ID}> <@{ADVERTISING_ROLE}>", @@ -137,9 +143,7 @@ async def callback(self, interaction: nextcord.Interaction) -> None: em = nextcord.Embed() em.set_author(icon_url=interaction.user.avatar, name=interaction.user.name) em.add_field(name="**reason**", value=self.details.value) - current_date = datetime.now().strftime("%m/%d/%Y") - current_time = datetime.now().strftime("%-I:%M %p") - em.set_footer(text=f"{inter.user.id} • {current_date} • {current_time}") + em.set_footer(text=f"{inter.user.id} • {get_date()} • {get_time()}") await target_channel.send(embed=em, view=RequestView()) @@ -150,7 +154,7 @@ def __init__(self, bot: Bot) -> None: self.persistent_modal_added = False @Cog.listener() - async def on_ready(self): + async def on_ready(self) -> None: if not self.persistent_modal_added: self.bot.add_view(RequestView()) self.bot.add_view(TicketView()) @@ -158,8 +162,8 @@ async def on_ready(self): self.persistent_modal_added = True @slash_command(name="deploy", description="Send inquiry embed") - async def deploy(self, ctx) -> None: - if isinstance(ctx.channel, nextcord.TextChannel): + async def deploy(self, inter: nextcord.Interaction) -> None: + if isinstance(inter.channel, nextcord.TextChannel): em = nextcord.Embed( title="📫 Contact Request", description=""" @@ -171,7 +175,7 @@ async def deploy(self, ctx) -> None: color=EMBED_COLOR, ) - await ctx.channel.send(embed=em, view=TicketView()) + await inter.channel.send(embed=em, view=TicketView()) def setup(bot: Bot) -> None: diff --git a/cogs/ticket.py b/cogs/ticket.py index 9b46ed2..bca028a 100644 --- a/cogs/ticket.py +++ b/cogs/ticket.py @@ -1,9 +1,9 @@ +import json from nextcord import SlashOption, TextChannel, slash_command from nextcord.ext.commands import Bot, Cog import nextcord -import json -with open("config.json", "r") as config_file: +with open("config.json", "r", encoding="utf-8") as config_file: config = json.load(config_file) diff --git a/main.py b/main.py index 9d461df..50f4dad 100644 --- a/main.py +++ b/main.py @@ -19,7 +19,7 @@ @bot.event async def on_ready(): - print(f"[System] Logged in as {bot.user.name}.") + print(f"[System] Logged in as {bot.user.name}.") # type: ignore if not TOKEN: