Esempio n. 1
0
 async def announce(self, ctx, *, message: str):
     """Sends an annoucement to all servers that have a tournament running."""
     for guild in self.bot.guilds:
         tournament = self.bot.session.query(Tournament).where(
             Tournament.guild_id == guild.id).first()
         if tournament:
             staff_channel = self.bot.get_channel(
                 tournament.staff_channel_id)
             tosurnament_guild = self.get_guild(guild.id)
             admin_role = base.get_role(guild.roles,
                                        tosurnament_guild.admin_role_id,
                                        "Admin")
             if admin_role:
                 admin_role_mention = admin_role.mention
             else:
                 admin_role_mention = guild.owner.mention
             try:
                 if staff_channel:
                     await staff_channel.send(admin_role_mention + "\n\n" +
                                              message)
                     continue
             except Exception:
                 pass
         try:
             await guild.owner.send(message)
         except Exception:
             continue
Esempio n. 2
0
 async def announce(self, ctx, *, message: str):
     """Sends an annoucement to all servers that have a tournament running."""
     users_already_sent_to = []
     for guild in self.bot.guilds:
         tournament = tosurnament_api.get_tournament_by_discord_guild_id(guild.id)
         if tournament:
             staff_channel = self.bot.get_channel(int(tournament.staff_channel_id))
             tosurnament_guild = self.get_guild(guild.id)
             admin_role = base.get_role(guild.roles, tosurnament_guild.admin_role_id, "Admin")
             if admin_role:
                 admin_role_mention = admin_role.mention
             else:
                 admin_role_mention = guild.owner.mention
             try:
                 if staff_channel:
                     await staff_channel.send(admin_role_mention + "\n\n" + message)
                     continue
             except Exception:
                 pass
         if guild.owner.id not in users_already_sent_to:
             try:
                 await guild.owner.send(message)
                 users_already_sent_to.append(guild.owner.id)
             except Exception:
                 continue
Esempio n. 3
0
 async def on_verified_user(self, guild, user):
     bot_guild = self.get_guild(guild.id)
     verified_role_id = None
     if bot_guild:
         verified_role_id = bot_guild.verified_role_id
     verified_role = base.get_role(guild.roles, verified_role_id,
                                   "Verified")
     if verified_role:
         await user.add_roles(verified_role)
Esempio n. 4
0
 def cog_check(self, ctx):
     if not ctx.guild:
         raise commands.NoPrivateMessage()
     if ctx.guild.owner == ctx.author:
         return True
     guild = self.get_guild(ctx.guild.id)
     if not guild or not guild.admin_role_id:
         raise base.NotBotAdmin()
     if not base.get_role(ctx.author.roles, guild.admin_role_id):
         raise base.NotBotAdmin()
     return True
Esempio n. 5
0
 async def on_verified_user(self, guild, user):
     verified_user = self.get_verified_user(user.id)
     bot_guild = self.get_guild(guild.id)
     verified_role_id = None
     if bot_guild:
         verified_role_id = bot_guild.verified_role_id
     verified_role = base.get_role(guild.roles, verified_role_id, "Verified")
     if verified_user.osu_name:
         try:
             await user.edit(nick=verified_user.osu_name)
         except Exception:
             self.bot.info("Missing manage_nicknames permission or error while changing the nickname of the user")
     if verified_role:
         try:
             await user.add_roles(verified_role)
         except Exception:
             self.bot.info("Missing manage_roles permission or error while changing the role of the user")
Esempio n. 6
0
 async def setup_verification_channel(self, ctx, channel: discord.TextChannel):
     """Setups a channel with a message to react on to be verified."""
     guild = self.get_guild(ctx.guild.id)
     verified_role_id = None
     if guild:
         verified_role_id = guild.verified_role_id
     verified_role = base.get_role(ctx.guild.roles, verified_role_id, "Verified")
     if not verified_role:
         raise base.RoleDoesNotExist("Verified")
     message = await self.send_reply(ctx, "setup", channel=channel)
     guild_verify_message = (
         self.bot.session.query(GuildVerifyMessage).where(GuildVerifyMessage.guild_id == ctx.guild.id).first()
     )
     if guild_verify_message:
         guild_verify_message.message_id = message.id
         self.bot.session.update(guild_verify_message)
     else:
         self.bot.session.add(GuildVerifyMessage(message_id=message.id, guild_id=ctx.guild.id))
     await message.add_reaction("🛎️")