Skip to content

fix: correctly unpack startup tasks in AutoShardedClient #1688

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

Merged

Conversation

mifuyutsuki
Copy link
Contributor

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

Fixes AutoShardedClient bug which causes the client to dispatch an error involving "unhashable type: dict" while loading extensions. This error causes the client to not run extensions' defined async_start() methods.

Changes

  • Change how async_startup_tasks is unpacked in AutoShardedClient to follow the method used by Client

Related Issues

Fixes #1687

Test Scenarios

Create and run a bot with AutoShardedClient and extension(s). The code below uses jurigged extension (requires jurigged). In this specific scenario, while the bot is running, try calling the main command before and after editing the contents of ctx.send().

from interactions import AutoShardedClient, Intents, slash_command
bot = AutoShardedClient(intents=Intents.DEFAULT)

@slash_command(name="main", description="Main command")
async def main_cmd(ctx):
  await ctx.send("Sent from main")

bot.load_extension("interactions.ext.jurigged")
bot.start("token")

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

Copy link
Member

@silasary silasary left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link
Member

@AstreaTSS AstreaTSS left a comment

Choose a reason for hiding this comment

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

Suggesting it's a copy of behavior from Client, it seems good to me.

@AstreaTSS AstreaTSS merged commit bca121e into interactions-py:unstable May 30, 2024
2 checks passed
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