import d20

class MyStringifier(d20.MarkdownStringifier):

    def _str_expression(self, node):

        if node.comment == None:
            resultText = "Result"
        else:
            resultText = node.comment.capitalize()

        return f"**{resultText}**: {self._stringify(node.roll)}\n**Total**: {int(node.total)}"

def roll_dice(user, rollString):
    while len(rollString) > 1 and rollString[0] == " ":
        rollString = rollString[1:]
    return user+" :game_die:\n"+str(d20.roll(rollString, allow_comments=True,stringifier=MyStringifier()))



