ui_embed.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:modis 作者: Infraxion 项目源码 文件源码
def user_warning(channel, user, warnings, max_warnings):
    """
    Creates an embed UI containing an user warning message

    Args:
        channel (discord.Channel): The Discord channel to bind the embed to
        user (discord.User): The user to warn
        warnings (str): The warnings for the user
        max_warnings (str): The maximum warnings for the user

    Returns:
        ui (ui_embed.UI): The embed UI object
    """

    username = user.name
    if isinstance(user, discord.Member):
        if user.nick is not None:
            username = user.nick

    warning_count_text = "warnings" if warnings != 1 else "warning"
    warning_text = "{} {}".format(warnings, warning_count_text)
    result_text = "at {} you will be banned".format(max_warnings)
    if warnings >= max_warnings:
        result_text = "you are being banned because you have more than the maximum warnings"

    # Create embed UI object
    gui = ui_embed.UI(
        channel,
        "Warning {}".format(username),
        "You now have {} {}, {}".format(warning_text, username, result_text),
        modulename=modulename
    )

    return gui
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号