Skip to content

feat: add load_extensions method #1530

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
merged 6 commits into from
Aug 15, 2023
Merged

feat: add load_extensions method #1530

merged 6 commits into from
Aug 15, 2023

Conversation

maksims8
Copy link
Contributor

@maksims8 maksims8 commented Aug 12, 2023

Pull Request Type

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

Description

This commit introduces a new method in which you can overcome manually loading extensions you have in your project down to just one line and therefore allows your project setup time and complexity to be decreased.

Changes

  • Introduces a new method to load extensions without manually looping and loading.

Test Scenarios

Non-recursive (loaded exts.example):

import interactions

intents = interactions.Intents.DEFAULT | interactions.Intents.MESSAGE_CONTENT
client = interactions.Client(intents=intents)

@interactions.listen()
async def on_ready():
    print("Client is ready.")

client.load_extensions("exts") # Folder is located in the root of the project
client.start("TOKEN")

Recursive (loaded exts.example & exts.subdir.example_two):

import interactions

intents = interactions.Intents.DEFAULT | interactions.Intents.MESSAGE_CONTENT
client = interactions.Client(intents=intents)

@interactions.listen()
async def on_ready():
    print("Client is ready.")

client.load_extensions("exts", recursive=True) # Folder is located in the root of the project
client.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

@maksims8 maksims8 requested a review from i0bs August 12, 2023 21:15
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.

Other than a stray print() statement, this looks really good

@maksims8 maksims8 requested a review from silasary August 13, 2023 02:25
@i0bs i0bs merged commit f3ba43d into interactions-py:unstable Aug 15, 2023
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