Skip to content

Commit

Permalink
Merge pull request #12 from Mineinjava/mineinjavaDev
Browse files Browse the repository at this point in the history
Add Audit Logs
  • Loading branch information
Mineinjava authored Feb 15, 2021
2 parents efe32ba + 48b379e commit 5a24580
Show file tree
Hide file tree
Showing 22 changed files with 621 additions and 98 deletions.
63 changes: 8 additions & 55 deletions discordSplash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

import discordSplash.resources.opcodes as op
import traceback
from discordSplash import member

commands = {}


class Presence:
"""Presence data used when connecting to Gateway
:param int presenceType: type of presence to use. See https://discord.com/developers/docs/topics/gateway#activity-object-activity-types for more info.
:param str text: Text of status to use. See {text} below.
.. Note ::
::
0 Game Playing {text}
1 Streaming Streaming {text}
Expand All @@ -40,7 +40,7 @@ def __init__(self, presenceType: int, text: str):
def type(self):
"""Returns the type of the activity. Used internally
:return: Integer from 1-5. See class `discordSplash.`**`Presence`** for more info
:return: Integer from 1-5. See class discordSplash.Presence** for more info
:rtype: int
"""

Expand Down Expand Up @@ -108,53 +108,6 @@ def json(self):
return self.jsonContent


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']


class ReactionData():
"""reaction data passed in to the handler
Expand Down Expand Up @@ -193,9 +146,9 @@ def type(self):

@property
def user(self):
""":return: a `discordSplash.`**`Member`** object.
:rtype: discordSplash.Member"""
return Member(self.jsonData['member']['user'])
""":return: a discordSplash.member.Member** object.
:rtype: discordSplash.member.Member"""
return member.Member(self.jsonData['member']['user'])

@property
def options(self):
Expand Down Expand Up @@ -237,10 +190,10 @@ class Run():
:raises: discordSplash.UnregisteredCommandException
.. Tip::
`Run('TOKEN', Presence(text='testing', presenceType=5))`
``Run('TOKEN', Presence(text='testing', presenceType=5))``
.. Important::
most of the methods here are only used internally.
Most of the methods here are only used internally.
Expand Down
98 changes: 98 additions & 0 deletions discordSplash/audit_log.py
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 added discordSplash/channel.py
Empty file.
Empty file added discordSplash/emoji.py
Empty file.
Empty file added discordSplash/guild.py
Empty file.
Empty file added discordSplash/invite.py
Empty file.
45 changes: 45 additions & 0 deletions discordSplash/member.py
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 added discordSplash/template.py
Empty file.
Empty file added discordSplash/webhook.py
Empty file.
Binary file modified docs/_build/doctrees/discordSplash.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
67 changes: 67 additions & 0 deletions docs/_build/html/_sources/discordSplash.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,73 @@ Subpackages

discordSplash.resources

Submodules
----------

discordSplash.audit\_log module
-------------------------------

.. automodule:: discordSplash.audit_log
:members:
:undoc-members:
:show-inheritance:

discordSplash.channel module
----------------------------

.. automodule:: discordSplash.channel
:members:
:undoc-members:
:show-inheritance:

discordSplash.emoji module
--------------------------

.. automodule:: discordSplash.emoji
:members:
:undoc-members:
:show-inheritance:

discordSplash.guild module
--------------------------

.. automodule:: discordSplash.guild
:members:
:undoc-members:
:show-inheritance:

discordSplash.invite module
---------------------------

.. automodule:: discordSplash.invite
:members:
:undoc-members:
:show-inheritance:

discordSplash.member module
---------------------------

.. automodule:: discordSplash.member
:members:
:undoc-members:
:show-inheritance:

discordSplash.template module
-----------------------------

.. automodule:: discordSplash.template
:members:
:undoc-members:
:show-inheritance:

discordSplash.webhook module
----------------------------

.. automodule:: discordSplash.webhook
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

Expand Down
12 changes: 10 additions & 2 deletions docs/_build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Discord: coming soon™
DiscordSplash is an easy-to-use api wrapper for the Discord Api (specifically Slash Commands and interactions)

This module was made because the [discord.py](http://github.com/rapptz) does not support Interactions
This module was made because the `discord.py <http://github.com/rapptz/discord.py>`_ module does not support Interactions.

This project is still in beta.

Expand All @@ -31,4 +31,12 @@ DiscordSplash currently does not support voice. This may change in the future.

Contributions:
################
Please contribute to this project on [GitHub](http://github.com/mineinjava/discord-splash)
Please contribute to this project on `GitHub <http://github.com/mineinjava/discord-splash>`_

Table Of Contents
#################
- API reference
- FAQ
- GitHub URL
- Discord Server
-
Loading

0 comments on commit 5a24580

Please sign in to comment.