Skip to content

Commit

Permalink
Black update and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
laggron42 committed Nov 17, 2020
1 parent c789464 commit d8c49de
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
python -m pip install Red-DiscordBot
python -m pip install git+https://github.com/retke/laggron-utils
python -m pip install python-dateutil==2.8.1
python -m pip install black==19.10b0
python -m pip install black==20.8b1
- name: Checking style
run: |
make stylecheck
Expand Down
4 changes: 1 addition & 3 deletions codmw/api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ class Client:
authentification, which can require a captcha after some requests.
"""

def __init__(
self, version: str, game: str, username: str, password: str, cookies: dict = {},
):
def __init__(self, version: str, game: str, username: str, password: str, cookies: dict = {}):
self.game = game
self.credentials = {"username": username, "password": password}
cookie_jar = aiohttp.CookieJar()
Expand Down
46 changes: 16 additions & 30 deletions codmw/codmw.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async def _check_for_tokens(self, ctx: commands.Context):
).format(prefix=ctx.clean_prefix)
)
return False
self.cod_client = Client("v1", "mw", tokens["username"], tokens["password"],)
self.cod_client = Client("v1", "mw", tokens["username"], tokens["password"])

def _format_timedelta(self, time: timedelta):
"""Format a timedelta object into a string"""
Expand Down Expand Up @@ -301,20 +301,14 @@ async def cod_mw(self, ctx: commands.Context, platform: str, username: str):
)
time = timedelta(seconds=game_data["timePlayedTotal"])
time -= timedelta(seconds=time.seconds % 60)
embed.add_field(
name=_("Time played"), value=self._format_timedelta(time), inline=False,
)
embed.add_field(name=_("Time played"), value=self._format_timedelta(time), inline=False)
games_played = round(game_data["gamesPlayed"])
embed.add_field(
name=_("Games played"), value=f"{games_played:,}", inline=False,
)
embed.add_field(name=_("Games played"), value=f"{games_played:,}", inline=False)
wins = round(game_data["wins"])
losses = round(game_data["losses"])
embed.add_field(name=_("Wins/Losses"), value=f"{wins:,}/{losses:,}", inline=True)
embed.add_field(
name=_("Wins/Losses"), value=f"{wins:,}/{losses:,}", inline=True,
)
embed.add_field(
name=_("Winrate"), value=f"{round((wins/games_played)*100, 1)}%", inline=True,
name=_("Winrate"), value=f"{round((wins/games_played)*100, 1)}%", inline=True
)
embed.add_field(
name=_("Win streak"),
Expand Down Expand Up @@ -356,13 +350,13 @@ async def cod_mw(self, ctx: commands.Context, platform: str, username: str):
inline=True,
)
embed.add_field(
name=_("Accuracy"), value=f"{round(game_data['accuracy']*100, 2)}%", inline=True,
name=_("Accuracy"), value=f"{round(game_data['accuracy']*100, 2)}%", inline=True
)
embed.add_field(
name=_("Score per game"), value=f"{round(game_data['scorePerGame']):,}", inline=True,
name=_("Score per game"), value=f"{round(game_data['scorePerGame']):,}", inline=True
)
embed.add_field(
name=_("Best score per minute"), value=f"{round(game_data['bestSPM']):,}", inline=True,
name=_("Best score per minute"), value=f"{round(game_data['bestSPM']):,}", inline=True
)
if favorite_gamemode:
embed.set_footer(text=f"Favorite gamemode: {self._get_gamemode(favorite_gamemode)}")
Expand Down Expand Up @@ -400,33 +394,25 @@ async def cod_wz(self, ctx: commands.Context, platform: str, username: str):
inline=False,
)
games_played = round(game_data["gamesPlayed"])
embed.add_field(
name=_("Games played"), value=f"{games_played:,}", inline=True,
)
embed.add_field(name=_("Games played"), value=f"{games_played:,}", inline=True)
wins = round(game_data["wins"])
embed.add_field(name=_("Wins"), value=f"{wins:,}", inline=True)
embed.add_field(
name=_("Wins"), value=f"{wins:,}", inline=True,
)
embed.add_field(
name=_("Winrate"), value=f"{round((wins/games_played)*100, 1)}%", inline=True,
name=_("Winrate"), value=f"{round((wins/games_played)*100, 1)}%", inline=True
)
embed.add_field(
name=_("Kills/Deaths"),
value=f"{round(game_data['kills']):,}/{round(game_data['deaths']):,}",
inline=True,
)
embed.add_field(
name=_("K/D Ratio"), value=f"{round(game_data['kdRatio'], 3):,}", inline=True,
)
embed.add_field(
name=_("Contracts"), value=f"{round(game_data['contracts']):,}", inline=True,
)
embed.add_field(
name=_("Revives"), value=f"{round(game_data['revives']):,}", inline=True,
name=_("K/D Ratio"), value=f"{round(game_data['kdRatio'], 3):,}", inline=True
)
embed.add_field(
name=_("Downs"), value=f"{round(game_data['downs']):,}", inline=True,
name=_("Contracts"), value=f"{round(game_data['contracts']):,}", inline=True
)
embed.add_field(name=_("Revives"), value=f"{round(game_data['revives']):,}", inline=True)
embed.add_field(name=_("Downs"), value=f"{round(game_data['downs']):,}", inline=True)
embed.add_field(
name=_("Number of tops"),
value=_("Top 25: {top_25}\n" "Top 10: {top_10}\n" "Top 5: {top_5}").format(
Expand Down Expand Up @@ -470,7 +456,7 @@ async def cod_recent(self, ctx: commands.Context, platform: str, username: str):
time = pretty_date(datetime.fromtimestamp(match["utcEndSeconds"]).replace(second=0))
map = match["map"].split("_")[1].title()
title = _("**{result}** a game of **{gamemode}** on **{map}** {time}").format(
result=result, gamemode=gamemode, map=map, time=time,
result=result, gamemode=gamemode, map=map, time=time
)
duration = self._format_timedelta(timedelta(seconds=match["duration"] / 1000))
player_stats = match["playerStats"]
Expand Down
2 changes: 1 addition & 1 deletion roleinvite/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CannotGetInvites(Exception):

class CannotAddRole(Exception):
"""
The bot isn't allowed to give a role.
The bot isn't allowed to give a role.
The role hierarchy was modified or a 3rd party module added the role without check.
"""

Expand Down
11 changes: 9 additions & 2 deletions warnsystem/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ async def warn_member(member: Union[discord.Member, UnavailableMember], audit_re
else:
modlog_message = None
data = await self._create_case(
guild, member, author, level, date, reason, time, roles, modlog_message,
guild, member, author, level, date, reason, time, roles, modlog_message
)
# start timer if there is a temporary warning
if time and (level == 2 or level == 5):
Expand Down Expand Up @@ -1306,7 +1306,14 @@ async def automod_process_regex(self, message: discord.Message):
reason = regex["reason"].format(
guild=guild, channel=message.channel, member=member
)
fail = await self.warn(guild, [member], guild.me, level, reason, time,)
fail = await self.warn(
guild,
[member],
guild.me,
level,
reason,
time,
)
if fail:
log.warn(
f"[Guild {guild.id}] Regex automod warn on member {member} ({member.id})\n"
Expand Down
8 changes: 4 additions & 4 deletions warnsystem/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ async def automod_regex_show(self, ctx: commands.Context, name: str):
embed = discord.Embed(title=_("Regex trigger: {name}").format(name=name))
embed.description = _("Regex trigger details.")
embed.add_field(
name=_("Regular expression"), value=box(automod_regex["regex"].pattern), inline=False,
name=_("Regular expression"), value=box(automod_regex["regex"].pattern), inline=False
)
embed.add_field(
name=_("Warning"),
Expand All @@ -252,7 +252,7 @@ async def automod_warn(self, ctx: commands.Context):
"""
Trigger actions when a member get x warnings within the specified time.
For example, if a member gets 3 warnings within a day, you can make the bot automatically
For example, if a member gets 3 warnings within a day, you can make the bot automatically \
set him a level 3 warning with the given reason.
It is also possible to only include warnings given by the bot when counting.
"""
Expand Down Expand Up @@ -296,7 +296,7 @@ async def automod_warn_add(self, ctx: commands.Context):
else:
await ctx.send(_("Level must be between 1 and 5."))
warn_reason = await self._ask_for_value(
ctx, msg, embed, _("What's the reason of the automod's warning?"), optional=True,
ctx, msg, embed, _("What's the reason of the automod's warning?"), optional=True
)
time: timedelta = await self._ask_for_value(
ctx,
Expand Down Expand Up @@ -458,7 +458,7 @@ async def automod_warn_list(self, ctx: commands.Context):
text = ""
for index, data in enumerate(autowarns):
text += _("{index}. level {level} warn (need {number} warns to trigger)\n").format(
index=index, level=data["warn"]["level"], number=data["number"],
index=index, level=data["warn"]["level"], number=data["number"]
)
text = list(pagify(text, page_length=1900))
pages = []
Expand Down
2 changes: 1 addition & 1 deletion warnsystem/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def format_channels(channels: list):
return text

text = _("Successfully checked all channels, {len}/{total} were edited.\n\n").format(
len=count - len(perms_failed) - len(other_failed), total=count,
len=count - len(perms_failed) - len(other_failed), total=count
)
if perms_failed:
text += _(
Expand Down

0 comments on commit d8c49de

Please sign in to comment.