Skip to content

Commit 0a02385

Browse files
committed
Improve formatting slightly
1 parent 804265d commit 0a02385

File tree

4 files changed

+55
-45
lines changed

4 files changed

+55
-45
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
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+
# [Unreleased]
8+
9+
### Changed
10+
- Improve format of thread message embeds. Slightly cleaner and simpler now.
11+
- All commands are now blurple instead of green.
12+
13+
### Added
14+
- Ability to set your own custom `mod_color` and `recipient_color` for the thread message embeds.
15+
716
# v2.9.1
817
Changed order of arguments for the contact command. This is so that you can use aliases to their full potential.
918
For example:

cogs/modmail.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def snippets(self, ctx):
5757

5858
embeds = []
5959

60-
em = discord.Embed(color=discord.Color.green())
60+
em = discord.Embed(color=discord.Color.blurple())
6161
em.set_author(name='Snippets', icon_url=ctx.guild.icon_url)
6262

6363
embeds.append(em)
@@ -71,7 +71,7 @@ async def snippets(self, ctx):
7171

7272
for name, value in self.bot.snippets.items():
7373
if len(em.fields) == 5:
74-
em = discord.Embed(color=discord.Color.green(), description=em.description)
74+
em = discord.Embed(color=discord.Color.blurple(), description=em.description)
7575
em.set_author(name='Snippets', icon_url=ctx.guild.icon_url)
7676
embeds.append(em)
7777
em.add_field(name=name, value=value, inline=False)
@@ -90,7 +90,7 @@ async def _add(self, ctx, name: str.lower, *, value):
9090

9191
em = discord.Embed(
9292
title='Added snippet',
93-
color=discord.Color.green(),
93+
color=discord.Color.blurple(),
9494
description=f'`{name}` points to: {value}'
9595
)
9696

@@ -102,7 +102,7 @@ async def __del(self, ctx, *, name: str.lower):
102102

103103
em = discord.Embed(
104104
title='Removed snippet',
105-
color=discord.Color.green(),
105+
color=discord.Color.blurple(),
106106
description=f'`{name}` no longer exists.'
107107
)
108108

@@ -224,7 +224,7 @@ async def notify(self, ctx, *, role=None):
224224
mentions.append(mention)
225225
await self.bot.config.update()
226226

227-
em = discord.Embed(color=discord.Color.green())
227+
em = discord.Embed(color=discord.Color.blurple())
228228
em.description = f'{mention} will be mentioned on the next message received.'
229229
await ctx.send(embed=em)
230230

@@ -257,7 +257,7 @@ async def subscribe(self, ctx, *, role=None):
257257
mentions.append(mention)
258258
await self.bot.config.update()
259259

260-
em = discord.Embed(color=discord.Color.green())
260+
em = discord.Embed(color=discord.Color.blurple())
261261
em.description = f'{mention} is now subscribed to be notified of all messages received.'
262262
await ctx.send(embed=em)
263263

@@ -288,7 +288,7 @@ async def unsubscribe(self, ctx, *, role=None):
288288
mentions.remove(mention)
289289
await self.bot.config.update()
290290

291-
em = discord.Embed(color=discord.Color.green())
291+
em = discord.Embed(color=discord.Color.blurple())
292292
em.description = f'{mention} is now unsubscribed to this thread.'
293293
await ctx.send(embed=em)
294294

