-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Mineinjava/mineinjavaDev
Add Audit Logs
- Loading branch information
Showing
22 changed files
with
621 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import discordSplash | ||
|
||
|
||
class AuditLog: | ||
def __init__(self, jsondata): | ||
self.jsondata = jsondata | ||
|
||
@property | ||
def webhooks(self): | ||
"""List of Webhooks found in the Audit Log | ||
:rtype: list | ||
:return: list of Webhook objects | ||
.. Error:: | ||
You will receive a list of JSON data currently. | ||
""" | ||
return self.jsondata['webhooks'] | ||
|
||
@property | ||
def users(self): | ||
"""Returns a list of all users found in the Audit log | ||
:return: list of discordSplash.member.Member objects | ||
:rtype: list""" | ||
listUsers = [] | ||
for user in self.jsondata['users']: | ||
listUsers.append(discordSplash.member.Member(user)) | ||
return listUsers | ||
|
||
@property | ||
def integrations(self): | ||
""" | ||
Returns a list of all integrations found in the Audit Log. | ||
.. warning:: | ||
May change from ``PartialIntegration`` to ``Integration``. See ``TODO`` in class PartialIntegration. | ||
:return: list of discordSplash.audit_log.PartialIntegration objects. | ||
:rtype: list | ||
""" | ||
listIntegrations = [] | ||
for integration in self.jsondata['integrations']: | ||
listIntegrations.append(PartialIntegration(integration)) | ||
return listIntegrations | ||
|
||
|
||
class Entry: | ||
def __init__(self, jsondata): | ||
self.jsondata = jsondata | ||
|
||
|
||
class PartialIntegration: | ||
def __init__(self, jsondata): | ||
"""Partial integration object. Used mainly in Audit Logs | ||
TODO: make it a full integration object.""" | ||
self.jsondata = jsondata | ||
|
||
@property | ||
def id(self): | ||
"""ID of the integration | ||
:rtype: int""" | ||
return str(self.jsondata("id")) | ||
|
||
@property | ||
def name(self): | ||
"""Name of the integration | ||
:rtype: str""" | ||
return self.jsondata("name") | ||
|
||
@property | ||
def type(self): | ||
"""Type of the integration. | ||
:rtype: str""" | ||
return self.jsondata("type") | ||
|
||
@property | ||
def account(self): | ||
"""integration account | ||
:return: Account of the integration | ||
:rtype: discordSplash.audit_log.Account""" | ||
return Account(self.jsondata("account")) | ||
|
||
|
||
class Account: | ||
""" | ||
Discord Account Object | ||
""" | ||
|
||
def __init__(self, jsondata): | ||
self.jsondata = jsondata | ||
|
||
@property | ||
def name(self): | ||
"""Name of the account. | ||
:rtype: str""" | ||
return self.jsondata("name") | ||
|
||
@property | ||
def id(self): | ||
"""Id of the account. | ||
:rtype: int""" | ||
return int(self.jsondata("id")) |
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
class Member: | ||
"""Represents a discord member. Used internally to parse interaction/member JSON data. | ||
:param json memberJson: JSON to parse into this class. | ||
TODO: | ||
- add a method to send a DM to the user | ||
- add an `avatar_url` property""" | ||
|
||
def __init__(self, memberJson): | ||
self.memberJson = memberJson | ||
|
||
@property | ||
def avatar(self): | ||
""" | ||
:return: the member's avatar hash | ||
:rtype: str | ||
""" | ||
return self.memberJson['avatar'] | ||
|
||
@property | ||
def id(self): | ||
""" | ||
:return: the user's id | ||
:rtype: int | ||
""" | ||
return int(self.memberJson['id']) | ||
|
||
@property | ||
def username(self): | ||
""" | ||
:return: the user's username | ||
:rtype: str | ||
""" | ||
return self.memberJson['username'] | ||
|
||
@property | ||
def discriminator(self): | ||
""" | ||
.. Warning :: | ||
**CURRENTLY BROKEN** | ||
""" | ||
return self.memberJson['id'] |
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.