Completed
Push — main ( b12314...8ccbcd )
by Yohann
17s queued 14s
created

pincer.objects.audit_log   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 210
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 88
dl 0
loc 210
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# MIT License
3
#
4
# Copyright (c) 2021 Pincer
5
#
6
# Permission is hereby granted, free of charge, to any person obtaining
7
# a copy of this software and associated documentation files
8
# (the "Software"), to deal in the Software without restriction,
9
# including without limitation the rights to use, copy, modify, merge,
10
# publish, distribute, sublicense, and/or sell copies of the Software,
11
# and to permit persons to whom the Software is furnished to do so,
12
# subject to the following conditions:
13
#
14
# The above copyright notice and this permission notice shall be
15
# included in all copies or substantial portions of the Software.
16
#
17
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
from __future__ import annotations
26
from dataclasses import dataclass
27
from enum import Enum
28
from typing import Any, Optional, List
29
30
from pincer.objects.channel import Channel
31
from pincer.objects.integration import Integration
32
from pincer.objects.user import User
33
from pincer.objects.webhook import Webhook
34
from pincer.utils.api_object import APIObject
35
from pincer.utils.constants import APINullable, MISSING
36
from pincer.utils.snowflake import Snowflake
37
38
39
class AuditLogEvent(Enum):
40
    """
41
    Audit log action type.
42
    This represents the action which got performed,
43
    and logged.
44
    """
45
    GUILD_UPDATE = 1
46
    CHANNEL_CREATE = 10
47
    CHANNEL_UPDATE = 11
48
    CHANNEL_DELETE = 12
49
    CHANNEL_OVERWRITE_CREATE = 13
50
    CHANNEL_OVERWRITE_UPDATE = 14
51
    CHANNEL_OVERWRITE_DELETE = 15
52
    MEMBER_KICK = 20
53
    MEMBER_PRUNE = 21
54
    MEMBER_BAN_ADD = 22
55
    MEMBER_BAN_REMOVE = 23
56
    MEMBER_UPDATE = 24
57
    MEMBER_ROLE_UPDATE = 25
58
    MEMBER_MOVE = 26
59
    MEMBER_DISCONNECT = 27
60
    BOT_ADD = 28
61
    ROLE_CREATE = 30
62
    ROLE_UPDATE = 31
63
    ROLE_DELETE = 32
64
    INVITE_CREATE = 40
65
    INVITE_UPDATE = 41
66
    INVITE_DELETE = 42
67
    WEBHOOK_CREATE = 50
68
    WEBHOOK_UPDATE = 51
69
    WEBHOOK_DELETE = 52
70
    EMOJI_CREATE = 60
71
    EMOJI_UPDATE = 61
72
    EMOJI_DELETE = 62
73
    MESSAGE_DELETE = 72
74
    MESSAGE_BULK_DELETE = 73
75
    MESSAGE_PIN = 74
76
    MESSAGE_UNPIN = 75
77
    INTEGRATION_CREATE = 80
78
    INTEGRATION_UPDATE = 81
79
    INTEGRATION_DELETE = 82
80
    STAGE_INSTANCE_CREATE = 83
81
    STAGE_INSTANCE_UPDATE = 84
82
    STAGE_INSTANCE_DELETE = 85
83
    STICKER_CREATE = 90
84
    STICKER_UPDATE = 91
85
    STICKER_DELETE = 92
86
    THREAD_CREATE = 110
87
    THREAD_UPDATE = 111
88
    THREAD_DELETE = 112
89
90
91
@dataclass
92
class AuditLogChange(APIObject):
93
    """
94
    Representation of Discord Audit Log Change object
95
96
    :param new_value:
97
        new value of the key
98
99
    :param old_value:
100
        old value of the key
101
102
    :param key:
103
        name of audit log change key
104
    """
105
    new_value: Any
106
    old_value: Any
107
    key: str
108
109
110
@dataclass
0 ignored issues
show
best-practice introduced by
Too many instance attributes (8/7)
Loading history...
111
class AuditEntryInfo(APIObject):
112
    """
113
    Represents Discord Optional Audit Entry Info
114
115
    :param delete_member_days:
116
        number of days after which inactive members were kicked
117
118
    :param members_removed:
119
        number of members removed by the prune
120
121
    :param channel_id:
122
        channel in which the entities were targeted
123
124
    :param message_id:
125
        id of the message that was targeted
126
127
    :param count:
128
        number of entities that were targeted
129
130
    :param id:
131
        id of the overwritten entity
132
133
    :param type:
134
        type of overwritten entity - "0" for "role" or "1" for "member"
135
136
    :param role_name:
137
        name of the role if type is "0" (not present if type is "1")
138
    """
139
    delete_member_days: str
140
    members_removed: str
141
    channel_id: Snowflake
142
    message_id: Snowflake
143
    count: str
144
    id: Snowflake
1 ignored issue
show
Coding Style Naming introduced by
Attribute name "id" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
145
    type: str
146
    role_name: str
147
148
149
@dataclass
150
class AuditLogEntry(APIObject):
151
    """
152
    Represents a Discord Audit Log Entry object.
153
154
    :param target_id:
155
        id of the affected entity x(webhook, user, role, etc.)
156
157
    :param changes:
158
        changes made to the target_id
159
160
    :param user_id:
161
        the user who made the changes
162
163
    :param id:
164
        id of the entry
165
166
    :param action_type:
167
        type of action that occurred
168
169
    :param options:
170
        additional info for certain action types
171
172
    :param reason:
173
        the reason for the change x(0-512 characters)
174
    """
175
    target_id: Optional[str]
176
    user_id: Optional[Snowflake]
177
    id: Snowflake
1 ignored issue
show
Coding Style Naming introduced by
Attribute name "id" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
178
    action_type: AuditLogEvent
179
180
    changes: APINullable[List[AuditLogChange]] = MISSING
0 ignored issues
show
introduced by
Value 'APINullable' is unsubscriptable
Loading history...
181
    options: APINullable[AuditEntryInfo] = MISSING
0 ignored issues
show
introduced by
Value 'APINullable' is unsubscriptable
Loading history...
182
    reason: APINullable[str] = MISSING
0 ignored issues
show
introduced by
Value 'APINullable' is unsubscriptable
Loading history...
183
184
185
@dataclass
186
class AuditLog(APIObject):
187
    """
188
    Represents a Discord Audit Log object.
189
190
    :param webhooks:
191
        list of webhooks found in the audit log
192
193
    :param users:
194
        list of users found in the audit log
195
196
    :param audit_log_entries:
197
        list of audit log entries
198
199
    :param integrations:
200
        list of partial integration objects
201
202
    :param threads:
203
        list of threads found in the audit log
204
    """
205
    webhooks: List[Webhook]
206
    users: List[User]
207
    audit_log_entries: List[AuditLogEntry]
208
    integrations: List[Integration]
209
    threads: List[Channel]
210