@@ -336,7 +336,7 @@ async def logs(self, ctx, *, member: Union[discord.Member, discord.User, obj]=No
336336

337337
for index, entry in enumerate(closed_logs):
338338
if len(embeds[-1].fields) == 3:
339-
em = discord.Embed(color=discord.Color.green())
339+
em = discord.Embed(color=discord.Color.blurple())
340340
em.set_author(name='Previous Logs', icon_url=icon_url)
341341
embeds.append(em)
342342

@@ -406,7 +406,7 @@ async def edit(self, ctx, message_id: Optional[int]=None, *, new_message):
406406
async for msg in ctx.channel.history():
407407
if message_id is None and msg.embeds:
408408
em = msg.embeds[0]
409-
if 'Moderator' not in str(em.footer.text):
409+
if em.color != discord.Color.green() or not em.author.url:
410410
continue
411411
linked_message_id = str(em.author.url).split('/')[-1]
412412
break
@@ -417,7 +417,7 @@ async def edit(self, ctx, message_id: Optional[int]=None, *, new_message):
417417

418418
if not linked_message_id:
419419
raise commands.UserInputError
420-
420+
421421
await thread.edit_message(linked_message_id, new_message)
422422
await ctx.message.add_reaction('✅')
423423

@@ -436,7 +436,7 @@ async def contact(self, ctx, category: Optional[discord.CategoryChannel]=None, *
436436
em = discord.Embed(
437437
title='Created thread',
438438
description=f'Thread started in {thread.channel.mention} for {user.mention}',
439-
color=discord.Color.green()
439+
color=discord.Color.blurple()
440440
)
441441

442442
await ctx.send(embed=em)
@@ -446,7 +446,7 @@ async def contact(self, ctx, category: Optional[discord.CategoryChannel]=None, *
446446
@commands.has_permissions(manage_channels=True)
447447
async def blocked(self, ctx):
448448
"""Returns a list of blocked users"""
449-
em = discord.Embed(title='Blocked Users', color=discord.Color.green(), description='')
449+
em = discord.Embed(title='Blocked Users', color=discord.Color.blurple(), description='')
450450

451451
users = []
452452
not_reachable = []
@@ -487,7 +487,7 @@ async def block(self, ctx, user: Union[discord.Member, discord.User, obj]=None,
487487
mention = user.mention if hasattr(user, 'mention') else f'`{user.id}`'
488488

489489
em = discord.Embed()
490-
em.color = discord.Color.green()
490+
em.color = discord.Color.blurple()
491491

492492
if str(user.id) not in self.bot.blocked_users:
493493
self.bot.config.blocked[str(user.id)] = reason
@@ -520,7 +520,7 @@ async def unblock(self, ctx, *, user: Union[discord.Member, discord.User, obj]=N
520520
mention = user.mention if hasattr(user, 'mention') else f'`{user.id}`'
521521

522522
em = discord.Embed()
523-
em.color = discord.Color.green()
523+
em.color = discord.Color.blurple()
524524

525525
if str(user.id) in self.bot.blocked_users:
526526
del self.bot.config.blocked[str(user.id)]

cogs/utility.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def format_cog_help(self, ctx, cog):
6565

6666
em = discord.Embed(
6767
description='*' + inspect.getdoc(cog) + '*',
68-
color=discord.Colour.green()
68+
color=discord.Colour.blurple()
6969
)
7070
em.set_author(name=cog.__class__.__name__ + ' - Help', icon_url=ctx.bot.user.avatar_url)
7171

@@ -82,7 +82,7 @@ def format_command_help(self, ctx, cmd):
8282
"""Formats command help."""
8383
prefix = self.bot.prefix
8484
em = discord.Embed(
85-
color=discord.Color.green(),
85+
color=discord.Color.blurple(),
8686
description=cmd.help
8787
)
8888

@@ -218,7 +218,7 @@ async def github(self, ctx):
218218
em = discord.Embed(
219219
title='Github',
220220
description='Current User',
221-
color=discord.Color.green()
221+
color=discord.Color.blurple()
222222
)
223223
user = data['user']
224224
em.set_author(name=user['username'], icon_url=user['avatar_url'], url=user['url'])
@@ -236,7 +236,7 @@ async def update(self, ctx):
236236
em = discord.Embed(
237237
title='Already up to date',
238238
description=f'The latest version is [`{self.bot.version}`](https://github.com/kyb3r/modmail/blob/master/bot.py#L25)',
239-
color=discord.Color.green()
239+
color=discord.Color.blurple()
240240
)
241241

242242
if metadata['latest_version'] == self.bot.version:
@@ -286,7 +286,7 @@ async def activity(self, ctx, activity_type: str, *, message: str = ''):
286286
await self.bot.config.update()
287287
em = discord.Embed(
288288
title='Activity Removed',
289-
color=discord.Color.green()
289+
color=discord.Color.blurple()
290290
)
291291
return await ctx.send(embed=em)
292292

@@ -308,7 +308,7 @@ async def activity(self, ctx, activity_type: str, *, message: str = ''):
308308
em = discord.Embed(
309309
title='Activity Changed',
310310
description=f'Current activity is: {activity_type.name} {message}.',
311-
color=discord.Color.green()
311+
color=discord.Color.blurple()
312312
)
313313
return await ctx.send(embed=em)
314314

@@ -330,7 +330,7 @@ async def mention(self, ctx, *, mention=None):
330330
current = self.bot.config.get('mention', '@here')
331331
em = discord.Embed(
332332
title='Current text',
333-
color=discord.Color.green(),
333+
color=discord.Color.blurple(),
334334
description=f'{current}'
335335
)
336336

@@ -351,7 +351,7 @@ async def prefix(self, ctx, *, prefix=None):
351351
current = self.bot.prefix
352352
em = discord.Embed(
353353
title='Current prefix',
354-
color=discord.Color.green(),
354+
color=discord.Color.blurple(),
355355
description=f'{current}'
356356
)
357357

@@ -376,7 +376,7 @@ async def config(self, ctx):
376376
async def options(self, ctx):
377377
"""Return a list of valid config keys you can change."""
378378
valid = ', '.join(f'`{k}`' for k in self.bot.config.allowed_to_change_in_command)
379-
em = discord.Embed(title='Valid Keys', description=valid, color=discord.Color.green())
379+
em = discord.Embed(title='Valid Keys', description=valid, color=discord.Color.blurple())
380380
await ctx.send(embed=em)
381381

382382
@config.command(name='set')
@@ -387,13 +387,13 @@ async def _set(self, ctx, key: str.lower, *, value):
387387

388388
em = discord.Embed(
389389
title='Success',
390-
color=discord.Color.green(),
390+
color=discord.Color.blurple(),
391391
description=f'Set `{key}` to `{value}`'
392392
)
393393

394394
if key not in self.bot.config.allowed_to_change_in_command:
395395
em.title = 'Error'
396-
em.color = discord.Color.green()
396+
em.color = discord.Color.blurple()
397397
em.description = f'{key} is an invalid key.'
398398
valid_keys = [f'`{k}`' for k in self.bot.config.allowed_to_change_in_command]
399399
em.add_field(name='Valid keys', value=', '.join(valid_keys))
@@ -407,13 +407,13 @@ async def _del(self, ctx, key: str.lower):
407407
"""Sets a specified key from the config to nothing."""
408408
em = discord.Embed(
409409
title='Success',
410-
color=discord.Color.green(),
410+
color=discord.Color.blurple(),
411411
description=f'Set `{key}` to nothing.'
412412
)
413413

414414
if key not in self.bot.config.allowed_to_change_in_command:
415415
em.title = 'Error'
416-
em.color = discord.Color.green()
416+
em.color = discord.Color.blurple()
417417
em.description = f'{key} is an invalid key.'
418418
valid_keys = [f'`{k}`' for k in self.bot.config.allowed_to_change_in_command]
419419
em.add_field(name='Valid keys', value=', '.join(valid_keys))
@@ -426,12 +426,12 @@ async def _del(self, ctx, key: str.lower):
426426
@config.command(name='get')
427427
async def get(self, ctx, key=None):
428428
"""Shows the config variables that are currently set."""
429-
em = discord.Embed(color=discord.Color.green())
429+
em = discord.Embed(color=discord.Color.blurple())
430430
em.set_author(name='Current config', icon_url=self.bot.user.avatar_url)
431431

432432
if key and key not in self.bot.config.allowed_to_change_in_command:
433433
em.title = 'Error'
434-
em.color = discord.Color.green()
434+
em.color = discord.Color.blurple()
435435
em.description = f'`{key}` is an invalid key.'
436436
valid_keys = [f'`{k}`' for k in self.bot.config.allowed_to_change_in_command]
437437
em.add_field(name='Valid keys', value=', '.join(valid_keys))
@@ -460,7 +460,7 @@ async def aliases(self, ctx):
460460

461461
embeds = []
462462

463-
em = discord.Embed(color=discord.Color.green())
463+
em = discord.Embed(color=discord.Color.blurple())
464464
em.set_author(name='Command aliases', icon_url=ctx.guild.icon_url)
465465

466466
embeds.append(em)
@@ -474,7 +474,7 @@ async def aliases(self, ctx):
474474

475475
for name, value in self.bot.aliases.items():
476476
if len(em.fields) == 5:
477-
em = discord.Embed(color=discord.Color.green(), description=em.description)
477+
em = discord.Embed(color=discord.Color.blurple(), description=em.description)
478478
em.set_author(name='Command aliases', icon_url=ctx.guild.icon_url)
479479
em.set_footer(text=f'Do {self.bot.prefix}help aliases for more commands.')
480480
embeds.append(em)
@@ -500,7 +500,7 @@ async def _add(self, ctx, name: str.lower, *, value):
500500

501501
em = discord.Embed(
502502
title='Added alias',
503-
color=discord.Color.green(),
503+
color=discord.Color.blurple(),
504504
description=f'`{name}` points to: {value}'
505505
)
506506

@@ -515,7 +515,7 @@ async def __del(self, ctx, *, name: str.lower):
515515

516516
em = discord.Embed(
517517
title='Removed alias',
518-
color=discord.Color.green(),
518+
color=discord.Color.blurple(),
519519
description=f'`{name}` no longer exists.'
520520
)
521521

core/thread.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def _close(self, closer, silent=False, delete_channel=True,
9999
}
100100
})
101101

102-
if not isinstance(log_data, str) or log_data is not None:
102+
if log_data is not None and isinstance(log_data, dict):
103103
if self.bot.selfhosted:
104104
log_url = f"{self.bot.config.log_url.strip('/')}/logs/{log_data['key']}"
105105
else:
@@ -160,9 +160,6 @@ async def _edit_thread_message(channel, message_id, message):
160160
embed = msg.embeds[0]
161161
if embed and embed.author and embed.author.url:
162162
if str(message_id) == str(embed.author.url).split('/')[-1]:
163-
if ' - (Edited)' not in embed.footer.text:
164-
embed.set_footer(
165-
text=embed.footer.text + ' - (Edited)')
166163
embed.description = message
167164
await msg.edit(embed=embed)
168165
break
@@ -236,15 +233,22 @@ async def send(self, message, destination=None, from_mod=False, note=False):
236233

237234
em = discord.Embed(
238235
description=message.content,
239-
timestamp=message.created_at
236+
# timestamp=message.created_at
240237
)
241238

242239
system_avatar_url = 'https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png'
243240

244241
# store message id in hidden url
245-
em.set_author(name=str(author) if not note else 'Note',
246-
icon_url=author.avatar_url if not note else system_avatar_url,
242+
if not note:
243+
em.set_author(name=author.name,
244+
icon_url=author.avatar_url,
247245
url=message.jump_url)
246+
else:
247+
em.set_author(
248+
name=f'Note ({author.name})',
249+
icon_url=system_avatar_url,
250+
url=message.jump_url
251+
)
248252

249253
image_types = ['.png', '.jpg', '.gif', '.jpeg', '.webp']
250254

@@ -292,14 +296,11 @@ def is_image_url(u, _):
292296
file_upload_count += 1
293297

294298
if from_mod:
295-
em.color = discord.Color.green()
296-
em.set_footer(text=f'Moderator')
299+
em.color = self.bot.mod_color
297300
elif note:
298301
em.color = discord.Color.blurple()
299-
em.set_footer(text=f'System ({author.name})')
300302
else:
301-
em.color = discord.Color.gold()
302-
em.set_footer(text=f'User')
303+
em.color = self.bot.recipient_color
303304

304305
await destination.trigger_typing()
305306

0 commit comments

Comments
 (0)