Passed
Pull Request — main (#167)
by
unknown
01:38
created

MessageContext.send()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nop 2
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
from __future__ import annotations
4
5
from dataclasses import dataclass
6
from typing import Optional, Union, TYPE_CHECKING
7
8
9
if TYPE_CHECKING:
10
    from ...utils.convert_message import MessageConvertable
11
    from .user_message import UserMessage
12
    from ..app import ClientCommandStructure, Interaction
13
    from ..guild.member import GuildMember
14
    from ..user import User
15
    from ...utils.snowflake import Snowflake
16
17
18
@dataclass
19
class MessageContext:
20
    """
21
    Represents the context of a message interaction.
22
23
    :param author:
24
        The user whom invoked the interaction.
25
26
    :param command:
27
        The local command object for the command to whom this context
28
        belongs.
29
30
    interaction :class:`~pincer.objects.app.interaction.Interaction`
31
        The interaction this command belongs to.
32
33
    :param guild_id:
34
        The ID of the guild the interaction was invoked in.
35
        Can be None if it wasn't invoked in a guild.
36
37
    :param channel_id:
38
        The ID of the channel the interaction was invoked in.
39
        Can be None if it wasn't invoked in a channel.
40
    """
41
    author: Union[GuildMember, User]
0 ignored issues
show
introduced by
The variable GuildMember does not seem to be defined in case TYPE_CHECKING on line 9 is False. Are you sure this can never be the case?
Loading history...
introduced by
The variable User does not seem to be defined in case TYPE_CHECKING on line 9 is False. Are you sure this can never be the case?
Loading history...
42
    command: ClientCommandStructure
0 ignored issues
show
introduced by
The variable ClientCommandStructure does not seem to be defined in case TYPE_CHECKING on line 9 is False. Are you sure this can never be the case?
Loading history...
43
    interaction: Interaction
0 ignored issues
show
introduced by
The variable Interaction does not seem to be defined in case TYPE_CHECKING on line 9 is False. Are you sure this can never be the case?
Loading history...
44
45
    guild_id: Optional[Snowflake] = None
0 ignored issues
show
introduced by
The variable Snowflake does not seem to be defined in case TYPE_CHECKING on line 9 is False. Are you sure this can never be the case?
Loading history...
46
    channel_id: Optional[Snowflake] = None
47
48
    async def send(self, message: MessageConvertable):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
49
        if self.interaction.has_replied:
50
            await self.interaction.followup(message)
51
        else:
52
            await self.interaction.reply(message)
53