Skip to content

Commit

Permalink
fix(lint): reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sn1F3rt committed Dec 15, 2024
1 parent 7248892 commit 425e74b
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 51 deletions.
16 changes: 9 additions & 7 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
from __future__ import annotations

from typing import Any

import logging
from datetime import datetime
from itertools import cycle
from typing import Any

import topgg
import aiohttp
import aiomysql
import discord
import topgg
import aiomysql
import wavelink
from discord.app_commands import CommandTree
from discord.ext import commands, tasks
from discord.ext import tasks, commands
from discord.ext.ipc import Server
from discord.app_commands import CommandTree

import config
from utils.db import (
add_guild,
guild_exists,
is_blacklisted_guild,
is_blacklisted_user,
is_blacklisted_guild,
)

import config


class FumeTree(CommandTree):
async def interaction_check(self, interaction: discord.Interaction) -> bool:
Expand Down
7 changes: 5 additions & 2 deletions cogs/__error__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import random
import string
import traceback
from typing import TYPE_CHECKING

import discord
from discord import app_commands
Expand Down Expand Up @@ -95,7 +96,9 @@ async def app_command_error(
await ctx.edit_original_response(content=message, view=None)

except (discord.NotFound, discord.errors.NotFound):
await ctx.followup.send(content=message, ephemeral=True, view=None)
await ctx.followup.send(
content=message, ephemeral=True, view=None
)
else:
# noinspection PyUnresolvedReferences
await ctx.response.send_message(
Expand Down
18 changes: 12 additions & 6 deletions cogs/__eval__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import io
import asyncio
import inspect
import io
import subprocess
import textwrap
import traceback
import subprocess
from contextlib import redirect_stdout
from typing import TYPE_CHECKING

import discord
from discord import app_commands
from discord.ext import commands

from config import COMMUNITY_GUILD_ID
from utils.modals import EvalModal, ExecModal

from config import COMMUNITY_GUILD_ID

if TYPE_CHECKING:
from bot import FumeTune

Expand Down Expand Up @@ -130,7 +132,9 @@ def _paginate(text: str):
content=f"```py\n{page}\n```"
)
else:
await modal.interaction.edit_original_response(content="\U00002705")
await modal.interaction.edit_original_response(
content="\U00002705"
)

else:
try:
Expand Down Expand Up @@ -177,7 +181,9 @@ async def _exec(self, ctx: discord.Interaction):
timeout=300,
)

stdout_value = process.stdout.decode("utf-8") + process.stderr.decode("utf-8")
stdout_value = process.stdout.decode("utf-8") + process.stderr.decode(
"utf-8"
)
stdout_value = "\n".join(stdout_value.split("\n")[-25:])

