Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
RealCyGuy committed Nov 11, 2020
1 parent 18bcb9e commit 18d3b4b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
4 changes: 3 additions & 1 deletion cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,9 @@ async def note_persistent(self, ctx, *, msg: str = ""):
async with ctx.typing():
msg = await ctx.thread.note(ctx.message, persistent=True)
await msg.pin()
await self.bot.api.create_note(recipient=ctx.thread.recipient, message=ctx.message, message_id=msg.id)
await self.bot.api.create_note(
recipient=ctx.thread.recipient, message=ctx.message, message_id=msg.id
)

@commands.command()
@checks.has_permissions(PermissionLevel.SUPPORTER)
Expand Down
10 changes: 7 additions & 3 deletions core/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ async def create_note(self, recipient: Member, message: Message, message_id: Uni
"id": str(message.author.id),
"name": message.author.name,
"discriminator": message.author.discriminator,
"avatar_url": str(message.author.avatar_url)
"avatar_url": str(message.author.avatar_url),
},
"message": message.content,
"message_id": str(message_id),
Expand All @@ -436,13 +436,17 @@ async def find_notes(self, recipient: Member):

async def update_note_ids(self, ids: dict):
for object_id, message_id in ids.items():
await self.db.notes.update_one({"_id": object_id}, {"$set": {"message_id": message_id}})
await self.db.notes.update_one(
{"_id": object_id}, {"$set": {"message_id": message_id}}
)

async def delete_note(self, message_id: Union[int, str]):
await self.db.notes.delete_one({"message_id": str(message_id)})

async def edit_note(self, message_id: Union[int, str], message: str):
await self.db.notes.update_one({"message_id": str(message_id)}, {"$set": {"message": message}})
await self.db.notes.update_one(
{"message_id": str(message_id)}, {"$set": {"message": message}}
)

def get_plugin_partition(self, cog):
cls_name = cog.__class__.__name__
Expand Down
21 changes: 17 additions & 4 deletions core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ class Author:
"author": Author(),
}
message = discord.Message(state=State(), channel=None, data=data)
ids[note["_id"]] = str((await self.note(message, persistent=True, thread_creation=True)).id)
ids[note["_id"]] = str(
(await self.note(message, persistent=True, thread_creation=True)).id
)

await self.bot.api.update_note_ids(ids)

Expand All @@ -242,7 +244,10 @@ async def activate_auto_triggers():
pass

await asyncio.gather(
send_genesis_message(), send_recipient_genesis_message(), activate_auto_triggers(), send_persistent_notes(),
send_genesis_message(),
send_recipient_genesis_message(),
activate_auto_triggers(),
send_persistent_notes(),
)
self.bot.dispatch("thread_ready", self)

Expand Down Expand Up @@ -687,11 +692,19 @@ async def edit_dm_message(self, message: discord.Message, content: str) -> None:
self.bot.api.edit_message(message.id, content), linked_message.edit(embed=embed)
)

async def note(self, message: discord.Message, persistent=False, thread_creation=False) -> None:
async def note(
self, message: discord.Message, persistent=False, thread_creation=False
) -> None:
if not message.content and not message.attachments:
raise MissingRequiredArgument(SimpleNamespace(name="msg"))

msg = await self.send(message, self.channel, note=True, persistent_note=persistent, thread_creation=thread_creation)
msg = await self.send(
message,
self.channel,
note=True,
persistent_note=persistent,
thread_creation=thread_creation,
)

self.bot.loop.create_task(
self.bot.api.append_log(
Expand Down

0 comments on commit 18d3b4b

Please sign in to comment.