Files
adventures/src/modules/dreamspace/cog.py

71 lines
2.4 KiB
Python

import asyncio
import discord
from discord import app_commands as appcmds
from discord.ext import commands as cmds
from meta import LionCog, LionBot, LionContext
from meta.logger import log_wrap
from utils.lib import utc_now
from . import logger
from .ui.docviewer import DocumentViewer
class DreamCog(LionCog):
"""
Discord-facting interface for Dreamspace Adventures
"""
def __init__(self, bot: LionBot):
self.bot = bot
self.data = bot.core.datamodel
async def cog_load(self):
pass
@log_wrap(action="Dreamer migration")
async def migrate_dreamer(self, source_profile, target_profile):
"""
Called when two dreamer profiles need to merge.
For example, when a user links a second twitch profile.
:TODO-MARKER:
Most of the migration logic is simple, e.g. just update the profileid
on the old events to the new profile.
The same applies to transactions and probably to inventory items.
However, there are some subtle choices to make, such as what to do
if both the old and the new profile have an active specimen?
A profile can only have one active specimen at a time.
There is also the question of how to merge user preferences, when those exist.
"""
...
# User command: view their dreamer card, wallet inventory etc
# (Admin): View events/documents matching certain criteria
# (User): View own event cards with info?
# Let's make a demo viewer which lists their event cards and let's them open one via select?
# /documents -> Show a paged list of documents, select option displays the document in a viewer
@cmds.hybrid_command(
name='documents',
description="View your printer log!"
)
async def documents_cmd(self, ctx: LionContext):
profile = await self.bot.get_cog('ProfileCog').fetch_profile_discord(ctx.author)
events = await self.data.Events.fetch_where(user_id=profile.profileid)
docids = [event.document_id for event in events if event.document_id is not None]
if not docids:
await ctx.error_reply("You don't have any documents yet!")
return
view = DocumentViewer(self.bot, ctx.interaction.user.id, filter=(self.data.Document.document_id == docids))
await view.run(ctx.interaction)
# (User): View Specimen information