Skip to content

Commit 983e3b4

Browse files
author
Eviee Py
committed
Add is_owner to Context
1 parent 9bd0a91 commit 983e3b4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

twitchio/ext/commands/bot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
client_id: str,
5555
client_secret: str,
5656
bot_id: str,
57+
owner_id: str | None = None,
5758
prefix: Prefix_T,
5859
**options: Unpack[ClientOptions],
5960
) -> None:
@@ -64,6 +65,7 @@ def __init__(
6465
**options,
6566
)
6667

68+
self._owner_id: str | None = owner_id
6769
self._get_prefix: Prefix_T = prefix
6870
self._components: dict[str, Component] = {}
6971
self._base_converter: _BaseConverter = _BaseConverter(self)
@@ -73,6 +75,10 @@ def bot_id(self) -> str:
7375
assert self._bot_id
7476
return self._bot_id
7577

78+
@property
79+
def owner_id(self) -> str | None:
80+
return self._owner_id
81+
7682
def _cleanup_component(self, component: Component, /) -> None:
7783
for command in component.__all_commands__.values():
7884
self.remove_command(command.name)

twitchio/ext/commands/context.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ def args(self) -> list[Any]:
122122
def kwargs(self) -> dict[str, Any]:
123123
return self._kwargs
124124

125+
def is_owner(self) -> bool:
126+
return self.chatter.id == self.bot.owner_id
127+
125128
def is_valid(self) -> bool:
126129
return self._prefix is not None
127130

0 commit comments

Comments
 (0)