Beispiel #1
0
    async def register_new(self, ctx, *args):
        my_result = query_user(ctx.author.id, ctx.guild.id)
        if my_result is not None:
            await ctx.send("Player is already registered in database.")
        elif my_result is None:
            print("\nRegister new")
            result = _register(ctx.author, ctx.author.display_name,
                               ctx.author.id, ctx.author.guild.id, args)
            if result == 'Invalid':
                await ctx.send(
                    """Uh oh! I couldn't find that stat. Try one or more of the following, separated by commas:
`hunger, humanity, stains, current willpower, total willpower, health, superficial damage, aggravated damage.`"""
                )
            elif result == ():
                await ctx.send(
                    f"""**__{ctx.author.display_name}__**'s basic player information has been registered in the database.
No character stats have been added yet. Please use `.update` or `.set` to enter your stats."""
                )
            else:
                print(result)
                stats = fregister_results(result)
                print(stats)
                print()
                await ctx.send(
                    f"""**__{ctx.author.display_name}__**'s player information has been registered, and the following stats have been set:\n{stats}"""
                )
Beispiel #2
0
    async def show(self, ctx, target: Greedy[Member], *args):
        if target == []:
            userID = ctx.author.id
            player = ctx.author  # moved
        else:
            split_target = str(target).split(' ')
            ids = [x[3:] for x in split_target if x[0:3] == 'id=']
            userID = int(ids[0])
            player = ctx.author.guild.get_member(userID)  #moved
        my_result = query_user(userID, ctx.guild.id)

        if my_result is None:
            await ctx.send("Player is not registered in database.")
        else:
            res = search(userID, ctx.author.guild.id, args)
            print(res)

            if res == 'Invalid':
                await ctx.send(
                    """Uh oh! I couldn't find that stat. Try one or more of the following, separated by commas:
`hunger, humanity, stains, current willpower, total willpower, health, superficial damage, aggravated damage.`"""
                )
            else:
                stats = fsearch(res)
                embed = Embed(title=f"__{player.display_name}'s Stats__",
                              colour=player.colour,
                              timestamp=datetime.utcnow(),
                              description=f"{stats}\n\u200b")
                # colour=ctx.author.colour,
                # colour = discord.Colour.purple(),
                embed.set_thumbnail(url=player.avatar_url)
                embed.set_footer(
                    text=f"Requested by:  {ctx.author.display_name}",
                    icon_url=ctx.author.avatar_url)
                await ctx.send(embed=embed)
Beispiel #3
0
    async def update_other(self, ctx, target: Greedy[Member], *args):
        if target == []:
            await ctx.send("Error: No player was mentioned.")
        else:
            split_target = str(target).split(' ')
            ids = [x[3:] for x in split_target if x[0:3] == 'id=']
            userID = int(ids[0])
            if ctx.author.id == userID or ctx.author.id == owner_id or ctx.author.id == st_id:
                my_result = query_user(userID, ctx.guild.id)
                player = ctx.author.guild.get_member(userID)

                if my_result is None:
                    result = _register(player, player.display_name, userID,
                                       player.guild.id, args)
                    if result == ():
                        await ctx.send(
                            f"""**__{player.display_name}__**'s basic player information has been registered in the database.
No character stats have been added yet. Please use `.update` or `.set` to enter your stats."""
                        )
                    else:
                        stats = fregister_results(result)
                        await ctx.send(
                            f"""**__{player.display_name}__**'s player information has been registered, and the following stats have been set:\n{stats}"""
                        )

                elif my_result is not None:
                    res = _update(userID, player.guild.id, args)
                    if res == 'Invalid':
                        await ctx.send(
                            """Uh oh! I couldn't find that stat. Try one or more of the following:
`hunger, humanity, stains, current willpower, total willpower, health, superficial damage, aggravated damage.`"""
                        )
                    else:
                        stats = fregister_results(res)
                        # TODO: maybe change it so it will show what the previous stat value was? E.g. Hunger updated from 2 to 3

                        embed = Embed(
                            title=f"__{player.display_name}'s Updated Stats__",
                            colour=player.colour,
                            timestamp=datetime.utcnow(),
                            description=f"{stats}\n\u200b")
                        embed.set_thumbnail(url=player.avatar_url)
                        await ctx.send(embed=embed)
            else:
                await ctx.send(
                    "Error: User is not authorized to change other people's stats."
                )
