Added analytics
This commit is contained in:
parent
7fdf37e35a
commit
c9f2da5834
30
cogs/analytics.py
Normal file
30
cogs/analytics.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import logging
|
||||||
|
from discord import (
|
||||||
|
Cog,
|
||||||
|
Message,
|
||||||
|
)
|
||||||
|
from discord.ext import commands
|
||||||
|
from modules.database import col_analytics
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Analytics(commands.Cog):
|
||||||
|
def __init__(self, client):
|
||||||
|
self.client = client
|
||||||
|
|
||||||
|
@Cog.listener()
|
||||||
|
async def on_message(self, message: Message):
|
||||||
|
if (
|
||||||
|
(message.author != self.client.user)
|
||||||
|
and (message.author.bot == False)
|
||||||
|
and (message.author.system == False)
|
||||||
|
):
|
||||||
|
col_analytics.insert_one(
|
||||||
|
{
|
||||||
|
"message": message.content,
|
||||||
|
"user": message.author.id,
|
||||||
|
"channel": message.channel.id,
|
||||||
|
}
|
||||||
|
)
|
@ -18,12 +18,13 @@ db = db_client.get_database(name=db_config["name"])
|
|||||||
|
|
||||||
collections = db.list_collection_names()
|
collections = db.list_collection_names()
|
||||||
|
|
||||||
for collection in ["users", "warnings", "scheduler"]:
|
for collection in ["users", "warnings", "scheduler", "analytics"]:
|
||||||
if not collection in collections:
|
if not collection in collections:
|
||||||
db.create_collection(collection)
|
db.create_collection(collection)
|
||||||
|
|
||||||
col_users = db.get_collection("users")
|
col_users = db.get_collection("users")
|
||||||
col_warnings = db.get_collection("warnings")
|
col_warnings = db.get_collection("warnings")
|
||||||
|
col_analytics = db.get_collection("analytics")
|
||||||
# col_checkouts = db.get_collection("checkouts")
|
# col_checkouts = db.get_collection("checkouts")
|
||||||
# col_trackings = db.get_collection("trackings")
|
# col_trackings = db.get_collection("trackings")
|
||||||
# col_authorized = db.get_collection("authorized")
|
# col_authorized = db.get_collection("authorized")
|
||||||
|
Loading…
Reference in New Issue
Block a user