Skip to content

Commit 290a8fa

Browse files
committed
Fixed some issues with how data is displayed in the info embed.
1 parent e630992 commit 290a8fa

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ 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.0.3
8+
9+
Fixed some issues with how data is displayed in the info embed.
10+
11+
### Fixed
12+
- Thread creation embed now shows the correct amount of past logs.
13+
- If using a seperate server setup, roles in the info embed now are shown as names instead of mentions.
14+
- This is due to the fact that you can't mention roles across servers.
15+
716
# v2.0.2
817

918
### Security

bot.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.0.2'
25+
__version__ = '2.0.3'
2626

2727
import asyncio
2828
import textwrap
@@ -36,12 +36,13 @@
3636
from discord.ext.commands.view import StringView
3737
from colorama import init, Fore, Style
3838

39+
init()
40+
3941
from core.api import Github, ModmailApiClient
4042
from core.thread import ThreadManager
4143
from core.config import ConfigManager
4244

4345

44-
init()
4546

4647
line = Fore.BLACK + Style.BRIGHT + '-------------------------' + Style.RESET_ALL
4748

@@ -111,10 +112,12 @@ def guild_id(self):
111112

112113
@property
113114
def guild(self):
115+
'''The guild that the bot is serving (the server where users message it from)'''
114116
return discord.utils.get(self.guilds, id=self.guild_id)
115117

116118
@property
117119
def modmail_guild(self):
120+
'''The guild that the bot is operating in (where the bot is creating threads)'''
118121
modmail_guild_id = self.config.get('modmail_guild_id')
119122
if not modmail_guild_id:
120123
return self.guild

core/thread.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def edit_message(self, message_id, message):
6565

6666
async def reply(self, message):
6767
if not message.content and not message.attachments:
68-
raise commands.UserInputError('msg is a required argument.')
68+
raise commands.UserInputError
6969
if not self.recipient:
7070
return await message.channel.send('This user does not share any servers with the bot and is thus unreachable.')
7171
await asyncio.gather(
@@ -227,7 +227,7 @@ async def create(self, recipient, *, creator=None):
227227
self.get_dominant_color(recipient.avatar_url)
228228
)
229229

230-
log_count = len(log_data)
230+
log_count = sum(1 for log in log_data if not log['open'])
231231
info_embed = self._format_info_embed(recipient, creator, log_url, log_count, dc)
232232

233233
topic = f'User ID: {recipient.id}'
@@ -303,8 +303,9 @@ def _format_info_embed(self, user, creator, log_url, log_count, dc):
303303
desc = f'{desc} [`{key}`]({log_url})'
304304

305305
if member:
306+
seperate_server = self.bot.guild != self.bot.modmail_guild
306307
roles = sorted(member.roles, key=lambda c: c.position)
307-
rolenames = ' '.join([r.mention for r in roles if r.name != "@everyone"])
308+
rolenames = ' '.join(r.mention if not seperate_server else r.name for r in roles if r.name != "@everyone")
308309

309310
em = discord.Embed(colour=dc, description=desc, timestamp=time)
310311

@@ -323,8 +324,8 @@ def _format_info_embed(self, user, creator, log_url, log_count, dc):
323324
em.add_field(name='Past logs', value=f'{log_count}')
324325
joined = str((time - member.joined_at).days)
325326
em.add_field(name='Joined', value=joined + days(joined))
326-
# em.add_field(name='Member No.',value=str(member_number),inline = True)
327-
em.add_field(name='Nickname', value=member.nick, inline=True)
327+
if member.nick:
328+
em.add_field(name='Nickname', value=member.nick, inline=True)
328329
if rolenames:
329330
em.add_field(name='Roles', value=rolenames, inline=False)
330331
else:

0 commit comments

Comments
 (0)