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

Slash cmd migration #59

Merged
merged 5 commits into from
May 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Imagine not being deployed
  • Loading branch information
MaskDuck committed May 29, 2024
commit a9b7beefba1a3e3c03c8c58d5572af4c9b9a1f32
31 changes: 31 additions & 0 deletions _orangcbot/extensions/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import annotations

from typing import List, Literal, TypedDict, Union

from typing_extensions import NotRequired

RecordType = Literal["A", "CNAME", "MX", "URL", "TXT"]


class _OwnerObject(TypedDict):
username: str
email: str

# known accounts
discord: NotRequired[str]
twitter: NotRequired[str]


class _RecordObject(TypedDict, total=False):
A: List[str]
CNAME: str
URL: str
TXT: Union[str, List[str]]
MX: List[str]


class Domain(TypedDict):
description: NotRequired[str]
repo: NotRequired[str]
owner: _OwnerObject
record: _RecordObject
26 changes: 26 additions & 0 deletions _orangcbot/extensions/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import annotations


import nextcord
from nextcord.ui import Item

from typing import TYPE_CHECKING


class TextBasedOnlyAuthorCheck(Item):
if TYPE_CHECKING:
_message: nextcord.Message
_author_id: int

async def interaction_check(self, interaction: nextcord.Interaction) -> bool:
if hasattr(self, "_message"):
return interaction.user.id == self._message.author.id
elif hasattr(self, "_author_id"):
return interaction.user.id == self._author_id
else:
raise nextcord.ApplicationCheckFailure(
(
"An `TextBasedOnlyAuthorCheck` was used but"
"neither `_message` or `_author_id` attribute was found."
)
)
5 changes: 5 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"reportOptionalMemberAccess": false,
"reportAssignmentType": false,
"reportIncompatibleMethodOverride": false
}