Skip to content

Commit 70aeffd

Browse files
committed
Merge from "master"
2 parents 88a2957 + 7876270 commit 70aeffd

File tree

5 files changed

+150
-99
lines changed

5 files changed

+150
-99
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ 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
17+
818
Changed order of arguments for the contact command. This is so that you can use aliases to their full potential.
919
For example:
1020
- `contact "Recruitment Category" @somedude`

bot.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,32 @@ def blocked_users(self):
172172
@property
173173
def prefix(self):
174174
return self.config.get('prefix', '?')
175+
176+
@property
177+
def mod_color(self):
178+
color = self.config.get('mod_color')
179+
if not color:
180+
return discord.Color.green()
181+
try:
182+
color = int(color.lstrip('#'), base=16)
183+
except ValueError:
184+
print('Invalid mod_color provided')
185+
return discord.Color.green()
186+
else:
187+
return color
188+
189+
@property
190+
def recipient_color(self):
191+
color = self.config.get('recipient_color')
192+
if not color:
193+
return discord.Color.gold()
194+
try:
195+
color = int(color.lstrip('#'), base=16)
196+
except ValueError:
197+
print('Invalid recipient_color provided')
198+
return discord.Color.gold()
199+
else:
200+
return color
175201

176202
@staticmethod
177203
async def get_pre(bot, message): # TODO: there gotta be a better way
@@ -409,10 +435,6 @@ async def on_message_edit(self, before, after):
409435
embed = msg.embeds[0]
410436
matches = str(embed.author.url).split('/')
411437
if matches and matches[-1] == str(before.id):
412-
if ' - (Edited)' not in embed.footer.text:
413-
embed.set_footer(
414-
text=embed.footer.text + ' - (Edited)'
415-
)
416438
embed.description = after.content
417439
await msg.edit(embed=embed)
418440
break

cogs/modmail.py

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,25 @@ async def snippets(self, ctx):
6464

6565
embeds = []
6666

67-
em = discord.Embed(color=discord.Color.green())
68-
em.set_author(name='Snippets', icon_url=ctx.guild.icon_url)
69-
70-
embeds.append(em)
71-
72-
em.description = ('Here is a list of snippets '
73-
'that are currently configured.')
74-
75-
if not self.bot.snippets:
76-
em.color = discord.Color.red()
77-
em.description = f'You dont have any snippets at the moment.'
67+
if self.bot.snippets:
68+
em = discord.Embed(color=discord.Color.blurple(),
69+
description='Here is a list of snippets '
70+
'that are currently configured.')
71+
else:
72+
em = discord.Embed(
73+
color=discord.Color.red(),
74+
description='You dont have any snippets at the moment.'
75+
)
7876
em.set_footer(
7977
text=f'Do {self.bot.prefix}help snippets for more commands.'
8078
)
8179

