Пример #1
0
    async def register(self, ctx):
        """Add yourself to the database"""
        if repo_u.exists(ctx.author.id):
            return await ctx.author.send("You are already registered.")

        nickname = self.sanitise(ctx.author.name, limit=12).replace(")", "").replace("(", "")

        # get first available nickname
        i = 0
        name_orig = nickname
        while repo_u.is_nickname_used(nickname):
            nickname = f"{name_orig}{i}"
            i += 1

        # register
        repo_u.add(discord_id=ctx.author.id, nickname=nickname)
        if isinstance(ctx.channel, discord.TextChannel) and repo_w.get(ctx.channel.id):
            beam_name = repo_w.get(ctx.channel.id).beam
            repo_u.set(ctx.author.id, key=f"home_id:{beam_name}", value=ctx.channel.id)

        await self.event.user(ctx, f"Registered as **{nickname}**.")
        await ctx.author.send(
            f"You are now registered as `{nickname}`. "
            f"You can display your information with `{self.p}me`.\n"
            f"To see information about another user, enter `{self.p}whois [nickname]`.\n\n"
            f"You can tag other registered users with `((nickname))`."
        )
Пример #2
0
 async def user_add(self, ctx, member_id: int, nickname: str):
     """Add user"""
     repo_u.add(discord_id=member_id, nickname=nickname)
     self.event.sudo(ctx, f"{str(repo_u.get(member_id))}.")