当前位置: 首页>>代码示例>>Java>>正文


Java OnlineStatus.UNKNOWN属性代码示例

本文整理汇总了Java中net.dv8tion.jda.core.OnlineStatus.UNKNOWN属性的典型用法代码示例。如果您正苦于以下问题:Java OnlineStatus.UNKNOWN属性的具体用法?Java OnlineStatus.UNKNOWN怎么用?Java OnlineStatus.UNKNOWN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.dv8tion.jda.core.OnlineStatus的用法示例。


在下文中一共展示了OnlineStatus.UNKNOWN属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

@Override
protected void execute(CommandEvent event) {
    try {
        OnlineStatus status = OnlineStatus.fromKey(event.getArgs());
        if(status==OnlineStatus.UNKNOWN)
        {
            event.replyError("Please include one of the following statuses: `ONLINE`, `IDLE`, `DND`, `INVISIBLE`");
        }
        else
        {
            event.getJDA().getPresence().setStatus(status);
            event.replySuccess("Set the status to `"+status.getKey().toUpperCase()+"`");
        }
    } catch(Exception e) {
        event.reply(event.getClient().getError()+" The status could not be set!");
    }
}
 
开发者ID:jagrosh,项目名称:MusicBot,代码行数:17,代码来源:SetstatusCmd.java

示例2: Config

public Config() throws Exception
{
    List<String> lines = Files.readAllLines(Paths.get("config.txt"));
    for(String str : lines)
    {
        String[] parts = str.split("=",2);
        String key = parts[0].trim().toLowerCase();
        String value = parts.length>1 ? parts[1].trim() : null;
        switch(key) 
        {
            case "token":
                userToken = value;
                break;
            case "prefix":
                if(value==null)
                {
                    prefix = "";
                    LOG.warn("The prefix was defined as empty!");
                }
                else
                    prefix = value;
                break;
            case "timezone":
                if(value==null)
                {
                    zone = ZoneId.systemDefault();
                    LOG.warn("An empty timezone was provided; using the system default!");
                }
                else
                {
                    try {
                        zone = ZoneId.of(value);
                    } catch(Exception e) {
                        zone = ZoneId.systemDefault();
                        LOG.warn("\""+value+"\" is not a valid timezone; using the system default!");
                    }
                }
                break;
            case "status":
                status = OnlineStatus.fromKey(value);
                if(status == OnlineStatus.UNKNOWN)
                {
                    status = OnlineStatus.IDLE;
                    LOG.warn("\""+value+"\" is not a valid status; using the default IDLE! Valid statuses are ONLINE, IDLE, DND, and INVISIBLE.");
                }
                break;
            case "bot":
                bot = "true".equalsIgnoreCase(value);
        }
    }
    if(userToken==null)
        throw new Exception("No token provided int he config file!");
    if(prefix==null)
        throw new Exception("No prefix provided in the config file!");
    if(zone==null)
    {
        zone = ZoneId.systemDefault();
        LOG.warn("No timezone provided; using the system default!");
    }
    if(status==null)
    {
        status = OnlineStatus.IDLE;
        LOG.warn("No status provided; using IDLE!");
    }
}
 
开发者ID:jagrosh,项目名称:Selfbot,代码行数:65,代码来源:Config.java


注:本文中的net.dv8tion.jda.core.OnlineStatus.UNKNOWN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。