Further attempts at fake message object

pull/132/head
bobloy 4 years ago
parent e602b5c868
commit 636b3ee975

@ -21,6 +21,10 @@ schedule_log.setLevel(logging.DEBUG)
log.setLevel(logging.DEBUG) log.setLevel(logging.DEBUG)
async def _do_nothing(*args, **kwargs):
pass
async def _execute_task(task_state): async def _execute_task(task_state):
log.info(f"Executing {task_state=}") log.info(f"Executing {task_state=}")
task = Task(**task_state) task = Task(**task_state)
@ -60,9 +64,9 @@ def parse_triggers(data: Union[Dict, None]):
# _state = None # _state = None
# class FakeMessage(discord.Message): class FakeMessage:
# def __init__(self): def __init__(self, **kwargs):
# super().__init__(state=None, channel=None, data=None) self.__dict__.update(kwargs)
class Task: class Task:
@ -216,11 +220,15 @@ class Task:
log.warning(f"Could not execute task due to missing author: {self.author_id}") log.warning(f"Could not execute task due to missing author: {self.author_id}")
return False return False
message = channel.last_message actual_message: discord.Message = channel.last_message
if message is None: if actual_message is None:
log.warning("No message found in channel cache yet, skipping execution") log.warning("No message found in channel cache yet, skipping execution")
return return
message = FakeMessage(**actual_message.__dict__)
message.author = author message.author = author
message.id = None
message.add_reaction = _do_nothing
prefixes = await self.bot.get_prefix(message) prefixes = await self.bot.get_prefix(message)
if isinstance(prefixes, str): if isinstance(prefixes, str):

Loading…
Cancel
Save