Skip to content

Commit

Permalink
Changed app to bot in LightbulbEvent
Browse files Browse the repository at this point in the history
Type changed from `hikari.BotAware` to `lightbulb.Bot`. This makes more
sense since it allows user to make use of the extended APIs lightbulb
exposes.
  • Loading branch information
Tmpod authored and tandemdude committed Apr 30, 2021
1 parent 7f7131b commit f6e3ae4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lightbulb/command_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ async def _dispatch_command_error_event_from_exception(
command: typing.Optional[commands.Command] = None,
) -> None:
error_event = events.CommandErrorEvent(
app=self, exception=exception, message=message, context=context, command=command
bot=self, exception=exception, message=message, context=context, command=command
)

handled = False
Expand Down Expand Up @@ -849,7 +849,7 @@ async def process_commands_for_event(self, event: hikari.MessageCreateEvent) ->

context = self.get_context(event.message, prefix, invoked_with, command)

await self.dispatch(events.CommandInvocationEvent(app=self, command=command, context=context))
await self.dispatch(events.CommandInvocationEvent(bot=self, command=command, context=context))
if (before_invoke := command._before_invoke) is not None:
await before_invoke(context)

Expand Down Expand Up @@ -878,7 +878,7 @@ async def process_commands_for_event(self, event: hikari.MessageCreateEvent) ->
if (after_invoke := command._after_invoke) is not None:
await after_invoke(context)

await self.dispatch(events.CommandCompletionEvent(app=self, command=command, context=context))
await self.dispatch(events.CommandCompletionEvent(bot=self, command=command, context=context))

async def handle(self, event: hikari.MessageCreateEvent) -> None:
"""
Expand Down
5 changes: 3 additions & 2 deletions lightbulb/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
if typing.TYPE_CHECKING:
import types

from lightbulb import command_handler
from lightbulb import commands
from lightbulb import context as context_
from lightbulb import errors
Expand All @@ -42,8 +43,8 @@ class LightbulbEvent(hikari.Event, abc.ABC):
will be an instance of a subclass of this.
"""

app: hikari.BotAware = attr.ib()
"""App instance for this application."""
bot: command_handler.Bot = attr.ib()
"""Bot instance for this event."""


@attr.s(kw_only=True, slots=True, weakref_slot=False)
Expand Down

0 comments on commit f6e3ae4

Please sign in to comment.