Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Add some models classes #6

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
35a51bd
chore: Update gitignore
Gugu7264 Dec 27, 2021
13f91cd
feat: Added User and ClientUser models
Gugu7264 Dec 28, 2021
adffec1
chore: Rename folders and added snowflake type
Gugu7264 Dec 28, 2021
60ee0df
refactor: moved BaseUser in protocols
Gugu7264 Dec 28, 2021
9d9c2cf
Merge branch 'nextcord:master' into master
Gugu7264 Dec 28, 2021
36a0f4b
fix: fixed relative imports
Gugu7264 Dec 28, 2021
d6baf9c
feat: adding Messageable and Embed models
Gugu7264 Dec 28, 2021
d5f7404
refactor: renamed embed functions
Gugu7264 Dec 28, 2021
1c0f1eb
feat: added InvalidArgument exception
Gugu7264 Dec 28, 2021
a3663cc
feat: Added Embed class and Embed* classes
Gugu7264 Dec 28, 2021
9a1d3ab
feat: switched video and provider to properties, added [from/to]_dict…
Gugu7264 Dec 29, 2021
1accd2a
feat: added allowed_mentions, modified embed, started work on channel…
Gugu7264 Jan 3, 2022
24f737e
Merge branch 'nextcord:master' into master
Gugu7264 Jan 3, 2022
31e0af9
refactor: linted
Gugu7264 Jan 3, 2022
91c5386
style: switched to comments for license
Gugu7264 Jan 4, 2022
9b2b62e
revert: remove abc.py ; early WIP
Gugu7264 Jan 8, 2022
8c1cd9e
fix: pull upstream and resolve conflicts
Gugu7264 Jan 9, 2022
53484c4
refactor/fix: moves code around and fixes typehinting
Gugu7264 Jan 9, 2022
6d711aa
Delete abc.py
Gugu7264 Jan 9, 2022
1cd594d
chore: subclass Protocol and use cls()
Gugu7264 Jan 19, 2022
3e08309
Merge branch 'master' of https://github.com/nextcord/nextcord-v3
Gugu7264 Jan 19, 2022
da41a2c
chore: fix mypy errors
Gugu7264 Jan 22, 2022
40b3721
Merge branch 'master' of https://github.com/nextcord/nextcord-v3
Gugu7264 Jan 22, 2022
3bb752b
fix: from_dict and to_dict now working almost entirely
Gugu7264 Jan 25, 2022
f66da5f
chore: change test
Gugu7264 Jan 25, 2022
cf51ca2
refactor: rename SnowflakeArray to SnowflakeList
Gugu7264 Jan 25, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,4 @@ cython_debug/
# Editors
.vscode/
.idea/
.nova/
23 changes: 23 additions & 0 deletions nextcord/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# The MIT License (MIT)
# Copyright (c) 2021-present vcokltfre & tag-epic
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.


class NextcordException(Exception):
...

Expand Down Expand Up @@ -25,3 +44,7 @@ def __init__(self) -> None:
"You have been banned by Cloudflare. "
"See https://discord.dev/topics/rate-limits#invalid-request-limit-aka-cloudflare-bans"
)


class ArgumentConflict(NextcordException):
...
37 changes: 18 additions & 19 deletions nextcord/type_sheet.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
"""
The MIT License (MIT)
Copyright (c) 2021-present vcokltfre & tag-epic
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
# The MIT License (MIT)
# Copyright (c) 2021-present vcokltfre & tag-epic
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
77 changes: 77 additions & 0 deletions nextcord/types/allowed_mentions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# The MIT License (MIT)
# Copyright (c) 2021-present vcokltfre & tag-epic
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from __future__ import annotations

from logging import getLogger
from typing import TYPE_CHECKING, Optional, Union

if TYPE_CHECKING:
from .snowflake import Snowflake


Role, User = None, None # TODO: DEFINE and import

logger = getLogger(__name__)


class AllowedMentions:
def __init__(
self,
*,
everyone: bool = False,
roles: Union[bool, list[Role], Role] = False,
users: Union[bool, User, list[User]] = True,
replied_user: Optional[bool] = None,
):
self.everyone = everyone
self.roles = roles
self.users = users
self.replied_user = replied_user

def to_dict(self) -> dict[str, Union[list[str], list[Snowflake], bool]]:
allowed: dict[str, Union[list[str], list[Snowflake], bool]] = {"parse": []}
if self.everyone:
allowed["parse"].append("everyone")

if isinstance(self.roles, bool) and self.roles:
allowed["parse"].append("roles")
elif isinstance(self.roles, list):
allowed["roles"] = [r.id for r in self.roles]
elif isinstance(self.roles, Role):
allowed["roles"] = [self.roles.id]

if isinstance(self.users, bool) and self.roles:
allowed["parse"].append("users")
elif isinstance(self.users, list):
allowed["users"] = [u.id for u in self.roles]
elif isinstance(self.users, User):
allowed["users"] = [self.users.id]

if self.replied_user:
allowed["replied_user"] = bool(self.replied_user)

return allowed

@classmethod
def none(cls) -> AllowedMentions:
return cls(everyone=False, roles=False, users=False, replied_user=False)

@classmethod
def all(cls) -> AllowedMentions:
return cls(everyone=True, roles=True, users=True, replied_user=True)
32 changes: 32 additions & 0 deletions nextcord/types/channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# The MIT License (MIT)
# Copyright (c) 2021-present vcokltfre & tag-epic
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from __future__ import annotations

from logging import getLogger
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ..client.state import State

logger = getLogger(__name__)


class Channel:
def __init__(self, state: State, data: dict):
pass
Loading