From c273bb21631601b36cf7162818283d57cbe4a821 Mon Sep 17 00:00:00 2001 From: joseywoermann Date: Thu, 11 Feb 2021 10:36:19 +0100 Subject: [PATCH] added logging --- commands/developer.py | 2 +- core/command_logger.py | 41 +++++++++++++++++++++++++++++++++++++++++ core/server_logger.py | 18 ++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 core/command_logger.py create mode 100644 core/server_logger.py diff --git a/commands/developer.py b/commands/developer.py index 261cd81..63b9ee3 100644 --- a/commands/developer.py +++ b/commands/developer.py @@ -9,7 +9,7 @@ def __init__(self, client): @commands.command() async def developer(self, ctx): - dev_embed = discord.Embed(description="[Twitter](https://twitter.com/joseywoermann/) - [Website](http://joseywoermann.tk/) - [GitHub](https://github.com/joseywoermann/)\n\n[Discord](https://discord.gg/SchJckc) - [Reddit](https://reddit.com/u/joseywoermann/) - [](https://github.com/joseywoermann/)", colour=discord.Colour.dark_grey()) + dev_embed = discord.Embed(description="[Twitter](https://twitter.com/joseywoermann/) - [Website](https://joseywoermann.ml/) - [GitHub](https://github.com/joseywoermann/)\n\n[Discord](https://discord.gg/SchJckc) - [Reddit](https://reddit.com/u/joseywoermann/) - [Github](https://github.com/joseywoermann/)", colour=discord.Colour.dark_grey()) dev_embed.set_author(name=ctx.message.author,icon_url=ctx.author.avatar_url) await ctx.reply(embed = dev_embed) diff --git a/core/command_logger.py b/core/command_logger.py new file mode 100644 index 0000000..3742229 --- /dev/null +++ b/core/command_logger.py @@ -0,0 +1,41 @@ +import discord +from discord.ext import commands +import logging +from time import sleep + +class CommandLogger(commands.Cog): + + def __init__(self, client): + self.client = client + + @commands.Cog.listener() + async def on_message(self, message): + + server = message.guild + + if message.content.startswith("$"): + + if server.id == 304191437652623360: + + log_channel = self.client.get_channel(751879355344617582) + + log_embed = discord.Embed(title=message.content, description="Channel: **{0.channel.name}** Channel-ID: [{0.channel.id}]".format(message)) + log_embed.set_author(name="User: " + message.author.name + "#" + str(message.author.discriminator) + " ID: " + str(message.author.id), icon_url=message.author.avatar_url) + log_embed.set_footer(text=message.created_at.strftime("%Y; %m. %d., %H:%M:%S") + " Server: " + str(message.channel.guild) + " / " + str(message.guild.id)) + + await log_channel.send(content=None, embed=log_embed) + + else: + + log_channel = self.client.get_channel(751879443810615487) + + log_embed = discord.Embed(title=message.content, description=" Channel: **{0.channel.name}** Channel-ID: [{0.channel.id}]".format(message)) + log_embed.set_author(name="User: " + message.author.name + "#" + str(message.author.discriminator) + " ID: " + str(message.author.id), icon_url=message.author.avatar_url) + log_embed.set_footer(text=message.created_at.strftime("%Y; %m. %d., %H:%M:%S") + " Server: " + str(message.channel.guild) + " / " + str(message.guild.id)) + + await log_channel.send(content=None, embed=log_embed) + + + +def setup(client): + client.add_cog(CommandLogger(client)) diff --git a/core/server_logger.py b/core/server_logger.py new file mode 100644 index 0000000..30ab4d9 --- /dev/null +++ b/core/server_logger.py @@ -0,0 +1,18 @@ +import discord +from discord.ext import commands +import logging +from asyncio import sleep + +class Join_leave_notification(commands.Cog): + + def __init__(self, client): + self.client = client + + + @commands.Cog.listener() + async def on_guild_join(self, ctx): + owner = self.client.get_user(586206645592391711) + await owner.send("Joined server \"" + str(ctx.name) + "\" (" + str(ctx.id) + ")") + +def setup(client): + client.add_cog(Join_leave_notification(client))