Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: cookie hunter #140

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

src/modules/cookieHunter/cookieHunter.helpers.ts Outdated Show resolved Hide resolved
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 ?

src/helpers/channels.ts Outdated Show resolved Hide resolved
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

src/modules/cookieHunter/cookieHunter.helpers.ts Outdated Show resolved Hide resolved
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

src/modules/cookieHunter/cookieHunter.helpers.ts Outdated Show resolved Hide resolved
@potb potb removed their request for review June 11, 2024 10:33
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