Skip to content

Commit

Permalink
Remove pin archive cog
Browse files Browse the repository at this point in the history
- Also, publically export certain typing aliases because why not
  • Loading branch information
Sachaa-Thanasius committed Nov 16, 2023
1 parent ca9a7f3 commit 36c6a3b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 406 deletions.
2 changes: 1 addition & 1 deletion core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

import discord
from discord import app_commands
from discord.app_commands.commands import Check as AppCheckFunc
from discord.ext import commands

from .errors import CheckAnyFailure, GuildIsBlocked, NotAdmin, NotInBotVoiceChannel, NotOwnerOrFriend, UserIsBlocked


if TYPE_CHECKING:
from discord.app_commands.commands import Check as AppCheckFunc
from discord.ext.commands._types import Check # type: ignore [reportMissingTypeStubs]

from .context import Context, GuildContext
Expand Down
12 changes: 6 additions & 6 deletions core/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
from asyncpg.pool import PoolConnectionProxy


UserObject: TypeAlias = discord.abc.User | discord.Object | tuple[int, bool]
GuildObject: TypeAlias = discord.Guild | discord.Object | tuple[int, bool]


__all__ = ("Connection_alias", "Pool_alias", "pool_init", "upsert_users", "upsert_guilds")

if TYPE_CHECKING:
Connection_alias: TypeAlias = Connection[Record] | PoolConnectionProxy[Record]
Pool_alias: TypeAlias = Pool[Record]
else:
Connection_alias: TypeAlias = Connection | PoolConnectionProxy
Pool_alias: TypeAlias = Pool

UserObject: TypeAlias = discord.abc.User | discord.Object | tuple[int, bool]
GuildObject: TypeAlias = discord.Guild | discord.Object | tuple[int, bool]


__all__ = ("pool_init", "upsert_users", "upsert_guilds")


async def pool_init(connection: Connection_alias) -> None:
"""Sets up codecs for Postgres connection."""
Expand Down
12 changes: 4 additions & 8 deletions core/utils/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
from __future__ import annotations

import asyncio
import logging
from abc import ABC, abstractmethod
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Generic, TypeVar

import discord
from discord.utils import maybe_coroutine


if TYPE_CHECKING:
Expand All @@ -25,8 +23,6 @@

__all__ = ("QuitButton", "OwnedView", "PageSeekModal", "PaginatedEmbedView", "PaginatedSelectView")

LOGGER = logging.getLogger(__name__)


class QuitButton(discord.ui.Button[discord.ui.View]):
"""A button subclass that deletes original message it's attached to after a short delay.
Expand Down Expand Up @@ -231,14 +227,14 @@ async def get_first_page(self) -> discord.Embed:

temp = self.page_index
self.page_index = 0
embed = await maybe_coroutine(self.format_page)
embed = await discord.utils.maybe_coroutine(self.format_page)
self.page_index = temp
return embed

async def update_page(self, interaction: discord.Interaction) -> None:
"""Update and display the view for the given page."""

embed_page = await maybe_coroutine(self.format_page)
embed_page = await discord.utils.maybe_coroutine(self.format_page)
self.disable_page_buttons()
await interaction.response.edit_message(embed=embed_page, view=self)

Expand Down Expand Up @@ -380,14 +376,14 @@ async def get_first_page(self) -> discord.Embed:

temp = self.page_index
self.page_index = 0
embed = await maybe_coroutine(self.format_page)
embed = await discord.utils.maybe_coroutine(self.format_page)
self.page_index = temp
return embed

async def update_page(self, interaction: discord.Interaction) -> None:
"""Update and display the view for the given page."""

embed_page = await maybe_coroutine(self.format_page)
embed_page = await discord.utils.maybe_coroutine(self.format_page)
self.disable_page_buttons()
await interaction.response.edit_message(embed=embed_page, view=self)

Expand Down
11 changes: 7 additions & 4 deletions core/wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
from __future__ import annotations

from collections.abc import AsyncIterable, Iterable
from typing import TypeAlias

import discord
import wavelink
from wavelink.ext import spotify # type: ignore [reportMissingTypeStubs]


__all__ = ("SkippableQueue", "SkippablePlayer")
__all__ = ("AnyTrack", "AnyTrackIterator", "AnyTrackIterable", "SkippableQueue", "SkippablePlayer")

AnyTrack = wavelink.Playable | spotify.SpotifyTrack
AnyTrackIterator = list[wavelink.Playable] | list[spotify.SpotifyTrack] | spotify.SpotifyAsyncIterator
AnyTrackIterable = Iterable[wavelink.Playable] | Iterable[spotify.SpotifyTrack] | AsyncIterable[spotify.SpotifyTrack]
AnyTrack: TypeAlias = wavelink.Playable | spotify.SpotifyTrack
AnyTrackIterator: TypeAlias = list[wavelink.Playable] | list[spotify.SpotifyTrack] | spotify.SpotifyAsyncIterator
AnyTrackIterable: TypeAlias = (
Iterable[wavelink.Playable] | Iterable[spotify.SpotifyTrack] | AsyncIterable[spotify.SpotifyTrack]
)


class SkippableQueue(wavelink.Queue):
Expand Down
Loading

0 comments on commit 36c6a3b

Please sign in to comment.