Skip to content

Commit ea20323

Browse files
authored
Merge: v5.7.0
v5.7.0
2 parents a21b04a + 68492e1 commit ea20323

File tree

25 files changed

+103
-54
lines changed

25 files changed

+103
-54
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ repos:
3030
- id: check-merge-conflict
3131
name: Merge Conflicts
3232
- repo: https://github.com/charliermarsh/ruff-pre-commit
33-
rev: 'v0.0.270'
33+
rev: 'v0.0.272'
3434
hooks:
3535
- id: ruff
3636
args: [--fix, --exit-non-zero-on-fix]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ In addition to core functionality, `interactions.py` provides a range of optiona
3737

3838
So the base library doesn't do what you want? No problem! With builtin extensions, you are able to extend the functionality of the library. And if none of those pique your interest, there are a myriad of other extension libraries available.
3939

40-
Just type `bot.load("extension")`
40+
Just type `bot.load_extension("extension")`
4141

4242
<details>
4343
<summary>Extensions</summary>

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ In addition to core functionality, interactions.py provides a range of optional
3434

3535
So the base library doesn't do what you want? No problem! With builtin extensions, you are able to extend the functionality of the library. And if none of those pique your interest, there are a myriad of other extension libraries available.
3636

37-
Just type `bot.load("extension")`
37+
Just type `bot.load_extension("extension")`
3838

3939
---
4040

interactions/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from .client import (
23
__api_version__,
34
__py_version__,
@@ -680,6 +681,10 @@
680681
"WebSocketOPCode",
681682
)
682683

684+
if "discord" in sys.modules:
685+
get_logger().error(
686+
"`import discord` import detected. Interactions.py is a completely separate library, and is not compatible with d.py models. Please see https://interactions-py.github.io/interactions.py/Guides/100%20Migration%20From%20D.py/ for how to fix your code."
687+
)
683688

684689
########################################################################################################################
685690
# Noteworthy Credits

interactions/api/events/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from interactions.models.discord.snowflake import to_snowflake
1010

1111
if TYPE_CHECKING:
12-
from interactions import Client
12+
from interactions.client.client import Client
1313
from interactions.models.discord.snowflake import Snowflake_Type
1414
from interactions.models.discord.guild import Guild
1515

interactions/api/http/http_requests/guild.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
from typing import TYPE_CHECKING, List, cast, Mapping, Any
1+
from typing import TYPE_CHECKING, Any, List, Mapping, cast
22

33
import discord_typings
44

55
from interactions.client.utils.serializer import dict_filter_none
66
from interactions.models.internal.protocols import CanRequest
7-
from ..route import Route, PAYLOAD_TYPE
7+
8+
from ..route import PAYLOAD_TYPE, Route
89

910
__all__ = ("GuildRequests",)
1011

1112

1213
if TYPE_CHECKING:
13-
from interactions.models.discord.snowflake import Snowflake_Type
1414
from interactions.models.discord.enums import AuditLogEventType
15+
from interactions.models.discord.snowflake import Snowflake_Type
1516

1617

1718
class GuildRequests(CanRequest):
@@ -404,9 +405,6 @@ async def modify_guild_role_positions(
404405
Args:
405406
guild_id: The ID of the guild
406407
position_changes: A list of dicts representing the roles to move and their new positions
407-
408-
``{"id": role_id, "position": new_position}``
409-
410408
reason: The reason for this action
411409
412410
Returns:

interactions/api/voice/voice_gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def _udp_keep_alive(self) -> None:
268268
keep_alive = b"\xc9\x00\x00\x00\x00\x00\x00\x00\x00"
269269

270270
self.logger.debug("Starting UDP Keep Alive")
271-
while not self.socket._closed and not self.ws.closed:
271+
while not self.socket._closed and self.ws and not self.ws.closed:
272272
try:
273273
_, writable, _ = select.select([], [self.socket], [], 0)
274274
while not writable:

interactions/client/mixins/modal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class ModalMixin:
12-
client: "interactions.Client"
12+
client: "interactions.client.client.Client"
1313
"""The client that created this context."""
1414
responded: bool
1515
"""Whether this context has been responded to."""

interactions/client/mixins/send.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import TYPE_CHECKING, Any, Iterable, Optional, Union
22

33
import interactions.models as models
4+
import interactions.models.discord
45
from interactions.models.discord.enums import MessageFlags
56

67
if TYPE_CHECKING:
@@ -82,6 +83,18 @@ async def send(
8283
flags = MessageFlags(flags)
8384
flags = flags | MessageFlags.SILENT
8485

86+
if (
87+
files
88+
and (
89+
isinstance(files, Iterable)
90+
and any(isinstance(file, interactions.models.discord.message.Attachment) for file in files)
91+
)
92+
or isinstance(files, interactions.models.discord.message.Attachment)
93+
):
94+
raise ValueError(
95+
"Attachments are not files. Attachments only contain metadata about the file, not the file itself - to send an attachment, you need to download it first. Check Attachment.url"
96+
)
97+
8598
message_payload = models.discord.message.process_message_payload(
8699
content=content,
87100
embeds=embeds or embed,

interactions/client/utils/attr_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ def docs(doc_string: str) -> Dict[str, str]:
3636
return {"docs": doc_string}
3737

3838

39-
def str_validator(self: Any, attribute: attrs.Attribute, value: Any) -> None:
39+
def str_validator(cls: Any, attribute: attrs.Attribute, value: Any) -> None:
4040
"""
4141
Validates that the value is a string. Helps convert and ives a warning if it isn't.
4242
4343
Args:
44-
self: The instance of the class.
44+
cls: The instance of the class.
4545
attribute: The attr attribute being validated.
4646
value: The value being validated.
4747
4848
"""
4949
if not isinstance(value, str):
5050
if value is MISSING:
5151
return
52-
setattr(self, attribute.name, str(value))
52+
setattr(cls, attribute.name, str(value))
5353
get_logger().warning(
5454
f"Value of {attribute.name} has been automatically converted to a string. Please use strings in future.\n"
5555
"Note: Discord will always return value as a string"

0 commit comments

Comments
 (0)