Skip to content

Commit fcf3472

Browse files
committed
Fix
1 parent 312b309 commit fcf3472

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/daf/message/base.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
from ..logging.tracing import *
1111
from ..timing import *
1212
from .. import misc
13+
from .. import client
1314

1415
import random
1516
import re
17+
import copy
1618
import asyncio
1719
import _discord as discord
1820

21+
1922
__all__ = (
2023
"BaseMESSAGE",
2124
"AutoCHANNEL",
@@ -151,6 +154,20 @@ def __eq__(self, o: object) -> bool:
151154

152155
raise TypeError(f"Comparison of {type(self)} not allowed with {type(o)}")
153156

157+
def __deepcopy__(self, *args):
158+
"Duplicates the object (for use in AutoGUILD)"
159+
new = copy.copy(self)
160+
for slot in list(self.__slots__) + list(BaseMESSAGE.__slots__):
161+
self_val = getattr(self, slot)
162+
if isinstance(self_val, (asyncio.Semaphore, asyncio.Lock)):
163+
# Hack to copy semaphores since not all of it can be copied directly
164+
copied = type(self_val)(self_val._value)
165+
else:
166+
copied = copy.deepcopy((self_val))
167+
168+
setattr(new, slot, copied)
169+
170+
return new
154171

155172
@property
156173
def created_at(self) -> datetime:
@@ -408,10 +425,18 @@ def _process(self):
408425
stamp = datetime.now().timestamp()
409426
if stamp - self.last_scan > self.interval:
410427
self.last_scan = stamp
411-
for channel in getattr(self.parent.parent.apiobject, self.channel_getter):
428+
guild: discord.Guild = self.parent.parent.apiobject
429+
client_: discord.Client = client.get_client()
430+
member = guild.get_member(client_.user.id)
431+
if member is None:
432+
return
433+
434+
for channel in getattr(guild, self.channel_getter):
412435
if channel not in self.cache:
436+
perms = channel.permissions_for(member)
413437
name = channel.name
414-
if (re.search(self.include_pattern, name) is not None and
438+
if ((perms.send_messages or (perms.connect and perms.stream and perms.speak)) and
439+
re.search(self.include_pattern, name) is not None and
415440
(self.exclude_pattern is None or re.search(self.exclude_pattern, name) is None)
416441
):
417442
self.cache.add(channel)

src/daf/message/voice_based.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ class VoiceMESSAGE(BaseMESSAGE):
9696
"""
9797

9898
__slots__ = (
99-
"randomized_time",
10099
"period",
101100
"start_period",
102101
"end_period",
103-
"data",
104102
"volume",
105103
"channels",
106104
)

0 commit comments

Comments
 (0)