def Alert(self, User, Guild, Action, Invoker=None, Reason=None, Duration=None): embed = discord.Embed(title="{}, {}!".format( Language.get(Guild.id, self.bot.cache, "Functions", "Hey"), User.name), colour=0x27b1db, description="{} {}!".format( Language.get(Guild.id, self.bot.cache, "Functions", "Action"), Action)) embed.set_author(name=Guild.name, icon_url=Guild.icon_url) if Invoker: embed.add_field(name=Language.get(Guild.id, self.bot.cache, "Functions", "By"), value=Invoker, inline=True) if Reason: embed.add_field(name=Language.get(Guild.id, self.bot.cache, "Functions", "Reason"), value=Reason, inline=True) if Duration: embed.add_field(name=Language.get(Guild.id, self.bot.cache, "Functions", "Duration"), value=Duration, inline=True) return embed
async def snipe(self, ctx): with open("./data/sniper.json") as f: self.sniper = json.load(f) if not ctx.author.guild_permissions.manage_messages: return await ctx.send(embed=func.NoPerm(self, ctx.guild.id), delete_after=15) if not str(ctx.guild.id) in self.sniper: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "NoSnipeMessage"))) if not str(ctx.channel.id) in self.sniper[str(ctx.guild.id)]: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "NoSnipeMessage"))) user = await self.bot.fetch_user(self.sniper[str( ctx.guild.id)][str(ctx.channel.id)]["AuthorID"]) embed = discord.Embed(colour=discord.Colour(0x27b1db), description=self.sniper[str( ctx.guild.id)][str( ctx.channel.id)]["Message"]) embed.set_author(name=user.name, icon_url=user.avatar_url) await ctx.send(embed=embed) del self.sniper[str(ctx.guild.id)] with open("./data/sniper.json", "w") as f: json.dump(self.sniper, f, indent=4)
async def botinfo(self, ctx): activeServers = self.bot.guilds sum = 0 for s in activeServers: sum += len(s.members) if self.bot.shard_ids != None: shardnum = self.bot.shard_ids.index(ctx.guild.shard_id) + 1 else: shardnum = 1 current_time = time.time() difference = int(round(current_time - start_time)) uptime = str(datetime.timedelta(seconds=difference)) dapi = time.time() async with aiohttp.ClientSession() as session: async with session.get('https://discord.com/api/'): dapi2 = time.time() discordlatency = dapi2 - dapi wapi = time.time() async with aiohttp.ClientSession() as session: async with session.get('http://116.203.154.166:8080/'): wapi2 = time.time() watchdoglatency = wapi2 - wapi connected_desc = f"""``` - Watchdog {config.version} - Watchdog API ({int(round(watchdoglatency, 2) * 100)}ms) - Discord API ({int(round(discordlatency, 2) * 100)}ms) - {len(activeServers)} {Language.get(ctx.guild.id, self.bot.cache, "Info", "Guilds")} - {sum} {Language.get(ctx.guild.id, self.bot.cache, "Info", "Users")} - {Language.get(ctx.guild.id, self.bot.cache, "Info", "Shards")} {shardnum} / {self.bot.shard_count} ({int(round(self.bot.latency, 2) * 100)}ms) - {Language.get(ctx.guild.id, self.bot.cache, "Info", "Cluster")} 0 / 0 (0ms)```""" coding_desc = f"""``` - {Language.get(ctx.guild.id, self.bot.cache, "Info", "Language")}: Python {platform.python_version()} - {Language.get(ctx.guild.id, self.bot.cache, "Info", "Library")}: Discord.py - {Language.get(ctx.guild.id, self.bot.cache, "Info", "Version")}: {discord.__version__}```""" cluster_desc = f"""``` - {Language.get(ctx.guild.id, self.bot.cache, "Info", "OS")}: {platform.system()} - {Language.get(ctx.guild.id, self.bot.cache, "Info", "CPU")}: {cpu_percent(interval=None, percpu=False)}% - {Language.get(ctx.guild.id, self.bot.cache, "Info", "RAM")}: {virtual_memory().percent}% - {Language.get(ctx.guild.id, self.bot.cache, "Info", "Uptime")}: {uptime}```""" embed = discord.Embed(colour=0x27b1db) embed.set_author(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "BotInfo")) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Connected"), value=connected_desc, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Coding"), value=coding_desc, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Cluster"), value=cluster_desc, inline=False) await ctx.send(embed=embed)
def NoPerm(self, id): title = random.choice(Language.get(id, self.bot.cache, "BadResponses")) embed = discord.Embed(title=title, description=Language.get(id, self.bot.cache, "Functions", "NoPerm"), colour=0xebc634, timestamp=datetime.datetime.utcnow()) return embed
async def help(self, ctx): embed = discord.Embed(colour=0x27b1db) embed.set_author(name="Watchdog - {}".format(Language.get(ctx.guild.id, self.bot.cache, "Core", "Help"))) embed.set_footer(text=Language.get(ctx.guild.id, self.bot.cache, "Core", "HelpFooter")) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Core", "AutoMod"), value=f"`{ctx.prefix}help automod`", inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Core", "Mod"), value=f"`{ctx.prefix}help moderator`", inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Core", "Commands"), value=f"`{ctx.prefix}help commands`", inline=True) await ctx.send(embed=embed)
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
def MassJoinWarning(self, id, users): embed = discord.Embed(colour=0x27b1db, description="**{}:\n\n{}**".format( Language.get(id, self.bot.cache, "Functions", "UsersInvolved"), "\n ".join(users))) embed.set_author(name=Language.get(id, self.bot.cache, "Functions", "MassJoinWarning")) embed.set_footer(text="{}: {}".format( Language.get(id, self.bot.cache, "Functions", "Users"), len( users))) return embed
async def on_command_error(self, ctx, error): if hasattr(ctx.command, 'on_error'): return ignored = (commands.CommandNotFound, commands.NoPrivateMessage, commands.DisabledCommand, discord.NotFound, commands.CheckFailure) error = getattr(error, "original", error) if isinstance(error, ignored): return elif isinstance(error, commands.BadArgument): return await ctx.send(embed=func.ErrorEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Errors", "BadArgument")), delete_after=15) elif isinstance(error, discord.Forbidden): try: return await ctx.send(embed=func.ErrorEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Errors", "Forbidden")), delete_after=15) except discord.Forbidden: return elif isinstance(error, commands.MissingPermissions): try: return await ctx.send(embed=func.ErrorEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Errors", "MissingPermissions")), delete_after=15) except discord.Forbidden: return elif isinstance(error, commands.CommandOnCooldown): return await ctx.send(embed=func.ErrorEmbed( self, ctx.guild.id, "{}! {}".format( ctx.author.mention, Language.get(ctx.guild.id, self.bot.cache, "Errors", "Cooldown"))), delete_after=15) await self.Errorlog(ctx, error)
def AutoModInfraction(self, Guild, User, InfractionsCount, Reason): embed = discord.Embed( colour=0x27b1db, description="**{}:** {}\n**{}:** Watchdog".format( Language.get(Guild.id, self.bot.cache, "AutoMod", "Reason"), Reason, Language.get(Guild.id, self.bot.cache, "Functions", "Invoker"))) embed.set_author(name="{}#{} {}".format( User.name, User.discriminator, Language.get(Guild.id, self.bot.cache, "Functions", "Recieved"))) embed.set_footer(text="{}: {}".format( Language.get(Guild.id, self.bot.cache, "Functions", "UInfractions"), InfractionsCount)) return embed
async def commands_(self, ctx): desc = f""" `{ctx.prefix}invite` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Invite")} `{ctx.prefix}vote` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Vote")} `{ctx.prefix}serverinfo` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Sinfo")} `{ctx.prefix}sinfo` `{ctx.prefix}userinfo` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Uinfo")} `{ctx.prefix}uinfo` `{ctx.prefix}roleinfo [role]` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Rinfo")} `{ctx.prefix}rinfo [{Language.get(ctx.guild.id, self.bot.cache, "Core", "Role")}]` `{ctx.prefix}botinfo` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Binfo")} `{ctx.prefix}binfo, {ctx.prefix}info` `{ctx.prefix}spotify` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Spotify")} `{ctx.prefix}requestdata` {Language.get(ctx.guild.id, self.bot.cache, "Core", "RD")} `{ctx.prefix}dashboard` {Language.get(ctx.guild.id, self.bot.cache, "Core", "DashHelp")} """ embed = discord.Embed(description=desc, colour=0x27b1db) embed.set_author(name="Watchdog - {}".format(Language.get(ctx.guild.id, self.bot.cache, "Core", "Commands"))) await ctx.send(embed=embed)
def GoodResponseEmbed(self, id, desc): title = random.choice(Language.get(id, self.bot.cache, "GoodResponses")) embed = discord.Embed(title=title, description=desc, colour=0x27b1db, timestamp=datetime.datetime.utcnow()) return embed
async def spotify(self, ctx, user : discord.Member=None): if user == None: user = ctx.author pass if user.activities: for activity in user.activities: if isinstance(activity, Spotify): embed = discord.Embed( description = "{} {}".format(Language.get(ctx.guild.id, self.bot.cache, "Info", "Listening"), activity.title), colour = 0x27b1db, ) embed.set_thumbnail(url=activity.album_cover_url) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Artist"), value=activity.artist) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Album"), value=activity.album) embed.set_footer(text="{} {}".format(Language.get(ctx.guild.id, self.bot.cache, "Info", "SongStart"), activity.created_at.strftime("%H:%M"))) await ctx.send(embed=embed)
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))
def ErrorEmbed(self, id, error): title = random.choice( Language.get(id, self.bot.cache, "ErrorResponses")) embed = discord.Embed(title=title, description=error, colour=0xebc634, timestamp=datetime.datetime.utcnow()) return embed
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 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 automod_(self, ctx): desc = f""" {Language.get(ctx.guild.id, self.bot.cache, "Core", "AutoModDesc")} [{Language.get(ctx.guild.id, self.bot.cache, "Core", "Dashboard")}](https://watchdogbot.net/) """ embed = discord.Embed(description=desc, colour=0x27b1db) embed.set_author(name="Watchdog - {}".format(Language.get(ctx.guild.id, self.bot.cache, "Core", "AutoMod"))) await ctx.send(embed=embed)
async def clear(self, ctx, amount: int = None): if not ctx.author.guild_permissions.manage_messages: return await ctx.send(embed=func.NoPerm(self, ctx.guild.id), delete_after=15) await ctx.message.delete() if not amount or amount > 100 or amount < 1: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "Upto100")), delete_after=15) dela = await ctx.channel.purge(limit=amount) await ctx.send("{}: {}".format( Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Deleted"), len(dela)), delete_after=15)
async def infractions(self, ctx, member: discord.Member = 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) infr = sql.GetInfractions(ctx.guild.id, member.id) if not infr: return await ctx.send(embed=func.BadResponseEmbed( self, ctx.guild.id, "{} {}".format( member.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Errors", "HasNoInfractions"))), delete_after=15) embed = discord.Embed(colour=0x27b1db) for i in infr: u = await self.bot.fetch_user(i[3]) desc = "{} {} {} @ {} | {}: {}".format( member.mention, Language.get(ctx.guild.id, self.bot.cache, "Moderator", "WarnedBy"), u.mention, i[5], Language.get(ctx.guild.id, self.bot.cache, "Moderator", "Reason"), i[4]) embed.add_field(name="{}: {}".format( Language.get(ctx.guild.id, self.bot.cache, "Moderator", "InfractID"), i[0]), value=desc, inline=False) await ctx.send(embed=embed)
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 serverinfo(self, ctx): embed = discord.Embed(colour = 0x27b1db) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "CreationDate"), value=ctx.guild.created_at.strftime("%d/%m/%Y at %H:%M:%S"), inline=False) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Owner"), value=ctx.guild.owner.name, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Region"), value=ctx.guild.region, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Roles"), value=len(ctx.guild.roles), inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Users"), value=ctx.guild.member_count, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Channels"), value=len(ctx.guild.channels), inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "AFKChannel"), value=ctx.guild.afk_channel, inline=True) embed.set_footer(icon_url=ctx.guild.icon_url, text=f"{ctx.guild.name} - {ctx.guild.id}") await ctx.send(embed=embed)
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 roleinfo(self, ctx, name=None): role = discord.utils.get(ctx.guild.roles, name=name) if not role: return await ctx.send(embed=func.BadResponseEmbed(self, ctx.guild.id, Language.get(ctx.guild.id, self.bot.cache, "Info", "Errors", "NoRole"))) embed = discord.Embed(colour = 0x27b1db) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Rolename"), value=role.mention, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "RoleID"), value=role.id, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "UsersWRole"), value=len(role.members), inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Mentionable"), value=role.mentionable, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "DisplayedSep"), value=role.hoist, inline=True) embed.add_field(name=Language.get(ctx.guild.id, self.bot.cache, "Info", "Colour"), value=role.colour, inline=True) embed.set_footer(text="{} - {}".format(Language.get(ctx.guild.id, self.bot.cache, "Info", "RoleCreated"), role.created_at.strftime("%d/%m/%Y at %H:%M:%S"))) await ctx.send(embed=embed)
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 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_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_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_channel_create(self, channel): role = discord.utils.get(channel.guild.roles, name="muted") if not role: return if channel.guild.id in self.bot.cache: if self.bot.cache[channel.guild.id]["Logs"]: channel = await self.bot.fetch_channel( self.bot.cache[channel.guild.id]["Logs"]) try: await channel.set_permissions(role, send_messages=False, add_reactions=False) except: if channel: await channel.send(embed=func.BadResponseEmbed( self, channel.guild.id, "{} {}".format( Language.get(channel.guild.id, self.bot.cache, "Errors", "CantSetOverwrite"), channel.name)))
async def moderator_(self, ctx): desc = f""" `{ctx.prefix}kick #{Language.get(ctx.guild.id, self.bot.cache, "Core", "User")} ({Language.get(ctx.guild.id, self.bot.cache, "Core", "Reason")})` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Kick")} `{ctx.prefix}ban #{Language.get(ctx.guild.id, self.bot.cache, "Core", "User")} ({Language.get(ctx.guild.id, self.bot.cache, "Core", "Reason")})` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Ban")} `{ctx.prefix}clear [{Language.get(ctx.guild.id, self.bot.cache, "Core", "Amount")}]` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Clear")} `{ctx.prefix}mute #{Language.get(ctx.guild.id, self.bot.cache, "Core", "User")} [{Language.get(ctx.guild.id, self.bot.cache, "Core", "Duration")}]` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Mute")} `{ctx.prefix}unmute #{Language.get(ctx.guild.id, self.bot.cache, "Core", "User")}` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Unmute")} `{ctx.prefix}warn #{Language.get(ctx.guild.id, self.bot.cache, "Core", "User")} ({Language.get(ctx.guild.id, self.bot.cache, "Core", "Reason")})` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Warn")} `{ctx.prefix}infractions remove #{Language.get(ctx.guild.id, self.bot.cache, "Core", "User")} [{Language.get(ctx.guild.id, self.bot.cache, "Core", "WarnID")}]` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Unwarn")} `{ctx.prefix}infractions #{Language.get(ctx.guild.id, self.bot.cache, "Core", "User")}` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Infractions")} `{ctx.prefix}snipe ` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Snipe")} `{ctx.prefix}say [{Language.get(ctx.guild.id, self.bot.cache, "Core", "Words")}]` {Language.get(ctx.guild.id, self.bot.cache, "Core", "Say")} """ embed = discord.Embed(description=desc, colour=0x27b1db) embed.set_author(name="Watchdog - {}".format(Language.get(ctx.guild.id, self.bot.cache, "Core", "Mod"))) await ctx.send(embed=embed)
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'] = []