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

pincer.objects.guild.audit_log   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 192
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 89
dl 0
loc 192
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 Any, Optional, List, TYPE_CHECKING
9
10
from ...utils.api_object import APIObject
11
from ...utils.types import MISSING
12
13
if TYPE_CHECKING:
14
    from ..guild.channel import Channel
15
    from ..user.integration import Integration
16
    from ..user import User
17
    from ..guild.webhook import Webhook
18
    from ...utils import APINullable, Snowflake
19
20
21
class AuditLogEvent(IntEnum):
22
    """
23
    Audit log action type.
24
    This represents the action which got performed,
25
    and logged.
26
    """
27
    GUILD_UPDATE = 1
28
    CHANNEL_CREATE = 10
29
    CHANNEL_UPDATE = 11
30
    CHANNEL_DELETE = 12
31
    CHANNEL_OVERWRITE_CREATE = 13
32
    CHANNEL_OVERWRITE_UPDATE = 14
33
    CHANNEL_OVERWRITE_DELETE = 15
34
    MEMBER_KICK = 20
35
    MEMBER_PRUNE = 21
36
    MEMBER_BAN_ADD = 22
37
    MEMBER_BAN_REMOVE = 23
38
    MEMBER_UPDATE = 24
39
    MEMBER_ROLE_UPDATE = 25
40
    MEMBER_MOVE = 26
41
    MEMBER_DISCONNECT = 27
42
    BOT_ADD = 28
43
    ROLE_CREATE = 30
44
    ROLE_UPDATE = 31
45
    ROLE_DELETE = 32
46
    INVITE_CREATE = 40
47
    INVITE_UPDATE = 41
48
    INVITE_DELETE = 42
49
    WEBHOOK_CREATE = 50
50
    WEBHOOK_UPDATE = 51
51
    WEBHOOK_DELETE = 52
52
    EMOJI_CREATE = 60
53
    EMOJI_UPDATE = 61
54
    EMOJI_DELETE = 62
55
    MESSAGE_DELETE = 72
56
    MESSAGE_BULK_DELETE = 73
57
    MESSAGE_PIN = 74
58
    MESSAGE_UNPIN = 75
59
    INTEGRATION_CREATE = 80
60
    INTEGRATION_UPDATE = 81
61
    INTEGRATION_DELETE = 82
62
    STAGE_INSTANCE_CREATE = 83
63
    STAGE_INSTANCE_UPDATE = 84
64
    STAGE_INSTANCE_DELETE = 85
65
    STICKER_CREATE = 90
66
    STICKER_UPDATE = 91
67
    STICKER_DELETE = 92
68
    THREAD_CREATE = 110
69
    THREAD_UPDATE = 111
70
    THREAD_DELETE = 112
71
72
73
@dataclass
74
class AuditLogChange(APIObject):
75
    """
76
    Representation of Discord Audit Log Change object
77
78
    :param new_value:
79
        new value of the key
80
81
    :param old_value:
82
        old value of the key
83
84
    :param key:
85
        name of audit log change key
86
    """
87
    new_value: Any
88
    old_value: Any
89
    key: str
90
91
92
@dataclass
0 ignored issues
show
best-practice introduced by
Too many instance attributes (8/7)
Loading history...
93
class AuditEntryInfo(APIObject):
94
    """
95
    Represents Discord Optional Audit Entry Info
96
97
    :param delete_member_days:
98
        number of days after which inactive members were kicked
99
100
    :param members_removed:
101
        number of members removed by the prune
102
103
    :param channel_id:
104
        channel in which the entities were targeted
105
106
    :param message_id:
107
        id of the message that was targeted
108
109
    :param count:
110
        number of entities that were targeted
111
112
    :param id:
113
        id of the overwritten entity
114
115
    :param type:
116
        type of overwritten entity - "0" for "role" or "1" for "member"
117
118
    :param role_name:
119
        name of the role if type is "0" (not present if type is "1")
120
    """
121
    delete_member_days: str
122
    members_removed: str
123
    channel_id: Snowflake
0 ignored issues
show
introduced by
The variable Snowflake does not seem to be defined in case TYPE_CHECKING on line 13 is False. Are you sure this can never be the case?
Loading history...
124
    message_id: Snowflake
125
    count: str
126
    id: Snowflake
127
    type: str
128
    role_name: str
129
130
131
@dataclass
132
class AuditLogEntry(APIObject):
133
    """
134
    Represents a Discord Audit Log Entry object.
135
136
    :param target_id:
137
        id of the affected entity x(webhook, user, role, etc.)
138
139
    :param changes:
140
        changes made to the target_id
141
142
    :param user_id:
143
        the user who made the changes
144
145
    :param id:
146
        id of the entry
147
148
    :param action_type:
149
        type of action that occurred
150
151
    :param options:
152
        additional info for certain action types
153
154
    :param reason:
155
        the reason for the change x(0-512 characters)
156
    """
157
    target_id: Optional[str]
158
    user_id: Optional[Snowflake]
0 ignored issues
show
introduced by
The variable Snowflake does not seem to be defined in case TYPE_CHECKING on line 13 is False. Are you sure this can never be the case?
Loading history...
159
    id: Snowflake
160
    action_type: AuditLogEvent
161
162
    changes: APINullable[List[AuditLogChange]] = MISSING
0 ignored issues
show
introduced by
The variable APINullable does not seem to be defined in case TYPE_CHECKING on line 13 is False. Are you sure this can never be the case?
Loading history...
163
    options: APINullable[AuditEntryInfo] = MISSING
164
    reason: APINullable[str] = MISSING
165
166
167
@dataclass
168
class AuditLog(APIObject):
169
    """
170
    Represents a Discord Audit Log object.
171
172
    :param webhooks:
173
        list of webhooks found in the audit log
174
175
    :param users:
176
        list of users found in the audit log
177
178
    :param audit_log_entries:
179
        list of audit log entries
180
181
    :param integrations:
182
        list of partial integration objects
183
184
    :param threads:
185
        list of threads found in the audit log
186
    """
187
    webhooks: List[Webhook]
0 ignored issues
show
introduced by
The variable Webhook does not seem to be defined in case TYPE_CHECKING on line 13 is False. Are you sure this can never be the case?
Loading history...
188
    users: List[User]
0 ignored issues
show
introduced by
The variable User does not seem to be defined in case TYPE_CHECKING on line 13 is False. Are you sure this can never be the case?
Loading history...
189
    audit_log_entries: List[AuditLogEntry]
190
    integrations: List[Integration]
0 ignored issues
show
introduced by
The variable Integration does not seem to be defined in case TYPE_CHECKING on line 13 is False. Are you sure this can never be the case?
Loading history...
191
    threads: List[Channel]
0 ignored issues
show
introduced by
The variable Channel does not seem to be defined in case TYPE_CHECKING on line 13 is False. Are you sure this can never be the case?
Loading history...
192