Skip to content

Commit 050c510

Browse files
committed
fix: duplicates in logs, notes.
1 parent d47a30e commit 050c510

File tree

2 files changed

+58
-23
lines changed

2 files changed

+58
-23
lines changed

bot.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ async def on_message(self, message):
13261326
# Only log if not a command
13271327
perms = message.channel.permissions_for(message.author)
13281328
if perms.manage_messages or perms.administrator:
1329-
await self.api.append_log(message, type_="mod_only")
1329+
await self.api.append_log(message, type_="internal")
13301330

13311331
await self.process_commands(message)
13321332

@@ -1365,8 +1365,6 @@ async def process_commands(self, message):
13651365
or self.config.get("plain_reply_without_command")
13661366
):
13671367
await thread.reply(message, anonymous=anonymous, plain=plain)
1368-
else:
1369-
await self.api.append_log(message, type_="internal")
13701368
elif ctx.invoked_with:
13711369
exc = commands.CommandNotFound('Command "{}" is not found'.format(ctx.invoked_with))
13721370
self.dispatch("command_error", ctx, exc)

core/thread.py

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ async def snooze(self, moderator=None, command_used=None, snooze_for=None):
173173
m.embeds
174174
and getattr(m.embeds[0], "author", None)
175175
and (
176-
getattr(m.embeds[0].author, "name", "").startswith("Note")
177-
or getattr(m.embeds[0].author, "name", "").startswith("Persistent Note")
176+
getattr(m.embeds[0].author, "name", "").startswith("📝 Note")
177+
or getattr(m.embeds[0].author, "name", "").startswith("📝 Persistent Note")
178178
)
179179
)
180180
else None
@@ -186,8 +186,8 @@ async def snooze(self, moderator=None, command_used=None, snooze_for=None):
186186
m.embeds
187187
and getattr(m.embeds[0], "author", None)
188188
and (
189-
getattr(m.embeds[0].author, "name", "").startswith("Note")
190-
or getattr(m.embeds[0].author, "name", "").startswith("Persistent Note")
189+
getattr(m.embeds[0].author, "name", "").startswith("📝 Note")
190+
or getattr(m.embeds[0].author, "name", "").startswith("📝 Persistent Note")
191191
)
192192
)
193193
and getattr(m, "type", None) not in ("internal", "note")
@@ -1015,9 +1015,9 @@ async def note(
10151015
thread_creation=thread_creation,
10161016
)
10171017

1018-
# Log as 'system' type for logviewer visibility
1018+
# Log as 'note' type for logviewer
10191019
self.bot.loop.create_task(
1020-
self.bot.api.append_log(message, message_id=msg.id, channel_id=self.channel.id, type_="system")
1020+
self.bot.api.append_log(message, message_id=msg.id, channel_id=self.channel.id, type_="note")
10211021
)
10221022

10231023
return msg
@@ -1125,6 +1125,30 @@ async def send(
11251125
persistent_note: bool = False,
11261126
thread_creation: bool = False,
11271127
) -> None:
1128+
# Handle notes with Discord-like system message format - return early
1129+
if note and from_mod:
1130+
destination = destination or self.channel
1131+
content = message.content or "[No content]"
1132+
1133+
# Create embed for note with Discord system message style
1134+
embed = discord.Embed(
1135+
description=content, color=0x5865F2 # Discord blurple color for system messages
1136+
)
1137+
1138+
# Set author with note icon and username
1139+
embed.set_author(
1140+
name=f"📝 Note ({message.author.name})", icon_url=message.author.display_avatar.url
1141+
)
1142+
1143+
# Add timestamp if enabled
1144+
if self.bot.config["show_timestamp"]:
1145+
embed.timestamp = message.created_at
1146+
1147+
# Add a subtle footer to distinguish from replies
1148+
embed.set_footer(text="Internal Note")
1149+
1150+
return await destination.send(embed=embed)
1151+
11281152
if not note and from_mod:
11291153
self.bot.loop.create_task(self._restart_close_timer()) # Start or restart thread auto close
11301154

@@ -1217,12 +1241,18 @@ async def send(
12171241
url=f"https://discordapp.com/users/{author.id}#{message.id}",
12181242
)
12191243
else:
1220-
# Notes are just replies with a different footer and color
1244+
# Notes use system message style with note icon
1245+
if persistent_note:
1246+
note_type = "Persistent Note"
1247+
else:
1248+
note_type = "Note"
1249+
12211250
embed.set_author(
1222-
name=str(author),
1251+
name=f"📝 {note_type} ({str(author)})",
12231252
icon_url=avatar_url,
12241253
url=f"https://discordapp.com/users/{author.id}#{message.id}",
12251254
)
1255+
embed.color = 0x5865F2 # Discord blurple for system messages
12261256

12271257
ext = [(a.url, a.filename, False) for a in message.attachments]
12281258

@@ -1347,20 +1377,27 @@ def lottie_to_png(data):
13471377
file_upload_count += 1
13481378

13491379
if from_mod:
1350-
embed.colour = self.bot.mod_color
13511380
if note:
1352-
embed.set_footer(text=f"{'Persistent' if persistent_note else ''} Internal Message")
1353-
# Anonymous reply sent in thread channel
1354-
elif anonymous and isinstance(destination, discord.TextChannel):
1355-
embed.set_footer(text="Anonymous Reply")
1356-
# Normal messages
1357-
elif not anonymous:
1358-
mod_tag = self.bot.config["mod_tag"]
1359-
if mod_tag is None:
1360-
mod_tag = str(get_top_role(message.author, self.bot.config["use_hoisted_top_role"]))
1361-
embed.set_footer(text=mod_tag) # Normal messages
1381+
# Notes use Discord blurple and special footer
1382+
embed.colour = 0x5865F2
1383+
if persistent_note:
1384+
embed.set_footer(text="Persistent Internal Message")
1385+
else:
1386+
embed.set_footer(text="Internal Message")
13621387
else:
1363-
embed.set_footer(text=self.bot.config["anon_tag"])
1388+
# Regular mod messages
1389+
embed.colour = self.bot.mod_color
1390+
# Anonymous reply sent in thread channel
1391+
if anonymous and isinstance(destination, discord.TextChannel):
1392+
embed.set_footer(text="Anonymous Reply")
1393+
# Normal messages
1394+
elif not anonymous:
1395+
mod_tag = self.bot.config["mod_tag"]
1396+
if mod_tag is None:
1397+
mod_tag = str(get_top_role(message.author, self.bot.config["use_hoisted_top_role"]))
1398+
embed.set_footer(text=mod_tag) # Normal messages
1399+
else:
1400+
embed.set_footer(text=self.bot.config["anon_tag"])
13641401
else:
13651402
embed.set_footer(text=f"Message ID: {message.id}")
13661403
embed.colour = self.bot.recipient_color

0 commit comments

Comments
 (0)