Beispiel #4
0
    async def register_full(self, ctx):
        my_result = query_user(ctx.author.id, ctx.guild.id)
        if my_result is not None:
            await ctx.send("Player is already registered in database.")
        elif my_result is None:
            await ctx.send(
                """Registering new character. Please provide, without brackets:
`(hunger), (humanity), (stains), (current willpower), (total willpower)`""")

            def check(msg):
                return msg.author == ctx.author and msg.channel == ctx.channel

            msg = await self.client.wait_for("message", check=check)
            rawinput = fregister_prompt(msg.content)
            result = _register(ctx.author, ctx.author.display_name,
                               ctx.author.id, ctx.author.guild.id, rawinput)
            # print(result)
            stats = fregister_results(result)
            await ctx.send(
                f"""**__{ctx.author.display_name}__**'s player information has been registered, and the following stats have been set:\n{stats}"""
            )
Beispiel #5
0
    async def update(self, ctx, *args):
        my_result = query_user(ctx.author.id, ctx.guild.id)
        invalid_msg = """Uh oh! I couldn't find that stat. Try one or more of the following:
`hunger, humanity, stains, current willpower, total willpower, health, superficial damage, aggravated damage`"""

        if my_result is None:
            result = _register(ctx.author, ctx.author.display_name,
                               ctx.author.id, ctx.author.guild.id, args)
            if result == 'Invalid':
                await ctx.send(invalid_msg)
                # This sends if the stat name was wrong AND/OR if the number isn't an integer value e.g. <3)>
                # So I may want to change the error message to reflect that it could be either of those

            elif result == ():
                await ctx.send(
                    f"""**__{ctx.author.display_name}__**'s basic player information has been registered in the database.
No character stats have been added yet. Please use `.update` or `.set` to enter your stats."""
                )
            else:
                stats = fregister_results(result)
                await ctx.send(
                    f"""**__{ctx.author.display_name}__**'s player information has been registered, and the following stats have been set:\n{stats}"""
                )

        elif my_result is not None:
            res = _update(ctx.author.id, ctx.author.guild.id, args)
            if res == 'Invalid':
                await ctx.send(invalid_msg)
            else:
                stats = fregister_results(res)
                # TODO: maybe change it so it will show what the previous stat value was? E.g. Hunger updated from 2 to 3

                embed = Embed(
                    title=f"__{ctx.author.display_name}'s Updated Stats__",
                    colour=ctx.author.colour,
                    timestamp=datetime.utcnow(),
                    description=f"{stats}\n\u200b")
                embed.set_thumbnail(url=ctx.author.avatar_url)
                await ctx.send(embed=embed)
Beispiel #6
0
    async def remove(self, ctx, target: Greedy[Member]):
        if target == []:
            userID = ctx.author.id
            player = ctx.author
        else:
            split_target = str(target).split(' ')
            ids = [x[3:] for x in split_target if x[0:3] == 'id=']
            userID = int(ids[0])
            player = ctx.author.guild.get_member(userID)

        my_result = query_user(userID, ctx.guild.id)
        if my_result is None:
            await ctx.send("Player is not registered in database.")

        else:
            await ctx.send(f'''
This command will **permanently delete** __{player.display_name}__ from the database. This action cannot be undone.\n
Please confirm by typing "yes". Type anything else to cancel.''')

            def check(msg):
                return msg.author == ctx.author and msg.channel == ctx.channel

            msg = await self.client.wait_for("message", check=check)
            confirmation = msg.content

            result = _delete_user(userID, ctx.guild.id, confirmation)

            if result == "Cancelled, user has not been deleted." or result[
                    0] == "Cancelled, user has not been deleted.":
                await ctx.send(result)
            elif result == 'Something went wrong' or result[
                    0] == 'Something went wrong':
                await ctx.send(result[0])
            else:
                await ctx.send(
                    f"{player.display_name} has been successfully deleted.")