Skip to content

Commit

Permalink
persistance
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Nov 28, 2023
1 parent 59cf098 commit d88c40a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
10 changes: 3 additions & 7 deletions cogs/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ async def mark_paid(interaction):
class QuestionForm(nextcord.ui.Modal):
def __init__(self):
super().__init__(
title="Contact Marlow", custom_id="persistant_modal:question", timeout=None
title="Contact Marlow",
custom_id="persistant_modal:question",
timeout=None,
)

self.details = nextcord.ui.TextInput(
Expand Down Expand Up @@ -122,12 +124,6 @@ async def ad_btn_callback(interaction):
class Inquiry(Cog):
def __init__(self, bot: Bot) -> None:
self.bot = bot
self.persistent_modal_added = False

async def add_persistent_modal(self):
if not self.persistent_modal_added:
self.bot.add_view(AdForm())
self.persistent_modal_added = True

@slash_command(name="deploy", description="Send inquiry embed")
async def deploy(self, ctx) -> None:
Expand Down
25 changes: 19 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
import nextcord
from nextcord.ext.commands import Bot
from nextcord.ext import commands
from dotenv import load_dotenv

from cogs.inquiry import AdForm, QuestionForm

load_dotenv()

TOKEN = os.getenv("BOT")
Expand All @@ -12,16 +14,27 @@
intents.message_content = True

print("[System] Beginning load...")


class Bot(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.persistent_modals_added = False

async def on_ready(self):
if not self.persistent_modals_added:
self.add_modal(AdForm())
self.add_modal(QuestionForm())
self.persistent_modals_added = True

print(f"[System] Logged in as {bot.user.name}.")


bot = Bot(command_prefix="!", intents=intents)
bot.load_extension("cogs.inquiry")
bot.load_extension("cogs.ticket")


@bot.event
async def on_ready():
print(f"[System] Logged in as {bot.user.name}.")


if not TOKEN:
print("[System] Missing TOKEN environment variable.")

Expand Down

0 comments on commit d88c40a

Please sign in to comment.