Unverified Commit 8d060269 authored by AnonymousDapper's avatar AnonymousDapper
Browse files

add lewd-alert and small fixes

parent 684d39e7
......@@ -21,11 +21,9 @@
# SOFTWARE.
import traceback
import discord
from datetime import datetime
import discord
from discord.ext import commands
#from .utils import sql
......@@ -69,11 +67,13 @@ class Analytics(commands.Cog):
# Listener functions
# Socket event arrived
@commands.Cog.listener()
async def on_socket_response(self, payload):
if self.bot.debug:
self.log_socket_data(payload)
# Command was triggered
@commands.Cog.listener()
async def on_command(self, ctx):
message = ctx.message
channel = ctx.channel
......@@ -91,6 +91,7 @@ class Analytics(commands.Cog):
await self.log_command_use(ctx)
# Message arrived
@commands.Cog.listener()
async def on_message(self, message):
channel = message.channel
author = message.author
......@@ -98,10 +99,14 @@ class Analytics(commands.Cog):
if author.bot or (not self.bot.is_ready()):
return
if isinstance(channel, discord.channel.DMChannel):
return
if hasattr(author, "display_name"):
await self.log_message(message)
# Message deleted
@commands.Cog.listener()
async def on_message_delete(self, message):
channel = message.channel
author = message.author
......@@ -109,6 +114,7 @@ class Analytics(commands.Cog):
await self.log_message_change(message, edited=False)
# Messaged edited
@commands.Cog.listener()
async def on_message_edit(self, old_message, new_message):
channel = new_message.channel
author = new_message.author
......@@ -117,6 +123,7 @@ class Analytics(commands.Cog):
await self.log_message_change(new_message, edited=True)
# Coommand tossed an error
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if ctx.command is not None:
await self.bot.db.edit_command_report(ctx.message, True)
......@@ -139,10 +146,13 @@ class Analytics(commands.Cog):
elif isinstance(error, (commands.MissingRequiredArgument, commands.BadArgument)):
await ctx.send(f"\N{WARNING SIGN} {error}")
elif isinstance(error, discord.errors.Forbidden):
log.warn(f"{ctx.command.qualified_name} failed: Forbidden. Required | Have ({self.pprint_perms(self.bot.required_permissions)} | {self.pprint_perms(ctx.channel.permissions_for(ctx.guild.me))})")
elif isinstance(error, discord.Forbidden):
log.warn(f"{ctx.command.qualified_name} failed: Forbidden. Required | Have \n\t({self.pprint_perms(self.bot.required_permissions)} | {self.pprint_perms(ctx.channel.permissions_for(ctx.guild.me))})")
elif isinstance(error, commands.CommandInvokeError):
if isinstance(error.original, discord.Forbidden):
log.warn(f"{ctx.command.qualified_name} failed: Forbidden. Required | Have \n\t({self.pprint_perms(self.bot.required_permissions)} | {self.pprint_perms(ctx.channel.permissions_for(ctx.guild.me))})")
original_name = error.original.__class__.__name__
print(f"In {paint(ctx.command.qualified_name, 'b_red')}:")
traceback.print_tb(error.original.__traceback__)
......
......@@ -21,14 +21,12 @@
# SOFTWARE.
import re
from datetime import datetime
from random import choice
from urllib.parse import quote_plus, quote
from urllib.parse import quote, quote_plus
import aiohttp
import discord
from bs4 import BeautifulSoup as b_soup
from discord.ext import commands
from PIL import ImageColor
......
......@@ -19,3 +19,26 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import discord
from discord.ext import commands
from .utils.logger import get_logger
log = get_logger()
class Misc(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name="lewd-alert", brief="print alert about lewd activities")
@commands.guild_only()
async def lewd_alert(self, ctx, *participants: discord.Member):
await ctx.send(f"**Lewd Alert**: A *lewd*, *lascivious*, and likely *immoral* act has occured in __{ctx.guild.name}__ #{ctx.channel.name}. Participating individuals include {', '.join(f'`{participant.display_name}`' for participant in participants)}.\nThis incident will be reported.")
# Lewd Alert: A lewd, lascivious, and possibly immoral act has occured in Discord Bots <#110373943822540800>. Individuals reported as participating in such debauchery include Julia, lewd-alert as a service.
#This incident will be recorded.
def setup(bot):
bot.add_cog(Misc(bot))
......@@ -32,10 +32,11 @@ class Moderation(commands.Cog):
@commands.command(name="clean", brief="remove snake's messages")
@commands.cooldown(2, 60, commands.BucketType.guild)
@commands.guild_only()
async def self_clean(self, ctx):
async for message in ctx.history(limit=30, before=ctx.message):
if message.author == ctx.guild.me:
await message.delete()
def setup(bot):
bot.add_cog(Moderation(bot))
\ No newline at end of file
bot.add_cog(Moderation(bot))
......@@ -23,22 +23,16 @@
import asyncio
import os
import sys
from datetime import datetime
import aiohttp
import discord
import toml
from discord.ext import commands
from pympler.tracker import SummaryTracker
from cogs.utils import logger
from cogs.utils import permissions
from cogs.utils import sql
from cogs.utils import time, checks
from cogs.utils import checks, logger, permissions, sql, time
from cogs.utils.colors import paint
from cogs.utils.imgur import ImgurAPI
from discord.ext import commands
from pympler.tracker import SummaryTracker
# Attempt to load uvloop for improved event loop performance
try:
......@@ -186,14 +180,17 @@ class SnakeBot(commands.Bot):
self.imgur_api = ImgurAPI(client_id=credentials["Imgur"]["client_id"])
help_cmd = commands.DefaultHelpCommand(
command_attrs=dict(hidden=True),
)
# Init superclass
super().__init__(
*args,
**kwargs,
help_command=help_cmd,
description="\nHsss!\n",
help_attrs=dict(hidden=True),
command_not_found=None,
command_has_no_subcommand="\N{WARNING SIGN} Command `{1}` doesn't exist in the `{0.name}` group!",
command_prefix=self.get_prefix
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment