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

Fixed a few issues with the new poll command #248

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions bot/extensions/polls/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ async def callback(self, interaction: core.InteractionType):
if len(embed.fields) >= 1:
self.view.add_item(DeletePollOptions(embed.fields))

# We removed a choice so there gotta be some space for more
field_count = len(embed.fields)

# We removed a choice so reset the disabled state of the buttons
add_choice_btn = discord.utils.get(self.view.children, custom_id=CreatePollView.ADD_CUSTOM_ID)
create_poll_btn = discord.utils.get(self.view.children, custom_id=CreatePollView.CREATE_CUSTOM_ID)
add_choice_btn.disabled = False
create_poll_btn.disabled = field_count < 2

await interaction.response.edit_message(embed=embed, view=self.view)

Expand Down Expand Up @@ -105,8 +109,9 @@ async def create_poll(self, interaction: core.InteractionType, _button: ui.Butto
"You can't create a poll with less than 2 choices", ephemeral=True
)

await interaction.response.send_message(embed=embed)
message = await interaction.original_response()
await interaction.response.defer()
await interaction.delete_original_response()
message = await interaction.channel.send(embed=embed)

for i in range(0, len(embed.fields)):
await message.add_reaction(emojis[i])
Loading