pincer.objects.guild.stage   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 29
dl 0
loc 84
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A StageInstance.from_id() 0 3 1
A StageInstance.modify() 0 21 1
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
4
from __future__ import annotations
5
6
from dataclasses import dataclass
7
from enum import IntEnum
8
from typing import TYPE_CHECKING, Optional
9
10
from ...utils.api_object import APIObject, ChannelProperty, GuildProperty
11
12
if TYPE_CHECKING:
13
    from ...client import Client
14
    from ...utils.snowflake import Snowflake
15
16
17
class PrivacyLevel(IntEnum):
18
    """Represents the level of publicity of a stage.
19
20
    Attributes
21
    ----------
22
    PUBLIC:
23
        The stage is public.
24
    GUILD_ONLY:
25
        The stage of for guild members only.
26
    """
27
28
    PUBLIC = 1
29
    GUILD_ONLY = 2
30
31
32
@dataclass(repr=False)
33
class StageInstance(APIObject, ChannelProperty, GuildProperty):
34
    """Represents a Stage Instance object
35
36
    Attributes
37
    ----------
38
    id: :class:`~pincer.utils.snowflake.Snowflake`
39
        Id of this Stage instance
40
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
41
        Guild id of the associated Stage channel
42
    channel_id: :class:`~pincer.utils.snowflake.Snowflake`
43
        Id of the associated Stage channel
44
    topic: :class:`str`
45
        Topic of the Stage instance (1-120 characters)
46
    privacy_level: :class:`~pincer.objects.guild.stage.PrivacyLevel`
47
        Privacy level of the Stage instance
48
    discoverable: :class:`bool`
49
        Is Stage Discovery enabled
50
    """
51
52
    id: Snowflake
53
    guild_id: Snowflake
54
    channel_id: Snowflake
55
    topic: str
56
    privacy_level: PrivacyLevel
57
    discoverable: bool
58
59
    @classmethod
60
    async def from_id(cls, client: Client, _id: int) -> StageInstance:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
61
        return client.http.get(f"stage-instance/{_id}")
62
63
    async def modify(
64
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
65
        topic: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
66
        privacy_level: Optional[PrivacyLevel] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
67
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
68
    ):
69
        """|coro|
70
        Updates fields of an existing Stage instance.
71
        Requires the user to be a moderator of the Stage channel.
72
73
        Parameters
74
        ----------
75
        topic : Optional[:class:`str`]
76
            The topic of the Stage instance (1-120 characters)
77
        privacy_level : Optional[:class:`~pincer.objects.guild.stage.PrivacyLevel`]
78
            The privacy level of the Stage instance
79
        reason : Optional[:class:`str`]
80
            The reason for the modification
81
        """
82
83
        await self._client.modify_stage(self.id, topic, privacy_level, reason)
84