Skip to content

Commit 7d9eb14

Browse files
authored
Merge pull request #260 from kyb3r/show-mutual-guilds
Mutual guilds field and pinned notes
2 parents f2ae0e5 + f003a75 commit 7d9eb14

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# v2.23.0
8+
9+
### Added
10+
11+
Added a "Mutual servers" field to the genesis embed if:
12+
a) The user is not in the main guild.
13+
b) The user shares more than 1 server with the bot.
14+
15+
### Changed
16+
17+
Notes taken using the `?note` command are now automatically pinned within the thread channel.
18+
719
# v2.22.0
820

921
### Added

bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = "2.22.0"
25+
__version__ = "2.23.0"
2626

2727
import asyncio
2828
import logging

cogs/modmail.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ async def note(self, ctx, *, msg: str = ""):
655655
"""
656656
ctx.message.content = msg
657657
async with ctx.typing():
658-
await ctx.thread.note(ctx.message)
658+
msg = await ctx.thread.note(ctx.message)
659+
await msg.pin()
659660

660661
async def find_linked_message(self, ctx, message_id):
661662
linked_message_id = None

core/thread.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,21 @@ async def setup(self, *, creator=None, category=None):
120120
log_url = log_count = None
121121
# ensure core functionality still works
122122

123-
info_embed = self.manager.format_info_embed(
124-
recipient, log_url, log_count, discord.Color.green()
125-
)
126-
127123
topic = f"User ID: {recipient.id}"
128124
if creator:
129125
mention = None
130126
else:
131127
mention = self.bot.config.get("mention", "@here")
132128

133129
async def send_genesis_message():
130+
info_embed = self.manager.format_info_embed(
131+
recipient, log_url, log_count, discord.Color.green()
132+
)
134133
try:
135134
msg = await channel.send(mention, embed=info_embed)
136135
self.bot.loop.create_task(msg.pin())
137136
self.genesis_message = msg
138-
except:
137+
except Exception as e:
139138
pass
140139
finally:
141140
self.ready = True
@@ -365,11 +364,13 @@ async def note(self, message: discord.Message) -> None:
365364
if not message.content and not message.attachments:
366365
raise MissingRequiredArgument(param(name="msg"))
367366

368-
await asyncio.gather(
367+
_, msg = await asyncio.gather(
369368
self.bot.api.append_log(message, self.channel.id, type_="system"),
370369
self.send(message, self.channel, note=True),
371370
)
372371

372+
return msg
373+
373374
async def reply(self, message: discord.Message, anonymous: bool = False) -> None:
374375
if not message.content and not message.attachments:
375376
raise MissingRequiredArgument(param(name="msg"))
@@ -580,7 +581,8 @@ async def send(
580581
else:
581582
mentions = None
582583

583-
await destination.send(mentions, embed=embed)
584+
_msg = await destination.send(mentions, embed=embed)
585+
584586
if additional_images:
585587
self.ready = False
586588
await asyncio.gather(*additional_images)
@@ -589,6 +591,8 @@ async def send(
589591
if delete_message:
590592
self.bot.loop.create_task(ignore(message.delete()))
591593

594+
return _msg
595+
592596
def get_notifications(self) -> str:
593597
config = self.bot.config
594598
key = str(self.id)
@@ -792,9 +796,7 @@ def format_info_embed(self, user, log_url, log_count, color):
792796
if role_names:
793797
embed.add_field(name="Roles", value=role_names, inline=True)
794798
else:
795-
embed.set_footer(
796-
text=f"{footer} | Note: this member " "is not part of this server."
797-
)
799+
embed.set_footer(text=f"{footer} • (not in main server)")
798800

799801
if log_count:
800802
# embed.add_field(name='Past logs', value=f'{log_count}')
@@ -803,4 +805,10 @@ def format_info_embed(self, user, log_url, log_count, color):
803805
else:
804806
embed.description += "."
805807

808+
mutual_guilds = [g for g in self.bot.guilds if user in g.members]
809+
if user not in self.bot.guild.members or len(mutual_guilds) > 1:
810+
embed.add_field(
811+
name="Mutual Servers", value=", ".join(g.name for g in mutual_guilds)
812+
)
813+
806814
return embed

0 commit comments

Comments
 (0)