Skip to content

Commit af65a09

Browse files
committed
Updated changelog, pylint
1 parent 933b56d commit af65a09

File tree

8 files changed

+52
-47
lines changed

8 files changed

+52
-47
lines changed

.pylintrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ disable=raw-checker-failed,
7979
too-many-instance-attributes,
8080
too-many-arguments,
8181
too-few-public-methods,
82-
too-many-lines
82+
too-many-lines,
83+
line-too-long
8384

8485

8586
# Enable the message, report, category or checker with the given id(s). You can
@@ -361,12 +362,12 @@ good-names=i,
361362
k,
362363
ex,
363364
_,
364-
v,
365365
id,
366366
db,
367367
f,
368368
dt,
369-
c
369+
ch,
370+
ts
370371

371372
# Include a hint for the correct naming format with invalid-name.
372373
include-naming-hint=yes

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ 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

77

8+
# v2.20.1
9+
10+
### Changes
11+
12+
This update contains mostly internal changes.
13+
- Implemented support for the new discord.py v1.1.1.
14+
- New error message when using thread-only commands outside of threads.
15+
- Improved help text for most commands.
16+
- Completely revamped help command, few user changes.
17+
- Removed abc (internal).
18+
819
# v2.20.0
920

1021
### What's new?

bot.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.20.0'
25+
__version__ = '2.20.1'
2626

2727
import asyncio
2828
import logging
@@ -32,7 +32,6 @@
3232
import typing
3333

3434
from datetime import datetime
35-
from pkg_resources import parse_version
3635
from types import SimpleNamespace
3736

3837
import discord
@@ -45,6 +44,7 @@
4544
from colorama import init, Fore, Style
4645
from emoji import UNICODE_EMOJI
4746
from motor.motor_asyncio import AsyncIOMotorClient
47+
from pkg_resources import parse_version
4848

4949
from core.changelog import Changelog
5050
from core.clients import ApiClient, PluginDatabaseClient
@@ -240,7 +240,7 @@ def run(self, *args, **kwargs):
240240
async def is_owner(self, user: discord.User) -> bool:
241241
raw = str(self.config.get('owners', '0')).split(',')
242242
allowed = {int(x) for x in raw}
243-
return (user.id in allowed) or await super().is_owner(user)
243+
return (user.id in allowed) or await super().is_owner(user)
244244

245245
@property
246246
def log_channel(self) -> typing.Optional[discord.TextChannel]:
@@ -518,8 +518,8 @@ async def process_modmail(self, message: discord.Message) -> None:
518518

519519
try:
520520
min_account_age = message.author.created_at + account_age
521-
except ValueError as e:
522-
logger.warning(e.args[0])
521+
except ValueError as exc:
522+
logger.warning(exc.args[0])
523523
del self.config.cache['account_age']
524524
await self.config.update()
525525
min_account_age = now
@@ -530,8 +530,8 @@ async def process_modmail(self, message: discord.Message) -> None:
530530
min_guild_age = member.joined_at + guild_age
531531
else:
532532
min_guild_age = now
533-
except ValueError as e:
534-
logger.warning(e.args[0])
533+
except ValueError as exc:
534+
logger.warning(exc.args[0])
535535
del self.config.cache['guild_age']
536536
await self.config.update()
537537
min_guild_age = now
@@ -641,11 +641,6 @@ async def get_context(self, message, *, cls=commands.Context):
641641
ctx.prefix = self.prefix # Sane prefix (No mentions)
642642
ctx.command = self.all_commands.get(invoker)
643643

644-
has_ai = hasattr(ctx, '_alias_invoked')
645-
if ctx.command is self.get_command('eval') and has_ai:
646-
# ctx.command.checks = None # Let anyone use the command.
647-
pass
648-
649644
return ctx
650645

