Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
a3510377 committed Jan 16, 2024
1 parent 94920ef commit b8269a6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
15 changes: 8 additions & 7 deletions plugins/discord/client.pyi
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import discord
from _typeshed import Incomplete
from asyncio import AbstractEventLoop
from discord import ApplicationContext as ApplicationContext, Message as Message, Reaction as Reaction, TextChannel as TextChannel, User as User
from discord import ApplicationContext as ApplicationContext, DiscordException as DiscordException, Message as Message, Reaction as Reaction, TextChannel as TextChannel, User as User
from discord.ext import commands
from discord.ext.commands import CommandError as CommandError, Context as Context
from server import Plugin
from server.utils import FormatMessage
from typing import Optional

class Bot(commands.Bot):
plugin: Incomplete
log: Incomplete
console: Incomplete
config: Incomplete
server: Incomplete
def __init__(self, plugin: Plugin, loop: AbstractEventLoop | None = ...) -> None: ...
@property
def chat_channel(self) -> int | None: ...
async def get_or_fetch_channel(self, id: int) -> TextChannel | None: ...
_uptime: Incomplete
async def on_ready(self) -> None: ...
async def on_command(self, ctx: Context): ...
async def on_application_command(self, ctx: ApplicationContext): ...
async def on_command_error(self, ctx: Context, error: CommandError): ...
async def on_application_command_error(self, ctx: ApplicationContext, error: DiscordException): ...
async def get_reference_message(self, msg: Message) -> Optional[Message]: ...
def style_message(self, msg: Message) -> list[FormatMessage]: ...
async def on_message(self, msg: Message): ...
Expand All @@ -31,12 +38,6 @@ class BaseCog(discord.Cog):
def __init__(self, bot: Bot) -> None: ...

class BotCommand(BaseCog):
bot: Incomplete
log: Incomplete
plugin: Incomplete
config: Incomplete
server: Incomplete
def __init__(self, bot: Bot) -> None: ...
async def stats(self, ctx: ApplicationContext, *args): ...
async def online(self, ctx: ApplicationContext): ...

Expand Down
5 changes: 4 additions & 1 deletion plugins/discord/main.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ from server.utils import Config, FileEncode

class DiscordConfig(Config):
token: str
webhook: str
avatarApi: str
default_avatar: str
prefix: str
sync_enabled: bool
sync_channel: int
Expand All @@ -28,7 +31,7 @@ class Discord(Plugin, config=DiscordConfig):
def __init__(self, server: BaseServer) -> None: ...
def on_load(self) -> None: ...
def on_unload_before(self) -> None: ...
async def send(self, content: str, ctx: Context | None = ..., channel: TextChannel | None = ..., **kwargs) -> None: ...
async def send(self, content: str, ctx: Context | None = ..., channel: TextChannel | None = ..., player_name: str = ..., **kwargs) -> None: ...
async def on_server_start(self, ctx: Context): ...
async def on_server_startup(self, ctx: Context): ...
async def on_server_stop(self, ctx: Context): ...
Expand Down
2 changes: 2 additions & 0 deletions plugins/online.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Online(Plugin, config=OnlineConfig):
async def query(self, *, order: bool = ...) -> list[tuple[Context, set[str]]]: ...
@overload
async def query(self, *, order: bool = ...) -> dict[Context, set[str]]: ...
async def on_command_online(self): ...
async def query(self, *, order: bool = ...): ...
def on_unload(self) -> None: ...

def setup(server: BaseServer): ...
16 changes: 16 additions & 0 deletions plugins/tps.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from _typeshed import Incomplete
from server import BaseServer, Plugin
from server.utils import Config

minecraft_list_match: Incomplete
minecraft_GList_match: Incomplete

class OnlineConfig(Config):
online_enabled: bool
query_online_names: Incomplete
bungeecord_list: Incomplete

class Tps(Plugin, config=OnlineConfig):
def __init__(self, server: BaseServer) -> None: ...

def setup(server: BaseServer): ...
1 change: 1 addition & 0 deletions server/core/server.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class BaseServer(PluginMixin):
app: Incomplete
command_manager: Incomplete
log: Incomplete
console: Incomplete
config: Incomplete
plugins_dir: Incomplete
def __init__(self, config_type: str = ..., loop: AbstractEventLoop | None = ...) -> None: ...
Expand Down
7 changes: 3 additions & 4 deletions server/plugin.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from pathlib import Path
from types import ModuleType
from typing import Any, Callable, ClassVar, Optional, Type, TypeVar

T = TypeVar("T", bound="Plugin")
T = TypeVar('T', bound='Plugin')

class PluginMeta(type):
__plugin_name__: str
Expand All @@ -24,6 +24,7 @@ class Plugin(metaclass=PluginMeta):
loop: Incomplete
server_config: Incomplete
log: Incomplete
console: Incomplete
config: Incomplete
def __init__(self, server: BaseServer) -> None: ...
def _inject(self, server: BaseServer) -> T: ...
Expand All @@ -32,9 +33,7 @@ class Plugin(metaclass=PluginMeta):
def on_unload(self) -> None: ...
def on_unload_before(self) -> None: ...
@classmethod
def listener(
cls, name: str | CoroFuncT = ...
) -> Callable[[CoroFuncT], CoroFuncT]: ...
def listener(cls, name: str | CoroFuncT = ...) -> Callable[[CoroFuncT], CoroFuncT]: ...

class PluginMixin:
__plugins: Incomplete
Expand Down
2 changes: 1 addition & 1 deletion server/utils/format.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mark_data: Incomplete

class FormatMessage:
original_msgs: Incomplete
def __init__(self, *msgs: Union[str, 'FormatMessage'], no_mark: bool = ...) -> None: ...
def __init__(self, *msgs: Union[str, 'FormatMessage'], no_style: bool = ..., no_mark: bool = ...) -> None: ...
def json(self): ...

def split_desc_text(msg: str) -> tuple[str, str]: ...
Expand Down

0 comments on commit b8269a6

Please sign in to comment.