80+
em.set_author(name='Snippets', icon_url=ctx.guild.icon_url)
81+
embeds.append(em)
82+
8283
for name, value in self.bot.snippets.items():
8384
if len(em.fields) == 5:
84-
em = discord.Embed(color=discord.Color.green(),
85+
em = discord.Embed(color=discord.Color.blurple(),
8586
description=em.description)
8687
em.set_author(name='Snippets', icon_url=ctx.guild.icon_url)
8788
embeds.append(em)
@@ -101,7 +102,7 @@ async def add_(self, ctx, name: str.lower, *, value):
101102

102103
em = discord.Embed(
103104
title='Added snippet',
104-
color=discord.Color.green(),
105+
color=discord.Color.blurple(),
105106
description=f'`{name}` points to: {value}'
106107
)
107108

@@ -111,20 +112,22 @@ async def add_(self, ctx, name: str.lower, *, value):
111112
async def del_(self, ctx, *, name: str.lower):
112113
"""Removes a snippet from bot config."""
113114

114-
em = discord.Embed(
115-
title='Removed snippet',
116-
color=discord.Color.green(),
117-
description=f'`{name}` no longer exists.'
118-
)
119-
120-
if not self.bot.config.snippets.get(name):
121-
em.title = 'Error'
122-
em.color = discord.Color.red()
123-
em.description = f'Snippet `{name}` does not exist.'
124-
else:
115+
if self.bot.config.snippets.get(name):
116+
em = discord.Embed(
117+
title='Removed snippet',
118+
color=discord.Color.blurple(),
119+
description=f'`{name}` no longer exists.'
120+
)
125121
del self.bot.config['snippets'][name]
126122
await self.bot.config.update()
127123

124+
else:
125+
em = discord.Embed(
126+
title='Error',
127+
color=discord.Color.red(),
128+
description=f'Snippet `{name}` does not exist.'
129+
)
130+
128131
await ctx.send(embed=em)
129132

130133
@commands.command()
@@ -246,7 +249,7 @@ async def notify(self, ctx, *, role=None):
246249
else:
247250
mentions.append(mention)
248251
await self.bot.config.update()
249-
em = discord.Embed(color=discord.Color.green(),
252+
em = discord.Embed(color=discord.Color.blurple(),
250253
description=f'{mention} will be mentioned '
251254
'on the next message received.')
252255
return await ctx.send(embed=em)
@@ -284,7 +287,7 @@ async def subscribe(self, ctx, *, role=None):
284287
else:
285288
mentions.append(mention)
286289
await self.bot.config.update()
287-
em = discord.Embed(color=discord.Color.green(),
290+
em = discord.Embed(color=discord.Color.blurple(),
288291
description=f'{mention} will now be notified '
289292
'of all messages received.')
290293
return await ctx.send(embed=em)
@@ -317,7 +320,7 @@ async def unsubscribe(self, ctx, *, role=None):
317320
else:
318321
mentions.remove(mention)
319322
await self.bot.config.update()
320-
em = discord.Embed(color=discord.Color.green(),
323+
em = discord.Embed(color=discord.Color.blurple(),
321324
description=f'{mention} is now unsubscribed '
322325
'to this thread.')
323326
return await ctx.send(embed=em)
@@ -372,7 +375,7 @@ async def logs(self, ctx, *,
372375

373376
for index, entry in enumerate(closed_logs):
374377
if len(embeds[-1].fields) == 3:
375-
em = discord.Embed(color=discord.Color.green())
378+
em = discord.Embed(color=discord.Color.blurple())
376379
em.set_author(name='Previous Logs', icon_url=icon_url)
377380
embeds.append(em)
378381

@@ -454,7 +457,7 @@ async def edit(self, ctx, message_id: Optional[int] = None,
454457
async for msg in ctx.channel.history():
455458
if message_id is None and msg.embeds:
456459
em = msg.embeds[0]
457-
if 'Moderator' not in str(em.footer.text):
460+
if em.color != discord.Color.green() or not em.author.url:
458461
continue
459462
linked_message_id = str(em.author.url).split('/')[-1]
460463
break
@@ -492,7 +495,7 @@ async def contact(self, ctx,
492495
title='Created thread',
493496
description=f'Thread started in {thread.channel.mention} '
494497
f'for {user.mention}',
495-
color=discord.Color.green()
498+
color=discord.Color.blurple()
496499
)
497500

498501
return await ctx.send(embed=em)
@@ -503,8 +506,8 @@ async def contact(self, ctx,
503506
async def blocked(self, ctx):
504507
"""Returns a list of blocked users"""
505508
em = discord.Embed(title='Blocked Users',
506-
color=discord.Color.green(),
507-
description='')
509+
color=discord.Color.blurple(),
510+
description='Here is a list of blocked users.')
508511

509512
users = []
510513
not_reachable = []
@@ -516,8 +519,6 @@ async def blocked(self, ctx):
516519
else:
517520
not_reachable.append((id_, reason))
518521

519-
em.description = 'Here is a list of blocked users.'
520-
521522
if users:
522523
val = '\n'.join(u.mention + (f' - `{r}`' if r else '')
523524
for u, r in users)
@@ -549,19 +550,21 @@ async def block(self, ctx,
549550

550551
mention = user.mention if hasattr(user, 'mention') else f'`{user.id}`'
551552

552-
em = discord.Embed(color=discord.Color.green())
553-
554553
if str(user.id) not in self.bot.blocked_users:
555554
self.bot.config.blocked[str(user.id)] = reason
556555
await self.bot.config.update()
557-
558-
em.title = 'Success'
559556
extend = f'for `{reason}`' if reason else ''
560-
em.description = f'{mention} is now blocked ' + extend
557+
em = discord.Embed(
558+
title='Success',
559+
color=discord.Color.blurple(),
560+
description=f'{mention} is now blocked ' + extend
561+
)
561562
else:
562-
em.title = 'Error'
563-
em.description = f'{mention} is already blocked'
564-
em.color = discord.Color.red()
563+
em = discord.Embed(
564+
title='Error',
565+
color=discord.Color.red(),
566+
description=f'{mention} is already blocked'
567+
)
565568

566569
return await ctx.send(embed=em)
567570

@@ -581,18 +584,20 @@ async def unblock(self, ctx, *,
581584

582585
mention = user.mention if hasattr(user, 'mention') else f'`{user.id}`'
583586

584-
em = discord.Embed(color=discord.Color.green())
585-
586587
if str(user.id) in self.bot.blocked_users:
587588
del self.bot.config.blocked[str(user.id)]
588589
await self.bot.config.update()
589-
590-
em.title = 'Success'
591-
em.description = f'{mention} is no longer blocked'
590+
em = discord.Embed(
591+
title='Success',
592+
color=discord.Color.blurple(),
593+
description=f'{mention} is no longer blocked'
594+
)
592595
else:
593-
em.title = 'Error'
594-
em.description = f'{mention} is not blocked'
595-
em.color = discord.Color.red()
596+
em = discord.Embed(
597+
title='Error',
598+
description=f'{mention} is not blocked',
599+
color=discord.Color.red()
600+
)
596601

597602
return await ctx.send(embed=em)
598603

0 commit comments

Comments
 (0)