651646
async def update_perms(self, name: typing.Union[PermissionLevel, str],
@@ -691,7 +686,7 @@ async def on_message(self, message):
691686
if thread:
692687
snippet = snippet.format(recipient=thread.recipient)
693688
message.content = f'{prefix}reply {snippet}'
694-
689+
695690
ctx = await self.get_context(message)
696691
if ctx.command:
697692
return await self.invoke(ctx)
@@ -853,29 +848,29 @@ async def on_error(self, event_method, *args, **kwargs):
853848
logger.error(error('Ignoring exception in {}'.format(event_method)))
854849
logger.error(error('Unexpected exception:'), exc_info=sys.exc_info())
855850

856-
async def on_command_error(self, ctx, exception):
851+
async def on_command_error(self, context, exception):
857852
if isinstance(exception, commands.BadUnionArgument):
858853
msg = 'Could not find the specified ' + human_join([c.__name__ for c in exception.converters])
859-
await ctx.trigger_typing()
860-
await ctx.send(embed=discord.Embed(
861-
color=discord.Color.red(),
854+
await context.trigger_typing()
855+
await context.send(embed=discord.Embed(
856+
color=discord.Color.red(),
862857
description=msg
863858
))
864859

865860
elif isinstance(exception, commands.BadArgument):
866-
await ctx.trigger_typing()
867-
await ctx.send(embed=discord.Embed(
868-
color=discord.Color.red(),
861+
await context.trigger_typing()
862+
await context.send(embed=discord.Embed(
863+
color=discord.Color.red(),
869864
description=str(exception)
870865
))
871866
elif isinstance(exception, commands.CommandNotFound):
872867
logger.warning(error('CommandNotFound: ' + str(exception)))
873868
elif isinstance(exception, commands.MissingRequiredArgument):
874-
await ctx.send_help(ctx.command)
869+
await context.send_help(context.command)
875870
elif isinstance(exception, commands.CheckFailure):
876-
for check in ctx.command.checks:
877-
if not await check(ctx) and hasattr(check, 'fail_msg'):
878-
await ctx.send(embed=discord.Embed(
871+
for check in context.command.checks:
872+
if not await check(context) and hasattr(check, 'fail_msg'):
873+
await context.send(embed=discord.Embed(
879874
color=discord.Color.red(),
880875
description=check.fail_msg
881876
))

cogs/modmail.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def setup(self, ctx):
5353

5454
embed = discord.Embed(
5555
title='Friendly Reminder:',
56-
description='You may use the `config set log_channel_id '
56+
description=f'You may use the `{self.bot.prefix}config set log_channel_id '
5757
'<channel-id>` command to set up a custom log channel'
5858
', then you can delete the default '
5959
f'{log_channel.mention} channel.',
@@ -72,7 +72,7 @@ async def setup(self, ctx):
7272
'Consider setting permission groups to give access '
7373
'to roles or users the ability to use Modmail.\n'
7474
f'Type `{self.bot.prefix}permissions` for more info.')
75-
75+
7676
if not self.bot.config.get('permissions'):
7777
await self.bot.update_perms(PermissionLevel.REGULAR, -1)
7878
await self.bot.update_perms(PermissionLevel.OWNER, ctx.author.id)
@@ -278,7 +278,7 @@ async def notify(self, ctx, *, role: Union[discord.Role, str.lower, None] = None
278278
"""
279279
thread = ctx.thread
280280

281-
if role is None or role == 'me':
281+
if role is None:
282282
mention = ctx.author.mention
283283
elif isinstance(role, discord.Role):
284284
mention = role.mention
@@ -594,7 +594,6 @@ async def anonreply(self, ctx, *, msg: str = ''):
594594
async with ctx.typing():
595595
await ctx.thread.reply(ctx.message, anonymous=True)
596596

597-
598597
@commands.command()
599598
@checks.has_permissions(PermissionLevel.SUPPORTER)
600599
@checks.thread_only()

cogs/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async def plugin_remove(self, ctx, *, plugin_name: str):
180180
if not any(i.startswith(f'{username}/{repo}')
181181
for i in self.bot.config.plugins):
182182
# if there are no more of such repos, delete the folder
183-
def onerror(func, path, exc_info):
183+
def onerror(func, path, exc_info): # pylint: disable=W0613
184184
if not os.access(path, os.W_OK):
185185
# Is the error an access error?
186186
os.chmod(path, stat.S_IWUSR)

cogs/utility.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
from io import StringIO
99
from typing import Union
1010
from json import JSONDecodeError
11-
from pkg_resources import parse_version
1211
from textwrap import indent
1312

1413
from discord import Embed, Color, Activity, Role
1514
from discord.enums import ActivityType, Status
1615
from discord.ext import commands
1716

1817
from aiohttp import ClientResponseError
18+
from pkg_resources import parse_version
1919

2020
from core import checks
2121
from core.changelog import Changelog
@@ -57,7 +57,7 @@ async def format_cog_help(self, cog):
5757

5858
embed.add_field(name='Commands', value=format_)
5959

60-
continued = ' (Continued)' if len(embeds) > 0 else ''
60+
continued = ' (Continued)' if embeds else ''
6161
embed.set_author(name=cog.qualified_name + ' - Help' + continued,
6262
icon_url=bot.user.avatar_url)
6363

@@ -66,8 +66,8 @@ async def format_cog_help(self, cog):
6666
embeds.append(embed)
6767
return embeds
6868

69-
def process_help_msg(self, help: str):
70-
return help.format(prefix=self.clean_prefix)
69+
def process_help_msg(self, help_: str):
70+
return help_.format(prefix=self.clean_prefix)
7171

7272
async def send_bot_help(self, mapping):
7373
embeds = []
@@ -138,7 +138,7 @@ async def send_group_help(self, group):
138138
)
139139
await self.get_destination().send(embed=embed)
140140

141-
async def send_error_message(self, msg):
141+
async def send_error_message(self, msg): # pylint: disable=W0221
142142
logger.warning(error(f'CommandNotFound: {msg}'))
143143

144144
embed = Embed(
@@ -583,9 +583,9 @@ async def set_presence(self, *,
583583
presence = {'activity': (None, 'No activity has been set.'),
584584
'status': (None, 'No status has been set.')}
585585
if activity is not None:
586-
to = 'to ' if activity.type == ActivityType.listening else ''
586+
use_to = 'to ' if activity.type == ActivityType.listening else ''
587587
msg = f'Activity set to: {activity.type.name.capitalize()} '
588-
msg += f'{to}{activity.name}.'
588+
msg += f'{use_to}{activity.name}.'
589589
presence['activity'] = (activity, msg)
590590
if status is not None:
591591
msg = f'Status set to: {status.value}.'
@@ -1276,14 +1276,14 @@ async def oauth_whitelist(self, ctx, target: Union[User, Role]):
12761276

12771277
await self.bot.config.update()
12781278

1279-
em = Embed(color=self.bot.main_color)
1280-
em.title = 'Success'
1281-
em.description = (
1279+
embed = Embed(color=self.bot.main_color)
1280+
embed.title = 'Success'
1281+
embed.description = (
12821282
f"{'Un-w' if removed else 'W'}hitelisted "
12831283
f"{target.mention} to view logs."
12841284
)
12851285

1286-
await ctx.send(embed=em)
1286+
await ctx.send(embed=embed)
12871287

12881288
@oauth.command(name='show', aliases=['get', 'list', 'view'])
12891289
@checks.has_permissions(PermissionLevel.OWNER)

core/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ async def clean_data(self, key: str,
166166
time = await converter.convert(None, val)
167167
if time.arg:
168168
raise ValueError
169-
except BadArgument as e:
170-
raise InvalidConfigError(*e.args)
169+
except BadArgument as exc:
170+
raise InvalidConfigError(*exc.args)
171171
except Exception:
172172
raise InvalidConfigError(
173173
'Unrecognized time, please use ISO-8601 duration format '

core/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ def parse_image_url(url: str) -> str:
129129
def human_join(strings):
130130
if len(strings) <= 2:
131131
return ' or '.join(strings)
132-
else:
133-
return ', '.join(strings[:len(strings) - 1]) + ' or ' + strings[-1]
132+
return ', '.join(strings[:len(strings) - 1]) + ' or ' + strings[-1]
134133

135134

136135
def days(day: typing.Union[str, int]) -> str:

0 commit comments

Comments
 (0)