Skip to content

Commit

Permalink
VIEWS: Use Confirmation view for stub view for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamievlin committed Dec 28, 2023
1 parent 0462fd3 commit c431687
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions bot/cogs/dm_comms.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
import discord
from discord import DMChannel, Interaction, Message
from discord import DMChannel, Message
from discord.ext import commands
from discord.ui import Button, button
from rodhaj import Rodhaj


class StubView(discord.ui.View):
def __init__(self, base_message: Message):
super().__init__(timeout=30)
self._base_msg = base_message
self._replied = False

async def on_timeout(self) -> None:
if not self._replied:
await self._base_msg.reply("You have not responded within 30 seconds")

@button(label="Create Thread")
async def create_thread_btn(self, interaction: Interaction, btn: Button):
if not self._replied:
self._replied = True
btn.disabled = True
# thread code creation goes to here
await interaction.message.edit(content="Thread created!", view=self)
await interaction.response.send_message("Thread created")


class DmCommunications(commands.Cog):
def __init__(self, bot: Rodhaj):
self._bot = bot
self._pool = bot.pool

async def handle_user_no_thread(self, message: Message):
await message.reply(
channel = message.channel
context = await self._bot.get_context(message)
result = await context.prompt(
"Seems like you do not have an active thread. "
+ "Would you want to create one?",
view=StubView(message),
timeout=600,
delete_after=True,
)

# Code to create thread here
if result:
await channel.send(
"Thread created; please use the following "
+ "thread for all further communications."
)
else:
await channel.send("No worries!")

async def handle_dm(self, message: Message):
query = """
SELECT id
Expand Down

0 comments on commit c431687

Please sign in to comment.