Skip to content

feat: add /madd slash cmd#2234

Open
7he4lph4 wants to merge 2 commits into
avrae:nightlyfrom
7he4lph4:slash-madd
Open

feat: add /madd slash cmd#2234
7he4lph4 wants to merge 2 commits into
avrae:nightlyfrom
7he4lph4:slash-madd

Conversation

@7he4lph4

Copy link
Copy Markdown
Contributor

Summary

Implements a new /madd slash command as a secondary way of adding monsters to combat initiative. /madd learns user's favourite monsters over time as they keep adding monsters to combat, it then boosts user's frequently added monsters to the top of the autocomplete search results.

Changelog Entry

  • Added new slash command /madd as a secondary way of adding monsters to combat initiative.

Checklist

PR Type

  • This PR is a code change that implements a feature request.
  • This PR fixes an issue.
  • This PR adds a new feature that is not an open feature request.
  • This PR is not a code change (e.g. documentation, README, ...)

Other

  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • If code changes were made then they have been tested.
  • I have updated the documentation to reflect the changes.

Comment thread cogs5e/initiative/cog.py
Comment on lines +411 to +424
seen_objects = set()
for name, mid in favorites:
if mid and mid in choices_by_id:
monster = choices_by_id[mid]
if monster not in seen_objects:
recent.append(monster)
seen_objects.add(monster)
elif name in choices_by_name_homebrew:
for monster in choices_by_name_homebrew[name]:
if monster not in seen_objects:
recent.append(monster)
seen_objects.add(monster)
if len(recent) >= AUTOCOMPLETE_MAX_RESULTS:
break

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comment or two here would be great to improve clarity

Comment thread cogs5e/initiative/cog.py
)

@commands.command(hidden=True)
async def mfav(self, ctx):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!monster favorites maybe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that just a monster called "favourites" lol I thought we keep this as a hidden dev cmd that no one really would use, users should be able to use their top 25 fav monsters already in the auto-complete when they do /madd

Comment thread cogs5e/lookup.py

batch = []
batch_size = 100
async for key in self.bot.rdb.iscan(match=pattern):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments here explaining behavior would be great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants