Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit a9b7bee

Browse files
committed
Imagine not being deployed
1 parent d9a3414 commit a9b7bee

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

_orangcbot/extensions/types.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from __future__ import annotations
2+
3+
from typing import List, Literal, TypedDict, Union
4+
5+
from typing_extensions import NotRequired
6+
7+
RecordType = Literal["A", "CNAME", "MX", "URL", "TXT"]
8+
9+
10+
class _OwnerObject(TypedDict):
11+
username: str
12+
email: str
13+
14+
# known accounts
15+
discord: NotRequired[str]
16+
twitter: NotRequired[str]
17+
18+
19+
class _RecordObject(TypedDict, total=False):
20+
A: List[str]
21+
CNAME: str
22+
URL: str
23+
TXT: Union[str, List[str]]
24+
MX: List[str]
25+
26+
27+
class Domain(TypedDict):
28+
description: NotRequired[str]
29+
repo: NotRequired[str]
30+
owner: _OwnerObject
31+
record: _RecordObject

_orangcbot/extensions/utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from __future__ import annotations
2+
3+
4+
import nextcord
5+
from nextcord.ui import Item
6+
7+
from typing import TYPE_CHECKING
8+
9+
10+
class TextBasedOnlyAuthorCheck(Item):
11+
if TYPE_CHECKING:
12+
_message: nextcord.Message
13+
_author_id: int
14+
15+
async def interaction_check(self, interaction: nextcord.Interaction) -> bool:
16+
if hasattr(self, "_message"):
17+
return interaction.user.id == self._message.author.id
18+
elif hasattr(self, "_author_id"):
19+
return interaction.user.id == self._author_id
20+
else:
21+
raise nextcord.ApplicationCheckFailure(
22+
(
23+
"An `TextBasedOnlyAuthorCheck` was used but"
24+
"neither `_message` or `_author_id` attribute was found."
25+
)
26+
)

pyrightconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"reportOptionalMemberAccess": false,
3+
"reportAssignmentType": false,
4+
"reportIncompatibleMethodOverride": false
5+
}

0 commit comments

Comments
 (0)