Skip to content

feat: cookie hunter #140

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

feat: cookie hunter #140

wants to merge 11 commits into from

Conversation

luca-montaigut
Copy link
Contributor

@luca-montaigut luca-montaigut commented Mar 23, 2024

Add cookie hunter game base on this idea : https://discord.com/channels/174169014568878080/1220425958050500689/1220425958050500689

The feature:

  • the hunt start when the bot is ready
  • /cookie-hunter-enable => allow grandma to send her message in this channel
  • /cookie-hunter-disable => same in reverse
  • /cookie-hunter-add-daily-log => add log to this channel after the daily hunt
  • /cookie-hunter-remove-daily-log => same in reverse
  • /cookie-hunter-start => restart the cron
  • /cookie-hunter-scoreboard => see global scoreboard

cookieHunterChannels: string[];
currentHuntMessageId: string;
cookieHunterDailyCount: Record<string, number>;
cookieHunterDailyLogChannels: string[];

Choose a reason for hiding this comment

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

what about adding a bit of jsdoc on top of some of these entries?

it may not be obvious what we are storing here without looking at the code

is cookieHunterDailyCount a discord user id <> score record?
what is cookieHunterDailyLogChannels ?

await cookieMessage.react('🥛');
await cookieMessage.react('🍪'); // 1 point for grandma here, she beats everyone who doesn't find her

setTimeout(() => void dailyHuntEnd(client, cookieMessage), ONE_MINUTE);

Choose a reason for hiding this comment

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

maybe overkill to manage this now, and i m not sure often the bot crash/restarts. but what happens if the bot crashes? the daily hunt will never stop

a simple fix would be to manage it in countCookies method. when some dude react, you check if the message was posted more than a minute ago and if so, you don't count the point and manually call dailyHuntEnd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I'm not a big fan of this setTimeout too... I will need to store the start time to do that but look like a good solution to avoid an infinite hunt

jobCurrentlyRunning.stop();
}
jobCurrentlyRunning = new CronJob(
IT_IS_SNACK_TIME,

Choose a reason for hiding this comment

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

this is not random ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not for the V1

@potb potb removed their request for review June 11, 2024 10:33
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants