Skip to content

Comments

Feat/wit 132 Implement guessing functionality#54

Open
ledanielhuynh wants to merge 10 commits intomainfrom
feat/WIT-131-setting-up-cogs-fix
Open

Feat/wit 132 Implement guessing functionality#54
ledanielhuynh wants to merge 10 commits intomainfrom
feat/WIT-131-setting-up-cogs-fix

Conversation

@ledanielhuynh
Copy link
Contributor

No description provided.

@linear
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!

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
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!

ItsLame and others added 3 commits February 13, 2024 20:45
Co-authored-by: katejoh <101443389+katejoh@users.noreply.github.com>
Co-authored-by: katejoh <101443389+katejoh@users.noreply.github.com>
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