Skip to content

Counting game#82

Draft
OpenSourceSimon wants to merge 2 commits intomasterfrom
counting
Draft

Counting game#82
OpenSourceSimon wants to merge 2 commits intomasterfrom
counting

Conversation

@OpenSourceSimon
Copy link
Copy Markdown
Member

No description provided.

Base automatically changed from development to master January 25, 2024 16:56
Comment thread cogs/counting.py

def __init__(self, bot: OGIROID):
self.bot = bot
self.count = 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dont store state in memory. We have a database, use it

Comment thread cogs/counting.py
async for message in self.channel.history(limit=10):
if message.author.bot:
continue
if message.content.isdigit():
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

strip the message

Comment thread cogs/counting.py
return
messages = await self.channel.history(limit=1).flatten()
last_message = messages[1]
print(f"{last_message.author.name}: {last_message.content}")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove debug prints

Comment thread cogs/counting.py
if message.author.bot or not message.content.isdigit():
return
messages = await self.channel.history(limit=1).flatten()
last_message = messages[1]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just... use the message arg passed into the function

Comment thread cogs/counting.py
messages = await self.channel.history(limit=1).flatten()
last_message = messages[1]
print(f"{last_message.author.name}: {last_message.content}")
if last_message.author == message.author and last_message.content.isdigit():
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

duplicate isdigit calls

Comment thread cogs/counting.py
elif message.content == str(self.count):
self.count += 1
# Add checkmark reaction
await message.add_reaction("✅")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

uh- I would have this be set for a channel. If the content isn't a num. delete it. No reactions

Comment thread cogs/counting.py
if last_message.author == message.author and last_message.content.isdigit():
embed = Embed(
title="Counting Game",
description=f"{message.author.mention}, you can't do this alone!",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no reason to not support an author sending multiple consecutive msgs

Comment thread cogs/counting.py
)
await self.channel.send(embed=embed)
self.count = 1
# TODO Implement leaderboard with db
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

todo ;-;

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.

3 participants