generated from HoloTech/holotech-plugin-template
feat(discord): Inline reward editing
This commit is contained in:
+34
-4
@@ -323,9 +323,19 @@ class CampaignCog(LionCog):
|
|||||||
)
|
)
|
||||||
@appcmds.describe(
|
@appcmds.describe(
|
||||||
rewardid="Earned reward to edit",
|
rewardid="Earned reward to edit",
|
||||||
|
fulfilled="Whether this reward has been completed or not.",
|
||||||
|
reference="Reference information for this reward, e.g. image or message URL",
|
||||||
|
notes="Any additional notes",
|
||||||
)
|
)
|
||||||
@appcmds.rename(rewardid="reward")
|
@appcmds.rename(rewardid="reward")
|
||||||
async def campaign_editreward_cmd(self, ctx: LionContext, rewardid: str):
|
async def campaign_editreward_cmd(
|
||||||
|
self,
|
||||||
|
ctx: LionContext,
|
||||||
|
rewardid: str,
|
||||||
|
fulfilled: Optional[bool] = None,
|
||||||
|
reference: Optional[str] = None,
|
||||||
|
notes: Optional[str] = None
|
||||||
|
):
|
||||||
# For this we'll just open the reward editor
|
# For this we'll just open the reward editor
|
||||||
# Will need to identify the reward with autocomplete. Can use the reward id directly..
|
# Will need to identify the reward with autocomplete. Can use the reward id directly..
|
||||||
if not rewardid.isdigit():
|
if not rewardid.isdigit():
|
||||||
@@ -353,11 +363,31 @@ class CampaignCog(LionCog):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Okay, this is our reward, and author has permission to modify it. Spin the modal.
|
# Okay, this is our reward, and author has permission to modify it.
|
||||||
modal = RewardEditor.from_reward(reward)
|
|
||||||
|
|
||||||
currently_fluffed = reward.fulfilled_at is not None
|
currently_fluffed = reward.fulfilled_at is not None
|
||||||
|
|
||||||
|
update_args = {}
|
||||||
|
if fulfilled is not None:
|
||||||
|
if fulfilled and not currently_fluffed:
|
||||||
|
# Reward has been fluffed
|
||||||
|
update_args["fulfilled_at"] = utc_now()
|
||||||
|
elif currently_fluffed and not fulfilled:
|
||||||
|
# Reward has been unfluffed
|
||||||
|
update_args["fulfilled_at"] = None
|
||||||
|
if reference is not None and reference != reward.reference:
|
||||||
|
update_args["reference"] = reference
|
||||||
|
if notes is not None and notes != reward.modnote:
|
||||||
|
update_args["modnote"] = notes
|
||||||
|
|
||||||
|
if update_args:
|
||||||
|
await ctx.interaction.response.defer(thinking=True, ephemeral=True)
|
||||||
|
await campaign.update_reward(reward.earned_id, **update_args)
|
||||||
|
await ctx.interaction.followup.send(
|
||||||
|
content="Reward updated!"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
modal = RewardEditor.from_reward(reward)
|
||||||
|
|
||||||
@modal.submit_callback()
|
@modal.submit_callback()
|
||||||
async def on_editor_submit(interaction: discord.Interaction):
|
async def on_editor_submit(interaction: discord.Interaction):
|
||||||
update_args = {}
|
update_args = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user