await modal.interaction.edit_original_response(
Expand Down
6 changes: 4 additions & 2 deletions cogs/__topgg__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING

from discord.ext import commands, tasks
from discord.ext import tasks, commands

if TYPE_CHECKING:
from bot import FumeTune
Expand All @@ -18,7 +18,9 @@ async def _update_stats(self):
await self.bot.topggpy.post_guild_count(
guild_count=len(self.bot.guilds), shard_count=len(self.bot.shards)
)
self.bot.log.info(f"Posted server count ({self.bot.topggpy.guild_count})")
self.bot.log.info(
f"Posted server count ({self.bot.topggpy.guild_count})"
)

except Exception as e:
self.bot.log.error(f"Failed to post server count", exc_info=e)
Expand Down
7 changes: 4 additions & 3 deletions cogs/filters.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from __future__ import annotations

import collections
from typing import TYPE_CHECKING, cast

import collections

import discord
import wavelink
from discord import app_commands, ui
from discord import ui, app_commands
from discord.ext import commands

from utils.cd import cooldown_level_0
from utils.checks import initial_checks
from utils.helpers import is_privileged
from utils.modals import FilterModal
from utils.player import Player
from utils.helpers import is_privileged

if TYPE_CHECKING:
from bot import FumeTune
Expand Down
7 changes: 5 additions & 2 deletions cogs/general.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import math
from datetime import datetime
from typing import TYPE_CHECKING

import discord
from discord import app_commands
Expand Down Expand Up @@ -129,7 +130,9 @@ async def _review(self, ctx: discord.Interaction):

view = discord.ui.View()
view.add_item(
discord.ui.Button(label="Review", url="https://fumes.top/fumetune/review")
discord.ui.Button(
label="Review", url="https://fumes.top/fumetune/review"
)
)

await ctx.edit_original_response(
Expand Down
48 changes: 33 additions & 15 deletions cogs/music.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Optional, cast

import json
import random
import string
from typing import TYPE_CHECKING, Optional, cast

import discord
import wavelink
Expand All @@ -12,13 +13,13 @@
from discord.ext.menus.views import ViewMenuPages

from utils.cd import cooldown_level_0
from utils.tools import parse_duration
from utils.views import TrackConfirm, PlaylistConfirm
from utils.checks import initial_checks
from utils.helpers import is_privileged, required_votes
from utils.paginators import QueuePaginatorSource
from utils.player import Player
from utils.helpers import is_privileged, required_votes
from utils.selects import TrackSelect
from utils.tools import parse_duration
from utils.views import PlaylistConfirm, TrackConfirm
from utils.paginators import QueuePaginatorSource

if TYPE_CHECKING:
from bot import FumeTune
Expand Down Expand Up @@ -76,7 +77,9 @@ async def on_wavelink_track_exception(
await self.bot.webhook.send(embed=embed)

@commands.Cog.listener()
async def on_wavelink_track_stuck(self, payload: wavelink.TrackStuckEventPayload):
async def on_wavelink_track_stuck(
self, payload: wavelink.TrackStuckEventPayload
):
player: Player = cast(Player, payload.player)

if not player:
Expand Down Expand Up @@ -311,7 +314,9 @@ async def _search(self, ctx: discord.Interaction, query: str):
embed.add_field(
name="Name",
value=(
f"**[{tracks.name}]({tracks.url})**" if tracks.url else tracks.name
f"**[{tracks.name}]({tracks.url})**"
if tracks.url
else tracks.name
),
)

Expand Down Expand Up @@ -348,7 +353,9 @@ async def _search(self, ctx: discord.Interaction, query: str):
f"({parse_duration(track.length)})\n\n"
)

options.append(discord.SelectOption(label=str(index), value=str(index)))
options.append(
discord.SelectOption(label=str(index), value=str(index))
)

embed.description += (
"Select the song number within **a minute** to play it, "
Expand Down Expand Up @@ -494,7 +501,9 @@ async def _resume(self, ctx: discord.Interaction):
)

if not player.paused:
return await ctx.edit_original_response(content="The player is not paused.")
return await ctx.edit_original_response(
content="The player is not paused."
)

if is_privileged(ctx):
player.resume_votes.clear()
Expand Down Expand Up @@ -623,7 +632,8 @@ async def _replay(self, ctx: discord.Interaction):

if not is_privileged(ctx):
return await ctx.edit_original_response(
content="Only the DJ or admins may set the " "loop state of the player."
content="Only the DJ or admins may set the "
"loop state of the player."
)

await player.seek()
Expand Down Expand Up @@ -763,7 +773,9 @@ async def _remove(self, ctx: discord.Interaction, position: int):

player.queue.delete(position - 1)

return await ctx.edit_original_response(content=f"That song has been removed!")
return await ctx.edit_original_response(
content=f"That song has been removed!"
)

@app_commands.command(name="flush")
@app_commands.check(initial_checks)
Expand All @@ -789,7 +801,9 @@ async def _flush(self, ctx: discord.Interaction):
if is_privileged(ctx):
player.queue.clear()

return await ctx.edit_original_response(content="Queue has been flushed!")
return await ctx.edit_original_response(
content="Queue has been flushed!"
)

else:
return await ctx.edit_original_response(
Expand Down Expand Up @@ -821,7 +835,9 @@ async def _shuffle(self, ctx: discord.Interaction):
player.shuffle_votes.clear()
player.queue.shuffle()

return await ctx.edit_original_response(content="Queue has been shuffled!")
return await ctx.edit_original_response(
content="Queue has been shuffled!"
)

required = required_votes(ctx)
player.shuffle_votes.add(ctx.user)
Expand Down Expand Up @@ -857,7 +873,8 @@ async def _loop(self, ctx: discord.Interaction):

if not is_privileged(ctx):
return await ctx.edit_original_response(
content="Only the DJ or admins may set the " "loop state of the player."
content="Only the DJ or admins may set the "
"loop state of the player."
)

if not player.loop:
Expand Down Expand Up @@ -886,7 +903,8 @@ async def _loop_queue(self, ctx: discord.Interaction):

if not is_privileged(ctx):
return await ctx.edit_original_response(
content="Only the DJ or admins may set the " "loop state of the player."
content="Only the DJ or admins may set the "
"loop state of the player."
)

if len(player.queue) == 0:
Expand Down
5 changes: 3 additions & 2 deletions cogs/utility.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from __future__ import annotations

import textwrap
from typing import TYPE_CHECKING, Optional

import textwrap

import discord
from azapi import AZlyrics
from discord import app_commands
from discord.ext import commands
from discord.ext.menus.views import ViewMenuPages

from utils.cd import cooldown_level_0, cooldown_level_1
from utils.paginators import LyricsPaginatorSource
from utils.tools import parse_duration
from utils.paginators import LyricsPaginatorSource

if TYPE_CHECKING:
from bot import FumeTune
Expand Down
9 changes: 5 additions & 4 deletions launcher.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from __future__ import annotations

import sys
import asyncio
import contextlib
import logging
import sys
import contextlib
from datetime import datetime

import aiomysql
import click
import discord
import pymysql
import aiomysql

import config
from bot import FumeTune

import config

try:
# noinspection PyUnresolvedReferences
import uvloop
Expand Down
2 changes: 1 addition & 1 deletion utils/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import discord
from discord import app_commands

from .helpers import is_privileged
from .player import Player
from .helpers import is_privileged


def initial_checks(ctx: discord.Interaction) -> bool:
Expand Down
4 changes: 3 additions & 1 deletion utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ async def guild_exists(pool: aiomysql.Pool, guild_id: int):
async def add_guild(pool: aiomysql.Pool, guild_id: int):
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("insert into guilds (GUILD_ID) values (%s);", (guild_id,))
await cur.execute(
"insert into guilds (GUILD_ID) values (%s);", (guild_id,)
)


async def is_premium_user(pool: aiomysql.Pool, user_id: int):
Expand Down
3 changes: 2 additions & 1 deletion utils/helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

import math
from typing import cast

import math

import discord

from .player import Player
Expand Down
Loading

0 comments on commit 425e74b

Please sign in to comment.