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/wit 132 Implement guessing functionality #54

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ledanielhuynh
Copy link
Contributor

No description provided.

Copy link

linear bot commented Nov 8, 2023

WIT-131 Setting up COGs

Set up the Cog for the 24 game

Copy link
Contributor

@katejoh katejoh left a comment

Choose a reason for hiding this comment

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

Hi Daniel, looks great so far! I've suggested a few minor style changes and bugfixes as I found some errors while testing. Let me know if you have any questions!

cogs/24.py Outdated Show resolved Hide resolved
cogs/24.py Outdated Show resolved Hide resolved
cogs/24.py Outdated Show resolved Hide resolved
elif eval(current_input_math) != 24:
await self.update_message_incorrect(
interaction, "Sorry, that's not 24!"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a condition and message for if the user enters an input that causes an error when evaluated (e.g. they only input an open parenthesis, only have two numbers without any operators, click equals without having inputted anything, etc.), as this currently causes an error and a 'This interaction failed' message.

cogs/24.py Outdated Show resolved Hide resolved
cogs/24.py Outdated Show resolved Hide resolved
cogs/24.py Outdated Show resolved Hide resolved
cogs/24.py Outdated
Comment on lines 261 to 271
embed = discord.Embed(title="24", color=discord.Color.orange())

embed.add_field(
name="Your numbers are:",
value=f"` {self.numbers[0]} {self.numbers[1]} {self.numbers[2]} {self.numbers[3]} `",
inline=False,
)

embed.add_field(
name="Input:", value="`" + self.current_input + "`", inline=False
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this repeated code into a function which returns the embed. You can call this function at the start of each update_message function (might have to pass in the colour), then add the unique fields + respond to the interaction afterwards!

# if button_id in self.numbers:
# item.disabled = True

await self.update_message(interaction)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line runs every time a button is pressed, even if the message has already been edited from a previous condition (e.g. line 240 after the user has gotten it correct), causing an error:
image

Keep in mind that there should only be one response for each interaction!

cogs/24.py Show resolved Hide resolved
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