diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 0168a8bb..9105422c 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -8,7 +8,7 @@ jobs: auto-approve: runs-on: ubuntu-latest steps: - - uses: hmarr/auto-approve-action@v3 + - uses: hmarr/auto-approve-action@v4 if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'pre-commit-ci[bot]' || github.actor == 'github-actions[bot]' }} with: github-token: "${{ secrets.REVIEW_TOKEN }}" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 63c26e04..822aadff 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -33,7 +33,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: setup-python-dependencies: false languages: ${{ matrix.language }} @@ -45,7 +45,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -59,4 +59,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 4c4e676c..eff884be 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -9,7 +9,7 @@ jobs: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: 'Dependency Review' - uses: actions/dependency-review-action@v3 + uses: actions/dependency-review-action@v4 with: # Possible values: "critical", "high", "moderate", "low" # fail-on-severity: critical diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index 299711dc..0f7b9645 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -7,7 +7,7 @@ jobs: pr-labeler: runs-on: ubuntu-latest steps: - - uses: TimonVS/pr-labeler-action@v4 + - uses: TimonVS/pr-labeler-action@v5 with: configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value env: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7d51c54..bfaef13b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: hooks: - id: black - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort ci: diff --git a/adminutils/adminutils.py b/adminutils/adminutils.py index 110e8bb3..ea22bbe2 100644 --- a/adminutils/adminutils.py +++ b/adminutils/adminutils.py @@ -218,9 +218,11 @@ async def emoji_add(self, ctx, name: str, url: str, *roles: discord.Role): roles=roles, reason=get_audit_reason( ctx.author, - _("Restricted to roles: {}").format(", ".join(role.name for role in roles)) - if roles - else None, + ( + _("Restricted to roles: {}").format(", ".join(role.name for role in roles)) + if roles + else None + ), ), ) except discord.HTTPException as e: @@ -259,9 +261,11 @@ async def emote_steal( roles=roles, reason=get_audit_reason( ctx.author, - _("Restricted to roles: {}").format(", ".join(role.name for role in roles)) - if roles - else None, + ( + _("Restricted to roles: {}").format(", ".join(role.name for role in roles)) + if roles + else None + ), ), ) await ctx.tick() @@ -290,9 +294,11 @@ async def emoji_rename( roles=roles, reason=get_audit_reason( ctx.author, - _("Restricted to roles: ").format(", ".join(role.name for role in roles)) - if roles - else None, + ( + _("Restricted to roles: ").format(", ".join(role.name for role in roles)) + if roles + else None + ), ), ) except discord.Forbidden: diff --git a/datautils/datautils.py b/datautils/datautils.py index 1b2d91df..17923f46 100644 --- a/datautils/datautils.py +++ b/datautils/datautils.py @@ -263,35 +263,55 @@ async def sinfo(self, ctx, *, server: commands.GuildConverter = None): ) em.add_field( name=_("Verification level"), - value=_("None") - if server.verification_level == discord.VerificationLevel.none - else _("Low") - if server.verification_level == discord.VerificationLevel.low - else _("Medium") - if server.verification_level == discord.VerificationLevel.medium - else _("High") - if server.verification_level == discord.VerificationLevel.high - else _("Highest") - if server.verification_level == discord.VerificationLevel.extreme - else _("Unknown"), + value=( + _("None") + if server.verification_level == discord.VerificationLevel.none + else ( + _("Low") + if server.verification_level == discord.VerificationLevel.low + else ( + _("Medium") + if server.verification_level == discord.VerificationLevel.medium + else ( + _("High") + if server.verification_level == discord.VerificationLevel.high + else ( + _("Highest") + if server.verification_level == discord.VerificationLevel.extreme + else _("Unknown") + ) + ) + ) + ) + ), ) em.add_field( name=_("Explicit content filter"), - value=_("Don't scan any messages.") - if server.explicit_content_filter == discord.ContentFilter.disabled - else _("Scan messages from members without a role.") - if server.explicit_content_filter == discord.ContentFilter.no_role - else _("Scan messages sent by all members.") - if server.explicit_content_filter == discord.ContentFilter.all_members - else _("Unknown"), + value=( + _("Don't scan any messages.") + if server.explicit_content_filter == discord.ContentFilter.disabled + else ( + _("Scan messages from members without a role.") + if server.explicit_content_filter == discord.ContentFilter.no_role + else ( + _("Scan messages sent by all members.") + if server.explicit_content_filter == discord.ContentFilter.all_members + else _("Unknown") + ) + ) + ), ) em.add_field( name=_("Default notifications"), - value=_("All messages") - if server.default_notifications == discord.NotificationLevel.all_messages - else _("Only @mentions") - if server.default_notifications == discord.NotificationLevel.only_mentions - else _("Unknown"), + value=( + _("All messages") + if server.default_notifications == discord.NotificationLevel.all_messages + else ( + _("Only @mentions") + if server.default_notifications == discord.NotificationLevel.only_mentions + else _("Unknown") + ) + ), ) em.add_field(name=_("2FA admins"), value=bool_emojify(server.mfa_level)) if server.rules_channel: @@ -432,15 +452,19 @@ async def cinfo( changed_roles = sorted(channel.changed_roles, key=lambda r: r.position, reverse=True) em = discord.Embed( title=chat.escape(str(channel.name), formatting=True), - description=topic - if (topic := getattr(channel, "topic", None)) - else "\N{SPEECH BALLOON}: {} | \N{SPEAKER}: {} | \N{SATELLITE ANTENNA}: {}".format( - len(channel.text_channels), - len(channel.voice_channels), - len(channel.stage_channels), - ) - if isinstance(channel, discord.CategoryChannel) - else discord.Embed.Empty, + description=( + topic + if (topic := getattr(channel, "topic", None)) + else ( + "\N{SPEECH BALLOON}: {} | \N{SPEAKER}: {} | \N{SATELLITE ANTENNA}: {}".format( + len(channel.text_channels), + len(channel.voice_channels), + len(channel.stage_channels), + ) + if isinstance(channel, discord.CategoryChannel) + else discord.Embed.Empty + ) + ), color=await ctx.embed_color(), ) em.add_field(name=_("ID"), value=channel.id) diff --git a/datautils/menus.py b/datautils/menus.py index d78c9fba..d2157a4f 100644 --- a/datautils/menus.py +++ b/datautils/menus.py @@ -168,9 +168,9 @@ def __init__(self, entries): async def format_page(self, menu: ChannelsMenu, entries): e = discord.Embed( title="{}:".format(_(KNOWN_CHANNEL_TYPES[menu.channel_type][1])), - description=chat.box("\n".join(c.name for c in entries)) - if entries - else _("No channels"), + description=( + chat.box("\n".join(c.name for c in entries)) if entries else _("No channels") + ), ) e.set_footer( text=_("Page {}/{} • {}: {} • Total channels: {}").format( diff --git a/godvilledata/godvilledata.py b/godvilledata/godvilledata.py index ac0194df..369a8d21 100644 --- a/godvilledata/godvilledata.py +++ b/godvilledata/godvilledata.py @@ -90,9 +90,11 @@ async def godville(self, ctx, *, god: GodConverter): text_header = "{} и его {}\n{}\n".format( chat.bold(profile.god), chat.bold(profile.name), - chat.italics(chat.escape(profile.motto.strip(), formatting=True)) - if profile.motto - else chat.inline("Здесь ничего нет"), + ( + chat.italics(chat.escape(profile.motto.strip(), formatting=True)) + if profile.motto + else chat.inline("Здесь ничего нет") + ), ) if profile.arena_is_in_fight: text_header += "В сражении: {}\n".format(profile.fight_type_rus) @@ -207,9 +209,11 @@ async def godvillegame(self, ctx, *, godname: str): text_header = "{} and his {}\n{}\n".format( chat.bold(profile.god), chat.bold(profile.name), - chat.italics(chat.escape(profile.motto.strip(), formatting=True)) - if profile.motto - else chat.inline("Nothing here"), + ( + chat.italics(chat.escape(profile.motto.strip(), formatting=True)) + if profile.motto + else chat.inline("Nothing here") + ), ) if profile.arena_is_in_fight: text_header += "In fight: {}\n".format(profile.fight_type_rus) diff --git a/leveler/commands/lvladmin/debugging.py b/leveler/commands/lvladmin/debugging.py index 8e823ada..ad4cb614 100644 --- a/leveler/commands/lvladmin/debugging.py +++ b/leveler/commands/lvladmin/debugging.py @@ -50,9 +50,11 @@ async def debug_info(self, ctx): ("DB lock locked", self._db_lock.locked()), ( "DB lock queue", - "N/A" - if self._db_lock._waiters is None - else len(self._db_lock._waiters), + ( + "N/A" + if self._db_lock._waiters is None + else len(self._db_lock._waiters) + ), ), ("pymongo version", pymongoversion), ("motor version", motorversion), diff --git a/leveler/commands/top.py b/leveler/commands/top.py index f27caa0f..f00e118f 100644 --- a/leveler/commands/top.py +++ b/leveler/commands/top.py @@ -64,8 +64,8 @@ async def top( elif options.global_top and owner: is_level = True if await self.config.global_levels() else False title = "Global Exp Leaderboard for {}\n".format(self.bot.user.name) - async for userinfo in self.db.users.find({}).allow_disk_use(True).sort( - "total_exp", -1 + async for userinfo in ( + self.db.users.find({}).allow_disk_use(True).sort("total_exp", -1) ): pos += 1 if is_level: @@ -109,9 +109,11 @@ async def top( icon_url = self.bot.user.display_avatar elif options.rep: title = "Rep Leaderboard for {}\n".format(server.name) - async for userinfo in self.db.users.find( - {f"servers.{server.id}": {"$exists": True}} - ).allow_disk_use(True).sort("rep", -1): + async for userinfo in ( + self.db.users.find({f"servers.{server.id}": {"$exists": True}}) + .allow_disk_use(True) + .sort("rep", -1) + ): pos += 1 users.append( ( @@ -137,10 +139,15 @@ async def top( else: is_level = True title = "Exp Leaderboard for {}\n".format(server.name) - async for userinfo in self.db.users.find( - {f"servers.{server.id}": {"$exists": True}} - ).allow_disk_use(True).sort( - [(f"servers.{server.id}.level", -1), (f"servers.{server.id}.current_exp", -1)] + async for userinfo in ( + self.db.users.find({f"servers.{server.id}": {"$exists": True}}) + .allow_disk_use(True) + .sort( + [ + (f"servers.{server.id}.level", -1), + (f"servers.{server.id}.current_exp", -1), + ] + ) ): pos += 1 if str(user.id) == userinfo["user_id"]: diff --git a/leveler/exp.py b/leveler/exp.py index 6c1f842b..b94dc045 100644 --- a/leveler/exp.py +++ b/leveler/exp.py @@ -247,10 +247,10 @@ async def _handle_levelup(self, user, userinfo, server, channel): async def _find_server_rank(self, user, server): rank = 1 - async for userinfo in self.db.users.find( - {f"servers.{server.id}": {"$exists": True}} - ).allow_disk_use(True).sort( - [(f"servers.{server.id}.level", -1), (f"servers.{server.id}.current_exp", -1)] + async for userinfo in ( + self.db.users.find({f"servers.{server.id}": {"$exists": True}}) + .allow_disk_use(True) + .sort([(f"servers.{server.id}.level", -1), (f"servers.{server.id}.current_exp", -1)]) ): if userinfo["user_id"] == str(user.id): return rank @@ -258,9 +258,11 @@ async def _find_server_rank(self, user, server): async def _find_server_rep_rank(self, user, server): rank = 1 - async for userinfo in self.db.users.find( - {f"servers.{server.id}": {"$exists": True}} - ).allow_disk_use(True).sort("rep", -1): + async for userinfo in ( + self.db.users.find({f"servers.{server.id}": {"$exists": True}}) + .allow_disk_use(True) + .sort("rep", -1) + ): if userinfo.get("user_id") == str(user.id): return rank rank += 1 diff --git a/leveler/menus/top.py b/leveler/menus/top.py index 63cefd9a..bb80115f 100644 --- a/leveler/menus/top.py +++ b/leveler/menus/top.py @@ -128,9 +128,11 @@ def __init__( async def format_page(self, menu: TopMenu, entries): table = tabulate( entries, - headers=["#", self.board_type, "Level", "Username"] - if self.is_level - else ["#", self.board_type, "Username"], + headers=( + ["#", self.board_type, "Level", "Username"] + if self.is_level + else ["#", self.board_type, "Username"] + ), tablefmt="rst", ) table_width = len(table.splitlines()[0]) diff --git a/minecraftdata/minecraftdata.py b/minecraftdata/minecraftdata.py index 56e95f71..52367b3f 100644 --- a/minecraftdata/minecraftdata.py +++ b/minecraftdata/minecraftdata.py @@ -304,18 +304,20 @@ async def java(self, ctx, query_data: Optional[bool], server_ip: str): name=_("Players"), value="{0.players.online}/{0.players.max}\n{1}".format( status, - chat.box( - list( - chat.pagify( - await self.clear_mcformatting( - "\n".join([p.name for p in status.players.sample]) - ), - page_length=992, - ) - )[0] - ) - if status.players.sample - else "", + ( + chat.box( + list( + chat.pagify( + await self.clear_mcformatting( + "\n".join([p.name for p in status.players.sample]) + ), + page_length=992, + ) + )[0] + ) + if status.players.sample + else "" + ), ), ) embed.add_field( diff --git a/steamcommunity/steamcommunity.py b/steamcommunity/steamcommunity.py index 7026e189..c36b77e1 100644 --- a/steamcommunity/steamcommunity.py +++ b/steamcommunity/steamcommunity.py @@ -136,9 +136,11 @@ async def steamprofile(self, ctx, profile: SteamUser): title=profile.personaname, description=profile.personastate(), url=profile.profileurl, - timestamp=datetime.utcfromtimestamp(profile.lastlogoff) - if profile.lastlogoff - else discord.Embed.Empty, + timestamp=( + datetime.utcfromtimestamp(profile.lastlogoff) + if profile.lastlogoff + else discord.Embed.Empty + ), color=profile.personastatecolor, ) if profile.gameid: diff --git a/vocadb/vocadb.py b/vocadb/vocadb.py index 92646b0e..0a82febe 100644 --- a/vocadb/vocadb.py +++ b/vocadb/vocadb.py @@ -131,11 +131,13 @@ def _info_embed(self, colour, data: Dict[str, Any]) -> discord.Embed: @staticmethod def _lyrics_embed(colour, page: Dict[str, Any], data: Dict[str, Any]) -> discord.Embed: """Create an embed with the lyrics""" + title = [ x.get("value") for x in data.get("names") - if x.get("language") == LANGUAGE_MAP.get(page["cultureCode"]) + if x.get("language") == LANGUAGE_MAP.get(page.get("translationType")) ] + em = discord.Embed( title=title[0] if title else data.get("defaultName"), colour=colour, @@ -149,6 +151,7 @@ def _lyrics_embed(colour, page: Dict[str, Any], data: Dict[str, Any]) -> discord name="Source", value=f"[{page.get('source') or 'Source'}]({page['url']})", ) + return em @commands.command() @@ -156,7 +159,7 @@ def _lyrics_embed(colour, page: Dict[str, Any], data: Dict[str, Any]) -> discord @commands.cooldown(1, 5, commands.BucketType.user) async def vocadb(self, ctx: commands.Context, *, query: str): """Fetch Vocaloid song lyrics from VocaDB.net database""" - await ctx.trigger_typing() + await ctx.typing() data = await self._fetch_data(ctx, query) if type(data) == str: @@ -170,7 +173,7 @@ async def vocadb(self, ctx: commands.Context, *, query: str): embeds = [] for i, page in enumerate(data["lyrics"], start=1): - language = f"Language: {LANGUAGE_MAP.get(page.get('cultureCode', 'na'))}" + language = f"Version: {page.get('translationType', 'na')}" emb = self._lyrics_embed(await ctx.embed_colour(), page, data) emb.set_footer(text=f"{language} • Page {i} of {len(data['lyrics'])}") embeds.append(emb)