interactions.py icon indicating copy to clipboard operation
interactions.py copied to clipboard

feat: ability to define which shards connect

Open Wolfhound905 opened this issue 6 months ago • 0 comments

Pull Request Type

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

Description

Having one AutoShardedClient can be risky in the case of a fatal error in a users code. Leading for the entire bot to crash. With this feature, a user can call a microservice or other to determine what shards the AutoShardedClient should be running.

Changes

  • added shard_ids to AutoShardedClient classs

Test Scenarios

bot = AutoShardedClient(
    fetch_members=False,
    delete_unused_application_cmds=False,
    sync_interactions=False,
    total_shards=112,
    shard_ids=[12, 13, 14, 15, 16],
    basic_logging=True,
    log_level=logging.DEBUG,
)


@listen(Startup, delay_until_ready=True)
async def on_startup(event: Startup):
    print("Bot is ready")
    print(f"Logged in as {bot.user}")
    print(f"Bot ID: {bot.user.id}")
    print(f"Guilds: {len(bot.guilds)}")

Python Compatibility

  • [ ] I've ensured my code works on Python 3.10.x
  • [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
  • [x] 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

Wolfhound905 avatar Feb 12 '24 08:02 Wolfhound905