예제 #1
0
 async def generate_permissions(self):
     # role permissions
     student_permissions: Permissions = Permissions.none()
     student_permissions.update(add_reactions=True,
                                stream=True,
                                read_message_history=True,
                                read_messages=True,
                                send_messages=True,
                                connect=True,
                                speak=True,
                                use_voice_activation=True,
                                embed_links=True,
                                attach_files=True)
     admin_permissions: Permissions = Permissions.all()
     un_authed_permissions: Permissions = Permissions.none()
     un_authed_permissions.update(read_message_history=True,
                                  read_messages=True,
                                  send_messages=True)
     ta_permissions: Permissions = Permissions.all()
     ta_permissions.update(administrator=False,
                           admin_permissions=False,
                           manage_channels=False,
                           manage_guild=False,
                           manage_roles=False,
                           manage_permissions=False,
                           manage_webhooks=False)
     return admin_permissions, ta_permissions, student_permissions, un_authed_permissions
예제 #2
0
 def __init__(self):
     # role permissions
     self.student_permissions: Permissions = Permissions.none()
     self.student_permissions.update(add_reactions=True,
                                     stream=True,
                                     read_message_history=True,
                                     read_messages=True,
                                     send_messages=True,
                                     connect=True,
                                     speak=True,
                                     use_voice_activation=True)
     self.admin_permissions: Permissions = Permissions.all()
     self.un_authed_perms: Permissions = Permissions.none()
     self.un_authed_perms.update(read_message_history=True,
                                 read_messages=True,
                                 send_messages=True)
     self.ta_permissions: Permissions = Permissions.all()
     self.ta_permissions.update(
         administrator=False,
         admin_permissions=False,
         manage_channels=False,
         manage_guild=False,
         manage_roles=False,
         manage_permissions=False,
         manage_webhooks=False,
     )
예제 #3
0
    async def _create_anonc_chat_channel(self, guild, member) -> AnoncChannel:
        overwrites = {
            guild.default_role:
            PermissionOverwrite.from_pair(
                Permissions.none(),  # allow
                Permissions.all()  # deny
            ),
            member:
            PermissionOverwrite(send_messages=True,
                                read_messages=True,
                                manage_messages=True,
                                attach_files=True,
                                read_message_history=True)
        }

        anonc_id = random_string(4)
        while self.get_anonc_chat_channel_from_anonc_id(anonc_id):
            anonc_id = random_string(4)

        anonc_id_role = None
        if self.use_role:
            anonc_id_role = await guild.create_role(name=anonc_id,
                                                    mentionable=True)

        channel = await guild.create_text_channel('anon chat',
                                                  overwrites=overwrites,
                                                  topic=anonc_id,
                                                  nsfw=self.nsfw)
        webhook = await channel.create_webhook(name=str(member.id))

        return AnoncChannel(channel, webhook, member, anonc_id_role)
예제 #4
0
파일: bot.py 프로젝트: furimu/moveer_jp
async def join(ctx):
    """Joins a server."""
    perms = Permissions.none()

    perms.connect = True
    perms.move_members = True

    await ctx.send(f'<{utils.oauth_url(config.client_id, perms)}>')
예제 #5
0
    async def _create_anonc_member_guild(self) -> Guild:
        if len(self.client.guilds) >= 2:
            await self.disable_use_role()
        guild = await self.client.create_guild(
            name=f'{self.base_name}-{len(self.anonc_chat_guilds)+1}')

        await guild.default_role.edit(
            mantionable=False,
            permissions=Permissions(permissions=67108864)  #  change nickname
        )
        bot_owner = await guild.create_role(name='bot owner',
                                            permissions=Permissions.all())
        anonc_moderator = await guild.create_role(
            name='anonc moderator', permissions=Permissions.none())
        anonc_system = await guild.create_role(name='anonc system',
                                               permissions=Permissions.none())

        for name, path in (('msg_anchor', self.client.anchor_emoji_path),
                           ('at_sign', self.client.at_sign_emoji_path)):
            with open(path, 'rb') as f:
                await guild.create_custom_emoji(name=name,
                                                image=f.read(),
                                                roles=[anonc_system])
        # TODO : なんか動かない。
        guild = next((g for g in self.client.guilds if g == guild))
        channels = await guild.fetch_channels()
        for channel in channels:
            if isinstance(channel, (CategoryChannel, )):
                continue
            elif isinstance(channel, (TextChannel, )):
                await channel.category.edit(name='anonc_system_channels')
                await channel.category.set_permissions(guild.default_role,
                                                       read_messages=False)
                await channel.category.set_permissions(bot_owner,
                                                       read_messages=True,
                                                       send_messages=True)
                await channel.category.set_permissions(anonc_moderator,
                                                       read_messages=True,
                                                       send_messages=True)
            else:
                await channel.category.delete()
                await channel.delete()

        return guild
예제 #6
0
    def __init__(self, ctx: Context, role: Role):
        """Initialise a SubRole object.

        Args:
            ctx: The Discord message Context.
            role: The Discord Role object that is wrapped by this class.

        """
        self.ctx = ctx
        self.role = role
        self.permissions_none: Permissions = Permissions.none()
예제 #7
0
    async def guild_permissions(self):
        if self.guild.owner_id == self.id:
            return Permissions.all()

        base = Permissions.none()
        for role in await self.roles():
            base.value |= role._permissions

        if base.administrator:
            return Permissions.all()

        return base
예제 #8
0
	async def join(self, ctx):
		"""Provides the bot invite link."""
		perms = Permissions.none()
		perms.read_messages = True
		perms.external_emojis = True
		perms.send_messages = True
		perms.manage_roles = True
		perms.manage_channels = True
		perms.ban_members = True
		perms.kick_members = True
		perms.manage_messages = True
		perms.embed_links = True
		perms.read_message_history = True
		perms.attach_files = True
		perms.add_reactions = True
		await ctx.send(f'<{utils.oauth_url(self.bot.user.id, perms)}>')
 async def invite(self, ctx):
     """Gives you the bot's Invite Link. If you don't want the bot to create its own role or you want to set the
     permissions yourself, use the Invite without permissions. But don't forget that it won't work without these
     permissions.
     """
     no_perms = oauth_url(ctx.bot.client_id, Permissions.none())
     best_perms = oauth_url(
         ctx.bot.client_id,
         Permissions(send_messages=True,
                     read_messages=True,
                     embed_links=True,
                     add_reactions=True,
                     move_members=True,
                     manage_channels=True))
     await ctx.send(embed=Embed(
         title=':envelope: Invite links',
         description=
         f'[Invite (recommended)]({best_perms})\n[Invite (no permissions)]({no_perms})',
         color=0x000000))
예제 #10
0
 async def role_vanity(self, ctx, *, name):
     """makes a vanity role"""
     await ctx.guild.create_role(name=name, permissions=Permissions.none(), reason=f'created by {ctx.author}')
     await ctx.ok()