本文整理汇总了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!");
}
}
示例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!");
}
}