Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Apr 12, 2024
1 parent caf0b48 commit 3facb21
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.minecraftchampions.dodoopenjava.api;

import io.github.minecraftchampions.dodoopenjava.permission.Permission;
import lombok.NonNull;
import org.json.JSONObject;

Expand Down Expand Up @@ -162,4 +163,16 @@ public interface Island {
* @return Channel
*/
Channel createChannel(int channelType);

/**
* 创建身分组
* 可传 null
*
* @param roleName name
* @param roleColor color
* @param position 权重
* @param permission 权限
* @return role
*/
Role createRole(String roleName, String roleColor, int position, Permission permission);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.github.minecraftchampions.dodoopenjava.Result;
import io.github.minecraftchampions.dodoopenjava.api.*;
import io.github.minecraftchampions.dodoopenjava.permission.Permission;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONArray;
Expand Down Expand Up @@ -333,7 +334,7 @@ public Role getRole(@NonNull String roleId) {
public Channel createChannel(@NonNull String channelName, int channelType) {
Result result = bot.getApi().V2.getChannelApi().addChannel(getIslandSourceId(), channelName, channelType);
if (result.isFailure()) {
log.error("创建失败, 错误消息:{};状态code:{};错误数据:{}", result.getMessage(), result.getStatusCode(), result.getJSONObjectData());
log.error("创建频道失败, 错误消息:{};状态code:{};错误数据:{}", result.getMessage(), result.getStatusCode(), result.getJSONObjectData());
return null;
}
return new ChannelImpl(result.getJSONObjectData().getString("channelId"), getIslandSourceId(), bot);
Expand All @@ -343,4 +344,14 @@ public Channel createChannel(@NonNull String channelName, int channelType) {
public Channel createChannel(int channelType) {
return createChannel(null, channelType);
}

@Override
public Role createRole(String roleName, String roleColor, int position, Permission permission) {
Result result = bot.getApi().V2.getRoleApi().addRole(getIslandSourceId(), roleName, roleColor, position, permission);
if (result.isFailure()) {
log.error("创建身份组失败, 错误消息:{};状态code:{};错误数据:{}", result.getMessage(), result.getStatusCode(), result.getJSONObjectData());
return null;
}
return new RoleImpl(result.getJSONObjectData().getString("roleId"), getIslandSourceId(), bot);
}
}

0 comments on commit 3facb21

Please sign in to comment.