Skip to content

Commit b62ee99

Browse files
authored
Feat/fix bugs (#400)
* Fix bugs * bug fixes
1 parent 7e08cc7 commit b62ee99

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

docs/source/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ Glossary
3232
Releases
3333
----------------------
3434

35+
v2.9.6
36+
=================
37+
- Fixed crash if ``start_period`` is larger than ``end_period``.
38+
- Fixed local update not showing errors if updating objects under AutoGUILD
39+
40+
41+
3542
v2.9.5
3643
=================
3744
- Fixed incorrect caching of the SQL logs, causing incorrect values to be returned back to the GUI.

src/daf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
from .misc import *
2020

2121

22-
VERSION = "2.9.5"
22+
VERSION = "2.9.6"

src/daf/client.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,15 +490,13 @@ async def update(self, **kwargs):
490490
if isinstance(intents, discord.Intents) and intents.value == 0:
491491
kwargs["intents"] = None
492492

493-
servers = kwargs.pop("servers", self.servers + self._uiservers)
494-
if servers is None:
495-
servers = []
493+
kwargs["servers"] = kwargs.pop("servers", self.servers + self._uiservers)
496494

497495
@misc._async_safe("_update_sem")
498496
async def update_servers(self_):
499497
_servers = []
500498
_autoguilds = []
501-
for server in servers:
499+
for server in self.servers:
502500
try:
503501
await server.update(init_options={"parent": self})
504502
if isinstance(server, guild._BaseGUILD):
@@ -516,6 +514,5 @@ async def update_servers(self_):
516514
await update_servers(self)
517515
except Exception:
518516
await self.initialize() # re-login
519-
servers = self.servers # Only return initialized servers
520517
await update_servers(self)
521518
raise

src/daf/message/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ def __init__(self,
142142
trace("Using int on end_period is deprecated, use timedelta object instead.", TraceLEVELS.DEPRECATED)
143143
end_period = timedelta(seconds=end_period)
144144

145+
if isinstance(start_period, timedelta) and start_period >= end_period:
146+
raise ValueError("'start_period' must be less than 'end_period'")
147+
145148
# Clamp periods to minimum level (prevent infinite loops)
146149
self.start_period = None if start_period is None else max(start_period, timedelta(seconds=C_PERIOD_MINIMUM_SEC))
147150
self.end_period = max(end_period, timedelta(seconds=C_PERIOD_MINIMUM_SEC))
@@ -546,6 +549,9 @@ async def update(self, init_options = None, **kwargs):
546549
Any
547550
Raised from :py:meth:`~daf.message.AutoCHANNEL.initialize` method.
548551
"""
552+
if self.parent is None:
553+
raise ValueError(f"{type(self).__name__} is not initialized. If this is under AutoGUILD, update AutoGUILD instead.")
554+
549555
if init_options is None:
550556
init_options = {}
551557
init_options["parent"] = self.parent

src/daf/message/text_based.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ async def update(self, _init_options: Optional[dict] = None, **kwargs: Any):
548548
Other
549549
Raised from .initialize() method.
550550
"""
551+
if self.parent is None:
552+
raise ValueError(f"{type(self).__name__} is not initialized. If this is under AutoGUILD, update AutoGUILD instead.")
553+
551554
if "start_in" not in kwargs:
552555
# This parameter does not appear as attribute, manual setting necessary
553556
kwargs["start_in"] = self.next_send_time

src/daf/message/voice_based.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ async def update(self, _init_options: Optional[dict] = None, **kwargs):
410410
Other
411411
Raised from .initialize() method
412412
"""
413+
if self.parent is None:
414+
raise ValueError(f"{type(self).__name__} is not initialized. If this is under AutoGUILD, update AutoGUILD instead.")
415+
413416
if "start_in" not in kwargs:
414417
# This parameter does not appear as attribute, manual setting necessary
415418
kwargs["start_in"] = self.next_send_time

0 commit comments

Comments
 (0)