async def blacklist_remove(self, ctx, tag: str): """ Remove a person from blacklist """ await ctx.trigger_typing() if ctx.guild.id == 724202847822151680 and not ctx.author.guild_permissions.administrator: return await ctx.send("You can't use this command.") if ctx.guild.id != 724202847822151680 and not ctx.author.guild_permissions.kick_members: return await ctx.send("You can't use this command.") tag = tag.lower().replace('o', '0') if tag.startswith("#"): tag = tag.strip('#') try: ign = await self.config.guild(ctx.guild ).blacklisted.get_raw(tag, "ign") await self.config.guild(ctx.guild).blacklisted.clear_raw(tag) await ctx.send(embed=goodEmbed( f"{ign} was successfully removed from this server's blacklist!" )) except KeyError: await ctx.send( embed=badEmbed(f"#{tag} isn't blacklisted in this server!"))
async def blacklist_check(self, ctx, tag: str): """ Check whether a person is blacklisted """ await ctx.trigger_typing() if ctx.guild.id == 724202847822151680 and ctx.author.top_role < ctx.guild.get_role(822458522322599956): return await ctx.send("You can't use this command.") if ctx.guild.id != 724202847822151680 and not ctx.author.guild_permissions.kick_members: return await ctx.send("You can't use this command.") tag = tag.lower().replace('o', '0') if tag.startswith("#"): tag = tag.strip('#') blacklisted = False guild = "" name = "" reason = "" servers = await self.config.all_guilds() for server in servers: serverobj = self.bot.get_guild(server) if serverobj is not None: try: name = await self.config.guild(serverobj).blacklisted.get_raw(tag, "ign") reason = await self.config.guild(serverobj).blacklisted.get_raw(tag, "reason") guild = serverobj.name blacklisted = True except KeyError: continue if blacklisted: await ctx.send(embed=goodEmbed(f"{name} is blacklisted in {guild} ({reason})!")) else: await ctx.send(embed=badEmbed(f"Looks like this tag isn't blacklisted anywhere!"))
async def setlang(self, ctx, lang): await ctx.trigger_typing() langs = ["en", "es"] if lang not in langs: return await ctx.send("No such language supported.") await self.config.guild(ctx.guild).roles.language.set(lang) await ctx.send(embed=goodEmbed(f"Value language set to {lang}."))
async def coc_clan_remove(self, ctx, key: str): await ctx.trigger_typing() key = key.lower() try: name = await self.config.guild(ctx.guild).clans.get_raw(key, "name") await self.config.guild(ctx.guild).clans.clear_raw(key) await ctx.send(embed=goodEmbed(f"{name} was successfully removed from this server!")) except KeyError: await ctx.send(embed=badEmbed(f"{key.title()} isn't saved club!"))
async def setrole(self, ctx, key, role: discord.Role = None): await ctx.trigger_typing() key = key.lower() try: await self.config.guild(ctx.guild).roles.set_raw( key, value=role.id if role is not None else None) name = role.name if role is not None else "None" await ctx.send(embed=goodEmbed(f"Value {key} set to {name}.")) except KeyError: await ctx.send(embed=badEmbed( f"{key.title()} isn't a valid keyword in this server."))
async def cocsave(self, ctx, tag, member: discord.Member = None): member = ctx.author if member is None else member tag = tag.lower().replace('O', '0') if tag.startswith("#"): tag = tag.strip('#') try: player = self.apirequest("players/%23" + tag) await self.config.user(member).tag.set(player['tag'].replace("#", "")) await ctx.send(embed=goodEmbed(f"COC account {player['name']} was saved to {member.name}")) except Exception as e: await ctx.send(f"Something went wrong: {e}.")
async def blacklist_add(self, ctx, tag: str, *, reason: str = ""): """ Add a player to blacklist """ await ctx.trigger_typing() if ctx.guild.id == 724202847822151680 and not ctx.author.guild_permissions.administrator: return await ctx.send("You can't use this command.") if ctx.guild.id != 724202847822151680 and not ctx.author.guild_permissions.kick_members: return await ctx.send("You can't use this command.") tag = tag.lower().replace('o', '0') if tag.startswith("#"): tag = tag.strip('#') if tag in (await self.config.guild(ctx.guild).blacklisted()).keys(): return await ctx.send( embed=badEmbed("This person is already blacklisted!")) try: player = await self.ofcbsapi.get_player(tag) player_in_club = "name" in player.raw_data["club"] if player_in_club: clubname = player.club.name else: clubname = "No club" result = {"ign": player.name, "club": clubname, "reason": reason} await self.config.guild(ctx.guild ).blacklisted.set_raw(tag, value=result) await ctx.send( embed=goodEmbed(f"{player.name} was successfully blacklisted!") ) except brawlstats.errors.NotFoundError as e: return await ctx.send( embed=badEmbed("No player with this tag found, try again!")) except brawlstats.errors.RequestError as e: return await ctx.send(embed=badEmbed( f"BS API is offline, please try again later! ({str(e)})")) except Exception as e: return await ctx.send( f"**Something went wrong, please send a personal message to LA Modmail bot or try again!** ({e})" )
async def coc_clan_add(self, ctx, key: str, tag: str): await ctx.trigger_typing() if key in (await self.config.guild(ctx.guild).clans()).keys(): return await ctx.send(embed=badEmbed("This clan is already saved!")) try: clan = self.apirequest("clans/%23" + tag.replace("#", "")) result = { "name": clan['name'], "nick": key.title(), "tag": clan['tag'].replace("#", ""), "lastMemberCount": clan['members'], "lastRequirement": clan['requiredTrophies'], "lastPoints": clan['clanPoints'], "lastVersusPoints": clan['clanVersusPoints'], "info": "" } key = key.lower() await self.config.guild(ctx.guild).clans.set_raw(key, value=result) await ctx.send(embed=goodEmbed(f"{clan['name']} was successfully saved in this server!")) except Exception as e: return await ctx.send(f"**Something went wrong: {str(e)}.**")