XenotropicDev / TheOracle2

Complete Rework of TheOracle using new discord features
4 stars 2 forks source link

GuildPlayer + last character used as default for pc-action-roll #27

Closed rsek closed 2 years ago

rsek commented 2 years ago

resolves #17 : adds GuildPlayer (and a coresponding DbSet, GuildPlayers), which is keyed by both user id and guild id, intended to hold user preferences at the per-guild level. at the moment it's mainly a vehicle for LastUsedPcId.

discord appears to cache some autocomplete results (and their ordering) in the client, so sorting by last used PlayerCharacter may not be possible. i suspect this an intentional design choice by discord: when the DB adds a new character, it adds them to the bottom of the autocomplete list without altering the order of the previous items. it does consistently update after the bot restarts (the only way i was able to tell the sorting was actually working, in fact), but there may be other triggers (restarting the client? time elapsing?).

i've left the OrderByDescending in there for now for further testing, but i suspect may not be possible to reorder the results after every LastUsedPcId change.

other things i need to resolve before this is merged:

rsek commented 2 years ago

ref: #17

rsek commented 2 years ago

ha, i think i assumed 'default' meant something other than... you know, the actual default value of an optional slash command parameter. which i've now implemented in action-pc-roll and it appears to work. i've left it out from various pc editing commands however, because that takes more work to undo than a roll (which can simply be ignored) with the incorrect PC than to undo changing their stats. still, i think it bears user testing, so i'll probably add it tomorrow.

i also think action-pc-roll could benefit from its roll result embed including the character name so that it's clear what PC has just been rolled. since the roll embed has a user-settable Description field, i think this would be best done in the Author field alongside the stat, e.g. "Action Roll: Marc Progress, +Edge"

rsek commented 2 years ago

/action-pc-roll now handles bad PlayerCharacter IDs by providing a list of the GuildPlayer's owned PCs as MessageComponents (buttons or a select menu, depending on the number). on interaction, they forward the roll's parameters to an ActionRoll by that character.

i also removed the autocomplete list sorting since it's not doing much.

todo:

rsek commented 2 years ago

i think this is pretty usable now. still haven't tracked down why the link isn't working in this specific instance - may just be some quirk of ephemerals, i'm not sure. but at this point i think there'd be more benefit to getting it into people's hands and seeing how they react to it.

rsek commented 2 years ago