Completed
Push — main ( 3a3ea0...93fa25 )
by Yohann
23s queued 12s
created

pincer.objects.guild.webhook   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 31
dl 0
loc 103
rs 10
c 0
b 0
f 0
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 Optional, TYPE_CHECKING
9
10
from ..guild import Guild
11
from ..guild.channel import Channel
12
from ..user import User
13
from ...utils.api_object import APIObject
14
from ...utils.snowflake import Snowflake
15
from ...utils.types import MISSING
16
17
if TYPE_CHECKING:
18
    from ...utils import APINullable
19
20
21
class WebhookType(IntEnum):
22
    """
23
    Represents the type of a webhook.
24
25
    :param INCOMING:
26
        Incoming Webhooks can post messages to channels with a
27
        generated token.
28
29
    :param CHANNEL_FOLLOWER:
30
        Channel Follower Webhooks are internal webhooks used with
31
        Channel Following to post new messages into channels.
32
33
    :param APPLICATION:
34
        Application webhooks are webhooks used with Interactions
35
    """
36
    INCOMING = 1
37
    CHANNEL_FOLLOWER = 2
38
    APPLICATION = 3
39
40
41
@dataclass
0 ignored issues
show
best-practice introduced by
Too many instance attributes (12/7)
Loading history...
42
class Webhook(APIObject):
43
    """
44
    Represents a Discord channel webhook.
45
46
    :param id:
47
        the id of the webhook
48
49
    :param type:
50
        the type of the webhook
51
52
    :param channel_id:
53
        the channel id this webhook is for, if any
54
55
    :param name:
56
        the default name of the webhook
57
58
    :param avatar:
59
        the default user avatar hash of the webhook
60
61
    :param application_id:
62
        the bot/OAuth2 application that created this webhook
63
64
    :param user:
65
        the user this webhook was created by
66
        (not returned when getting a webhook with its token)
67
68
    :param token:
69
        the secure token of the webhook
70
        (returned for Incoming Webhooks)
71
72
    :param source_guild:
73
        the guild of the channel that this webhook is following
74
        (returned for Channel Follower Webhooks)
75
76
    :param source_channel:
77
        the channel that this webhook is following
78
        (returned for Channel Follower Webhooks)
79
80
    :param url:
81
        the url used for executing the webhook
82
        (returned by the webhooks OAuth2 flow)
83
84
    :param guild_id:
85
        the guild id this webhook is for, if any
86
    """
87
88
    id: Snowflake
89
    type: WebhookType
90
91
    channel_id: Optional[Snowflake] = None
92
    name: Optional[str] = None
93
    avatar: Optional[str] = None
94
    application_id: Optional[Snowflake] = None
95
96
    user: APINullable[User] = MISSING
0 ignored issues
show
introduced by
The variable APINullable does not seem to be defined in case TYPE_CHECKING on line 17 is False. Are you sure this can never be the case?
Loading history...
97
    token: APINullable[str] = MISSING
98
    source_guild: APINullable[Guild] = MISSING
99
    source_channel: APINullable[Channel] = MISSING
100
    url: APINullable[str] = MISSING
101
102
    guild_id: APINullable[Optional[Snowflake]] = MISSING
103