Skip to content

Commit

Permalink
feat: 2.3.4 (#374)
Browse files Browse the repository at this point in the history
* Fix typo in docstring

* Fix custom option converter not being initialized for slash commands (#324)

* Update nox requirement from ~=2022.11.21 to ~=2023.4.22 (#318)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update hikari requirement from ~=2.0.0.dev118 to ~=2.0.0.dev119 (#322)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update sphinx requirement from ~=6.1.3 to ~=7.0.1 (#323)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update furo requirement from ~=2023.3.27 to ~=2023.5.20 (#327)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update hikari requirement from ~=2.0.0.dev119 to ~=2.0.0.dev120 (#329)

Updates the requirements on [hikari](https://github.com/hikari-py/hikari) to permit the latest version.
- [Release notes](https://github.com/hikari-py/hikari/releases)
- [Changelog](https://github.com/hikari-py/hikari/blob/master/CHANGELOG.md)
- [Commits](hikari-py/hikari@2.0.0.dev119...2.0.0.dev120)

---
updated-dependencies:
- dependency-name: hikari
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update croniter requirement from ~=1.3.14 to ~=1.4.1 (#330)

Updates the requirements on [croniter](https://github.com/kiorky/croniter) to permit the latest version.
- [Changelog](https://github.com/kiorky/croniter/blob/master/CHANGELOG.rst)
- [Commits](corpusops/croniter@1.3.14...1.4.1)

---
updated-dependencies:
- dependency-name: croniter
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update types-croniter requirement from ~=1.3.2 to ~=1.4.0 (#331)

Updates the requirements on [types-croniter](https://github.com/python/typeshed) to permit the latest version.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-croniter
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: thomm.o <[email protected]>

* Update furo requirement from ~=2023.5.20 to ~=2023.8.19 (#340)

Updates the requirements on [furo](https://github.com/pradyunsg/furo) to permit the latest version.
- [Release notes](https://github.com/pradyunsg/furo/releases)
- [Changelog](https://github.com/pradyunsg/furo/blob/main/docs/changelog.md)
- [Commits](pradyunsg/furo@2023.05.20...2023.08.19)

---
updated-dependencies:
- dependency-name: furo
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update sphinx requirement from ~=7.0.1 to ~=7.2.5 (#342)

Updates the requirements on [sphinx](https://github.com/sphinx-doc/sphinx) to permit the latest version.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES)
- [Commits](sphinx-doc/sphinx@v7.0.1...v7.2.5)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix mypy, improve slotting, swap dataclasses for attrs-defined classes

* Update sphinx requirement from ~=7.2.5 to ~=7.2.6 (#345)

Updates the requirements on [sphinx](https://github.com/sphinx-doc/sphinx) to permit the latest version.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES)
- [Commits](sphinx-doc/sphinx@v7.2.5...v7.2.6)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update hikari requirement from ~=2.0.0.dev120 to ~=2.0.0.dev121 (#344)

Updates the requirements on [hikari](https://github.com/hikari-py/hikari) to permit the latest version.
- [Release notes](https://github.com/hikari-py/hikari/releases)
- [Changelog](https://github.com/hikari-py/hikari/blob/master/CHANGELOG.md)
- [Commits](hikari-py/hikari@2.0.0.dev120...2.0.0.dev121)

---
updated-dependencies:
- dependency-name: hikari
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update furo requirement from ~=2023.8.19 to ~=2023.9.10 (#343)

Updates the requirements on [furo](https://github.com/pradyunsg/furo) to permit the latest version.
- [Release notes](https://github.com/pradyunsg/furo/releases)
- [Changelog](https://github.com/pradyunsg/furo/blob/main/docs/changelog.md)
- [Commits](pradyunsg/furo@2023.08.19...2023.09.10)

---
updated-dependencies:
- dependency-name: furo
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update DataStore docstring to mention an instance is attached to BotApp

* Fix documentation build (#349)

* Fix documentation build

* Remove deprecated method of specifying python version

* Actually fix doc build this time

* Ok actually for real its fixed now

* Fix localization options not being passed to subcommands or options (#325)

* Fix localization options not being passed to subcommands or options

Signed-off-by: davfsa <[email protected]>

* Remove duplicated set_name_localizations

* Black formatting fixes

* Don't call set_desc_locales on non-SlashCommandBuilder instances

---------

Signed-off-by: davfsa <[email protected]>

* Lint and typecheck fixes (#354)

* CI improvements, more info below

- slotscheck has been added
- isort was swapped for ruff
- format session was renamed to format_check
- sphinx is no longer a default session
- workflows will no longer run on dependabot branches, only on the actual dependency update PR (and pushes to other branches)

* Update ruff requirement from ~=0.0.292 to ~=0.1.0 (#355)

Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@v0.0.292...v0.1.0)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update black requirement from ~=23.9.1 to ~=23.10.0 (#356)

Updates the requirements on [black](https://github.com/psf/black) to permit the latest version.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](psf/black@23.9.1...23.10.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update croniter requirement from ~=1.4.1 to ~=2.0.1 (#353)

Updates the requirements on [croniter](https://github.com/kiorky/croniter) to permit the latest version.
- [Changelog](https://github.com/kiorky/croniter/blob/master/CHANGELOG.rst)
- [Commits](corpusops/croniter@1.4.1...2.0.1)

---
updated-dependencies:
- dependency-name: croniter
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update types-croniter requirement from ~=1.4.0 to ~=2.0.0 (#352)

Updates the requirements on [types-croniter](https://github.com/python/typeshed) to permit the latest version.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-croniter
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update mypy requirement from ~=1.6.0 to ~=1.6.1 (#357)

Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](python/mypy@v1.6.0...v1.6.1)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update black requirement from ~=23.10.0 to ~=23.10.1 (#359)

Updates the requirements on [black](https://github.com/psf/black) to permit the latest version.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](psf/black@23.10.0...23.10.1)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update ruff requirement from ~=0.1.0 to ~=0.1.1 (#358)

Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@v0.1.0...v0.1.1)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update ruff requirement from ~=0.1.1 to ~=0.1.3 (#361)

Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@v0.1.1...v0.1.3)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): update slotscheck requirement from ~=0.17.0 to ~=0.17.1 (#363)

Updates the requirements on [slotscheck](https://github.com/ariebovenberg/slotscheck) to permit the latest version.
- [Release notes](https://github.com/ariebovenberg/slotscheck/releases)
- [Changelog](https://github.com/ariebovenberg/slotscheck/blob/main/CHANGELOG.rst)
- [Commits](ariebovenberg/slotscheck@v0.17.0...v0.17.1)

---
updated-dependencies:
- dependency-name: slotscheck
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): update black requirement from ~=23.10.1 to ~=23.11.0 (#364)

Updates the requirements on [black](https://github.com/psf/black) to permit the latest version.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](psf/black@23.10.1...23.11.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): update hikari requirement from ~=2.0.0.dev121 to ~=2.0.0.dev122 (#368)

Updates the requirements on [hikari](https://github.com/hikari-py/hikari) to permit the latest version.
- [Release notes](https://github.com/hikari-py/hikari/releases)
- [Changelog](https://github.com/hikari-py/hikari/blob/master/CHANGELOG.md)
- [Commits](hikari-py/hikari@2.0.0.dev121...2.0.0.dev122)

---
updated-dependencies:
- dependency-name: hikari
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): update ruff requirement from ~=0.1.3 to ~=0.1.6 (#367)

Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@v0.1.3...v0.1.6)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: Case insensitive prefixes (#351)

* case insensitive prefixes

* oops

* map prefixes to str.lower

Co-authored-by: nulldomain <[email protected]>

* unpack the mapped lowercase prefixes to a tuple

technically it should work without tuple() but mypy keeps complaining and i'm honestly quite fed up of it

---------

Co-authored-by: nulldomain <[email protected]>

* chore(deps-dev): update mypy requirement from ~=1.6.1 to ~=1.7.1 (#369)

* Update mypy requirement from ~=1.6.1 to ~=1.7.1

Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](python/mypy@v1.6.1...v1.7.1)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix(mypy): ignore setting slotted attribute

i trust slotscheck more than i trust mypy

* fix: annotate partial typehint

I have absolutely no idea what parameters this type annotation takes but it looks right and mypy doesn't complain so we ball

* revert: annotate partial typehint

This reverts commit fd574dd.

* fix: ignore generic type annotation

mypy complains when functools.partial is used as a generic in python 3.11, but it's not supported in 3.8

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: nulldomain <[email protected]>

* build: allow installation in python 3.12 environments (#370)

* feat: Add Validators to Options in PrefixContext (#371)

* chore(deps-dev): update ruff requirement from ~=0.1.6 to ~=0.1.7 (#372)

Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@v0.1.6...v0.1.7)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: prepare for 2.3.4 (#373)

* docs: add changelog for v2.3.4

* chore: version bump (2.3.4)

* docs: :^)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: davfsa <[email protected]>
Co-authored-by: thomm.o <[email protected]>
Co-authored-by: Zoey <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Oliver Thompson <[email protected]>
Co-authored-by: Luana <[email protected]>
  • Loading branch information
6 people authored Dec 7, 2023
1 parent 5e1a6f7 commit 2215c5b
Show file tree
Hide file tree
Showing 35 changed files with 303 additions and 111 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: CI

on: [push, pull_request]
on:
push:
branches-ignore:
- "dependabot/**"
pull_request:

jobs:
lint:
Expand All @@ -16,10 +20,10 @@ jobs:
with:
python-version: "3.8"

- name: Run black
- name: Run format checks
run: |
pip install nox
nox -s format
nox -s format_check
type-check:
name: Type-check
Expand All @@ -38,3 +42,21 @@ jobs:
run: |
pip install nox
nox -s mypy
slotscheck:
name: Slotscheck
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Run slotscheck
run: |
pip install nox
nox -s slotscheck
3 changes: 0 additions & 3 deletions .isort.cfg

This file was deleted.

8 changes: 4 additions & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ version: 2
sphinx:
configuration: docs/source/conf.py


build:
image: latest
os: ubuntu-22.04
tools:
python: "3.11"

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
install:
- requirements: requirements.txt
- requirements: docs_requirements.txt
- requirements: dev-requirements/docs.txt
4 changes: 2 additions & 2 deletions crontrigger_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
croniter~=1.3.14
types-croniter~=1.3.2
croniter~=2.0.1
types-croniter~=2.0.0
2 changes: 2 additions & 0 deletions dev-requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
furo~=2023.9.10
sphinx~=7.2.6
2 changes: 2 additions & 0 deletions dev-requirements/formatting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
black~=23.11.0
ruff~=0.1.7
1 change: 1 addition & 0 deletions dev-requirements/mypy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mypy~=1.7.1
1 change: 1 addition & 0 deletions dev-requirements/slotscheck.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
slotscheck~=0.17.1
3 changes: 1 addition & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-r requirements.txt
-r docs_requirements.txt
-r crontrigger_requirements.txt
nox~=2022.11.21
nox~=2023.4.22
18 changes: 18 additions & 0 deletions docs/source/changelogs/v2-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ Below are all the changelogs for the stable versions of hikari-lightbulb (versio

----

Version 2.3.4
=============

- Add validators to options in PrefixContext

- Fix custom option converter not being initialized for slash commands.

- Implemented slotting in some classes.

- Fixed localization options not being passed to subcommands or command options.

- Added case insensitive prefixes.

- Add support for Python 3.12.

- Bump hikari requirement to ``2.0.0.dev122``.


Version 2.3.3
=============

Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Contributors:

- `Parafoxia#1911 <https://github.com/parafoxia>`_

- `nulldomain <https://github.com/null-domain>`_

Index:
------

Expand Down
2 changes: 0 additions & 2 deletions docs_requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion lightbulb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,4 @@
from lightbulb.parser import *
from lightbulb.plugins import *

__version__ = "2.3.3"
__version__ = "2.3.4"
33 changes: 24 additions & 9 deletions lightbulb/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ class BotApp(hikari.GatewayBot):
as well as a prefix command. Defaults to ``False``.
delete_unbound_commands (:obj:`bool`): Whether or not the bot should delete application commands that it cannot
find an implementation for when the bot starts. Defaults to ``True``.
case_insensitive_prefixes (:obj:`bool`): Wheter or not command prefixes should be case-insensitive.
Defaults to ``False``.
case_insensitive_prefix_commands (:obj:`bool`): Whether or not prefix command names should be case-insensitive.
Defaults to ``False``.
**kwargs (Any): Additional keyword arguments passed to the constructor of the :obj:`~hikari.impl.gateway_bot.GatewayBot`
class.
"""
""" # noqa: E501

__slots__ = (
"get_prefix",
Expand All @@ -189,6 +191,7 @@ class BotApp(hikari.GatewayBot):
"default_enabled_guilds",
"_help_command",
"_delete_unbound_commands",
"_case_insensitive_prefixes",
"_case_insensitive_prefix_commands",
"_running_tasks",
)
Expand All @@ -203,6 +206,7 @@ def __init__(
help_class: t.Optional[t.Type[help_command_.BaseHelpCommand]] = help_command_.DefaultHelpCommand,
help_slash_command: bool = False,
delete_unbound_commands: bool = True,
case_insensitive_prefixes: bool = False,
case_insensitive_prefix_commands: bool = False,
**kwargs: t.Any,
) -> None:
Expand All @@ -220,6 +224,7 @@ def __init__(
] = prefix

self._delete_unbound_commands = delete_unbound_commands
self._case_insensitive_prefixes = case_insensitive_prefixes
self._case_insensitive_prefix_commands = case_insensitive_prefix_commands

self.ignore_bots: bool = ignore_bots
Expand All @@ -232,7 +237,8 @@ def __init__(
"""The default guilds that application commands will be enabled in."""

self.application: t.Optional[hikari.Application] = None
"""The :obj:`~hikari.applications.Application` for the bot account. This will always be ``None`` before the bot has logged in."""
"""The :obj:`~hikari.applications.Application` for the bot account.
This will always be ``None`` before the bot has logged in."""

self.d: data_store.DataStore = data_store.DataStore()
"""A :obj:`~.utils.data_store.DataStore` instance enabling storage of custom data without subclassing."""
Expand Down Expand Up @@ -388,7 +394,8 @@ async def _manage_application_commands(self, _: hikari.StartingEvent) -> None:
match = _APPLICATION_CMD_ERROR_REGEX.search(error_msg)
guild_id = "unknown" if match is None else match.group(1)
raise errors.ApplicationCommandCreationFailed(
f"Application command creation failed for guild {guild_id!r}. Is your bot in the guild and was it invited with the 'applications.commands' scope?"
f"Application command creation failed for guild {guild_id!r}. "
+ "Is your bot in the guild and was it invited with the 'applications.commands' scope?"
) from exc
finally:
await self.dispatch(events.LightbulbStartedEvent(app=self))
Expand Down Expand Up @@ -611,7 +618,7 @@ async def fetch_owner_ids(self) -> t.Sequence[hikari.Snowflakeish]:

self.application = self.application or await self.rest.fetch_application()

owner_ids = []
owner_ids: t.List[hikari.Snowflake] = []
if self.application.owner is not None:
owner_ids.append(self.application.owner.id)
if self.application.team is not None:
Expand Down Expand Up @@ -962,12 +969,18 @@ async def get_prefix_context(
prefixes = t.cast(t.Sequence[str], prefixes)

if isinstance(prefixes, str):
prefixes = [prefixes]
prefixes = (prefixes,)

message = event.message.content
if self._case_insensitive_prefixes:
message = message.lower()
prefixes = tuple(map(str.lower, prefixes))

prefixes = sorted(prefixes, key=len, reverse=True)

invoked_prefix = None
for prefix in prefixes:
if event.message.content.startswith(prefix):
if message.startswith(prefix):
invoked_prefix = prefix
break

Expand Down Expand Up @@ -1221,9 +1234,11 @@ async def handle_interaction_create_for_autocomplete(self, event: hikari.Interac
assert event.interaction.command_type is hikari.CommandType.SLASH
assert event.interaction.options is not None and len(event.interaction.options) > 0

get_focused: t.Callable[
[t.Sequence[hikari.AutocompleteInteractionOption]], hikari.AutocompleteInteractionOption
] = lambda opts: next(filter(lambda o: o.is_focused, opts), opts[0])
def is_focused(opt: hikari.AutocompleteInteractionOption) -> bool:
return opt.is_focused

def get_focused(opts: t.Sequence[hikari.AutocompleteInteractionOption]) -> hikari.AutocompleteInteractionOption:
return next(filter(is_focused, opts), opts[0])

def flatten_command_option(
opt: hikari.AutocompleteInteractionOption,
Expand Down
5 changes: 4 additions & 1 deletion lightbulb/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@
from lightbulb import plugins

_CallbackT = t.Union[
t.Callable[[context_.base.Context], t.Union[bool, t.Coroutine[t.Any, t.Any, bool]]], functools.partial
t.Callable[[context_.base.Context], t.Union[bool, t.Coroutine[t.Any, t.Any, bool]]],
functools.partial, # type: ignore[type-arg]
]


class _ExclusiveCheck:
__slots__ = ("_checks",)

def __init__(self, *checks: "Check") -> None:
self._checks = list(checks)

Expand Down
Loading

0 comments on commit 2215c5b

Please sign in to comment.