Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Add permissions v2 support (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: GoogleGenius <[email protected]>
  • Loading branch information
thesadru and GoogolGenius committed Aug 29, 2022
1 parent 876a50b commit 770b09f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
hikari>=2.0.0.dev108
hikari-tanjun>=2.4.4a1
alluka
hikari>=2.0.0.dev110
hikari-tanjun>=2.6.1a1
alluka~=0.1
6 changes: 6 additions & 0 deletions tanchi/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typing

import hikari
import tanjun

from tanchi import parser, types
Expand All @@ -11,9 +12,13 @@ def as_slash_command(
name: typing.Optional[str] = None,
*,
always_defer: bool = False,
default_member_permissions: typing.Union[hikari.Permissions, int, None] = None,
default_to_ephemeral: typing.Optional[bool] = None,
dm_enabled: typing.Optional[bool] = None,
is_global: bool = True,
sort_options: bool = True,
validate_arg_keys: bool = True,
**kwargs: typing.Any,
) -> typing.Callable[[types.CommandCallbackSigT], tanjun.SlashCommand[types.CommandCallbackSigT]]:
"""Build a SlashCommand by decorating a function."""
return lambda func: parser.create_command(
Expand All @@ -23,4 +28,5 @@ def as_slash_command(
default_to_ephemeral=default_to_ephemeral,
is_global=is_global,
sort_options=sort_options,
**kwargs,
)
8 changes: 8 additions & 0 deletions tanchi/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,13 @@ def create_command(
*,
name: typing.Optional[str] = None,
always_defer: bool = False,
default_member_permissions: typing.Union[hikari.Permissions, int, None] = None,
default_to_ephemeral: typing.Optional[bool] = None,
dm_enabled: typing.Optional[bool] = None,
is_global: bool = True,
sort_options: bool = True,
validate_arg_keys: bool = True,
**kwargs: typing.Any,
) -> tanjun.SlashCommand[types.CommandCallbackSigT]:
"""Build a SlashCommand."""
if not (doc := function.__doc__):
Expand All @@ -264,9 +268,13 @@ def create_command(
name or function.__name__,
description,
always_defer=always_defer,
default_member_permissions=default_member_permissions,
default_to_ephemeral=default_to_ephemeral,
dm_enabled=dm_enabled,
is_global=is_global,
sort_options=sort_options,
validate_arg_keys=validate_arg_keys,
**kwargs,
)

sig = types.signature(function)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class SlashCommand(tanjun.SlashCommand[typing.Any]):
def __init__(self) -> None:
super().__init__(NotImplemented, "name", "description")
super().__init__(lambda ctx, **kwargs: None, "name", "description")


def parse_parameter(
Expand Down

0 comments on commit 770b09f

Please sign in to comment.