async def on_message(self, message): if not self.Init(message): return guild = message.guild self.store[guild.id][message.author.id]["String"] = message.content self.store[guild.id][message.author.id]["Count"] = 0 self.store[guild.id][message.author.id]["Count"] = len( re.findall(u'[\U00010000-\U0010ffff]', message.content)) # Normal Emojis self.store[guild.id][message.author.id]["Count"] += len( re.findall( '<(?P<animated>a)?:(?P<name>[0-9a-zA-Z_]{2,32}):(?P<id>[0-9]{15,21})>', message.content)) # Custom Emojis if self.store[guild.id][message.author.id]["Count"] > self.bot.cache[ guild.id]["AutoMod"][4]["Ratelimit"]: member = message.author await message.channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Emojis")), delete_after=30) if self.bot.cache[message.guild.id]["AutoMod"][4]["Enabled"] == 1: if self.bot.cache[message.guild.id]["Logs"]: channel = await self.bot.fetch_channel( self.bot.cache[message.guild.id]["Logs"]) await channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Emojis"))) sql.Warn( guild.id, member.id, 702141833437773824, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Emojis")) sql.LogMe( guild.id, 9, "{} {}. {}: {}".format( Language.get(message.guild.id, self.bot.cache, "AutoMod", "Warned"), member.name, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Reason"), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Emojis"))) await Rules.DoRule(self, member, message.guild, self.bot.tobemuted, self.bot.tobekicked, self.bot.tobebanned) try: await message.delete() except: pass self.store[guild.id][member.id]['Count'] = 0 self.store[guild.id][member.id]['String'] = None
async def on_message(self, message): if not self.Init(message): return guild = message.guild self.store[message.guild.id][message.author.id] += 1 if self.store[guild.id][message.author.id] >= self.bot.cache[ guild.id]["AutoMod"][8]["Ratelimit"]: member = message.author await message.channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Spam")), delete_after=30) if self.bot.cache[message.guild.id]["AutoMod"][8]["Enabled"] == 1: if self.bot.cache[message.guild.id]["Logs"]: channel = await self.bot.fetch_channel( self.bot.cache[message.guild.id]["Logs"]) await channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Spam"))) sql.Warn( guild.id, member.id, 702141833437773824, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Spam")) sql.LogMe( guild.id, 9, "{} {}. {}: {}".format( Language.get(message.guild.id, self.bot.cache, "AutoMod", "Warned"), member.name, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Reason"), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Spam"))) await Rules.DoRule(self, member, message.guild, self.bot.tobemuted, self.bot.tobekicked, self.bot.tobebanned) try: msgs = [] async for messagea in message.channel.history( limit=self.bot.cache[ guild.id]["AutoMod"][8]["Ratelimit"]): if member == messagea.author: msgs.append(messagea) await message.channel.delete_messages(msgs) msgs.clear() except: pass self.store[guild.id][member.id] = 0
async def on_message(self, message): if not self.Init(message): return guild = message.guild filetypes = [ '.exe', '.py', '.dll', '.xls', '.doc', '.xlsx', '.docx', '.vbs', '.sln', '.application', '.com', '.cpl' ] for i in message.attachments: for f in filetypes: j = i.filename.lower() if j.endswith(f): self.store[guild.id] = True if self.store[guild.id] == True: member = message.author await message.channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "File")), delete_after=30) if self.bot.cache[message.guild.id]["AutoMod"][9]["Enabled"] == 1: if self.bot.cache[message.guild.id]["Logs"]: channel = await self.bot.fetch_channel( self.bot.cache[message.guild.id]["Logs"]) await channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "File"))) sql.Warn( guild.id, member.id, 702141833437773824, Language.get(message.guild.id, self.bot.cache, "AutoMod", "File")) sql.LogMe( guild.id, 9, "{} {}. {}: {}".format( Language.get(message.guild.id, self.bot.cache, "AutoMod", "Warned"), member.name, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Reason"), Language.get(message.guild.id, self.bot.cache, "AutoMod", "File"))) await Rules.DoRule(self, member, message.guild, self.bot.tobemuted, self.bot.tobekicked, self.bot.tobebanned) try: await message.delete() except: pass self.store[guild.id] = False
async def remove(self, ctx, member: discord.Member = None, id=None): if not ctx.author.guild_permissions.manage_messages: return await ctx.send(embed=func.NoPerm(self, ctx.guild.id), delete_after=15) if not member: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "NoInfractionsUser")), delete_after=15) if not id: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, "{} {}{}".format( Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "NeedID"), ctx.prefix, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "NeedIDEnd"))), delete_after=15) rm = sql.RemoveInfraction(id, ctx.guild.id, member.id) channel = await self.bot.fetch_channel( self.bot.cache[ctx.guild.id]["Logs"]) if not rm: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, "{} {}: {}".format( member.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "DoesntHave"), id)), delete_after=15) await ctx.send(embed=func.GoodResponseEmbed( self, ctx.guild.id, "{} {} {}".format( member.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "InfractionRemoved"), id))) if channel: await channel.send(embed=func.GoodResponseEmbed( self, ctx.guild.id, "{} {} {}".format( member.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "InfractionRemoved"), id))) sql.LogMe( ctx.guild.id, 5, "{} ({}) {}: {} {} {}".format( ctx.author.display_name, ctx.author.name, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "UnWarned"), id, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "From"), member.name))
async def on_guild_join(self, guild): activeServers = self.bot.guilds sum = 0 for s in activeServers: sum += len(s.members) people = format(sum, ",") watch = discord.Activity(type=discord.ActivityType.watching, name=f"{people} people | w!help") await self.bot.change_presence(activity=watch) sql.AddData(guild.id) sql.LogMe( guild.id, 1, "{} {}".format( Language.get(guild.id, self.bot.cache, "Events", "Added"), guild.name)) muted_role = discord.utils.get(guild.roles, name="muted") if not muted_role: try: role = await guild.create_role(name="muted") except: try: return await guild.owner.send(embed=func.BadResponseEmbed( self, guild.id, "{} {}setup @ {}".format( Language.get(guild.id, self.bot.cache, "Core", "Error", "CantCreateMutedRole"), "w!", guild.name))) except: return Failed = [] for channel in guild.channels: if channel.type != "voice": if not channel.overwrites_for(muted_role): try: await channel.set_permissions(role, send_messages=False, add_reactions=False) except: Failed.append(channel.name) pass if len(Failed) > 0: try: return await guild.owner.send(embed=func.BadResponseEmbed( self, guild.id, "{}\n\n {}".format( Language.get(guild.id, self.bot.cache, "Errors", "CantSetOverwrite"), "\n".join(Failed)))) except: return
async def warn(self, ctx, member: discord.Member = None, reason=None): if not ctx.author.guild_permissions.manage_messages: return await ctx.send(embed=func.NoPerm(self, ctx.guild.id), delete_after=15) if not member: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "WarnNoUser")), delete_after=15) if not reason: reason = Language.get(ctx.guild.id, self.bot.cache, "Moderator", "NoReason") channel = await self.bot.fetch_channel( self.bot.cache[ctx.guild.id]["Logs"]) sql.Warn(ctx.guild.id, member.id, ctx.author.id, reason) await member.send(embed=func.Alert( self, member, ctx.guild, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Warned"), ctx.author, reason)) await ctx.send(embed=func.GoodResponseEmbed( self, ctx.guild.id, "{} {} {} | {}: {}".format( member.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "WasWarned"), ctx.author.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Reason"), reason))) await Rules.DoRule(self, member, ctx.guild, self.bot.tobemuted, self.bot.tobekicked, self.bot.tobebanned) if channel: await channel.send(embed=func.GoodResponseEmbed( self, ctx.guild.id, "{} {} {} | {}: {}".format( member.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "WasWarned"), ctx.author.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Reason"), reason))) sql.LogMe( ctx.guild.id, 5, "{} ({}) {} {}. {}: {}".format( ctx.author.display_name, ctx.author.name, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Warned"), member.name, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Reason"), reason))
async def ban(self, ctx, user: discord.User = None, *args): if not ctx.author.guild_permissions.ban_members: return await ctx.send(embed=func.NoPerm(self, ctx.guild.id), delete_after=15) if not user: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "BanNoUser")), delete_after=15) reason = ' '.join(args) channel = await self.bot.fetch_channel( self.bot.cache[ctx.guild.id]["Logs"]) if reason == "": reason = Language.get(ctx.guild.id, self.bot.cache, "Moderator", "NoReason") await user.send(embed=func.Alert( self, user, ctx.guild, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Banned"), ctx.author.name, reason)) await ctx.send(embed=func.GoodResponseEmbed( self, ctx.guild.id, "{} {} {} | {}: {}".format( user.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "WasBanned"), ctx.author.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Reason"), reason))) if channel: await channel.send(embed=func.GoodResponseEmbed( self, ctx.guild.id, "{} {} {} | {}: {}".format( user.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "WasBanned"), ctx.author.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Reason"), reason))) await ctx.guild.ban(user, reason=reason, delete_message_days=7) sql.LogMe( ctx.guild.id, 8, "{} ({}) {} {}. {}: {}".format( ctx.author.display_name, ctx.author.name, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Banned"), user.name, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Reason"), reason))
async def on_message_edit(self, before, after): if not self.Init(after): return guild = after.guild text = after.content.replace('*', '') censored = profanity.censor(text) if '*' in censored: member = after.author await after.channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(after.guild.id, self.bot.cache, "AutoMod", "Swearing")), delete_after=30) if self.bot.cache[after.guild.id]["AutoMod"][7]["Enabled"] == 1: if self.bot.cache[after.guild.id]["Logs"]: channel = await self.bot.fetch_channel( self.bot.cache[after.guild.id]["Logs"]) await channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(after.guild.id, self.bot.cache, "AutoMod", "Swearing"))) sql.Warn( guild.id, member.id, 702141833437773824, Language.get(after.guild.id, self.bot.cache, "AutoMod", "Swearing")) sql.LogMe( guild.id, 9, "{} {}. {}: {}".format( Language.get(after.guild.id, self.bot.cache, "AutoMod", "Warned"), member.name, Language.get(after.guild.id, self.bot.cache, "AutoMod", "Reason"), Language.get(after.guild.id, self.bot.cache, "AutoMod", "Swearing"))) await Rules.DoRule(self, member, after.guild, self.bot.tobemuted, self.bot.tobekicked, self.bot.tobebanned) try: await after.delete() except: pass
async def on_guild_remove(self, guild): activeServers = self.bot.guilds sum = 0 for s in activeServers: sum += len(s.members) people = format(sum, ",") watch = discord.Activity(type=discord.ActivityType.watching, name=f"{people} people | w!help") await self.bot.change_presence(activity=watch) sql.RemoveData(guild.id) sql.LogMe( guild.id, 2, "{} {}".format( Language.get(guild.id, self.bot.cache, "Events", "Removed"), guild.name))
async def on_message(self, message): if not self.Init(message): return guild = message.guild self.store[guild.id][message.author.id]["String"] = message.content self.store[guild.id][message.author.id]["Count"] = 0 for i in message.content: if(i.isupper()): self.store[guild.id][message.author.id]["Count"] += 1 self.store[guild.id][message.author.id]["Percentage"] = self.store[guild.id][message.author.id]["Count"] / len(self.store[guild.id][message.author.id]["String"]) * 100 if self.store[guild.id][message.author.id]["Percentage"] >= self.bot.cache[guild.id]["AutoMod"][3]["Ratelimit"]: member = message.author await message.channel.send(embed=func.AutoModInfraction(self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Caps")), delete_after=30) if self.bot.cache[message.guild.id]["AutoMod"][3]["Enabled"] == 1: if self.bot.cache[message.guild.id]["Logs"]: channel = await self.bot.fetch_channel(self.bot.cache[message.guild.id]["Logs"]) await channel.send(embed=func.AutoModInfraction(self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Caps"))) sql.Warn(guild.id, member.id, 702141833437773824, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Caps")) sql.LogMe(guild.id, 9, "{} {}. {}: {}".format(Language.get(message.guild.id, self.bot.cache, "AutoMod", "Warned"), member.name, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Reason"), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Caps"))) await Rules.DoRule(self, member, message.guild, self.bot.tobemuted, self.bot.tobekicked, self.bot.tobebanned) try: await message.delete() except: pass self.store[guild.id][member.id]['Count'] = 0 self.store[guild.id][member.id]['Percentage'] = 0 self.store[guild.id][member.id]['String'] = None
async def on_message(self, message): if not self.Init(message): return guild = message.guild self.store[guild.id][message.author.id]['Percentage'] = 0 self.store[guild.id][message.author.id]['String'] = list( message.content.lower().split()) self.store[guild.id][message.author.id]['Unique'] = [] for i in self.store[guild.id][message.author.id]['String']: if not i in self.store[guild.id][message.author.id]['Unique']: self.store[guild.id][message.author.id]['Unique'].append(i) self.store[guild.id][message.author.id]['Percentage'] = ( len(self.store[guild.id][message.author.id]['Unique']) / len(message.content.lower().split()) * 100) if self.store[guild.id][ message.author.id]['Percentage'] >= self.bot.cache[ guild.id]["AutoMod"][1]["Ratelimit"]: member = message.author await message.channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Repeated")), delete_after=30) if self.bot.cache[message.guild.id]["AutoMod"][1]["Enabled"] == 1: if self.bot.cache[message.guild.id]["Logs"]: channel = await self.bot.fetch_channel( self.bot.cache[message.guild.id]["Logs"]) await channel.send(embed=func.AutoModInfraction( self, guild, member, len(sql.GetInfractions(guild.id, member.id)), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Repeated"))) sql.Warn( guild.id, member.id, 702141833437773824, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Repeated")) sql.LogMe( guild.id, 9, "{} {}. {}: {}".format( Language.get(message.guild.id, self.bot.cache, "AutoMod", "Warned"), member.name, Language.get(message.guild.id, self.bot.cache, "AutoMod", "Reason"), Language.get(message.guild.id, self.bot.cache, "AutoMod", "Repeated"))) await Rules.DoRule(self, member, message.guild, self.bot.tobemuted, self.bot.tobekicked, self.bot.tobebanned) try: await message.delete() except: pass self.store[guild.id][message.author.id]['Percentage'] = 0 self.store[guild.id][message.author.id]['String'] = None self.store[guild.id][message.author.id]['Unique'] = []