Skip to content

Commit

Permalink
+ 优化帮助命令介绍
Browse files Browse the repository at this point in the history
+ 添加列出所有自定义cmd的命令
  • Loading branch information
cnlimiter committed Jan 24, 2023
1 parent 248e777 commit 42416ee
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,28 @@ public static int execute(CommandContext<CommandSourceStack> context) throws Com
群服互联使用说明:
如果你是第一次使用请按照以下步骤设置
1.请先开启机器人框架,go-cqhttp或者mirai
1.请先选择机器人框架,go-cqhttp或者mirai
2.请使用/mcbot addGroup <GroupId> 添加互通的群
3.请使用/mcbot setBot <BotId> 设置机器人的qq号
4.如果使用的是onebot-mirai,同时打开了VerifyKey验证,请输入/mcbot setVerifyKey <VerifyKey> 设置
4.如果使用的是onebot-mirai,并且打开了VerifyKey验证,请输入/mcbot setVerifyKey <VerifyKey> 设置
5.准备工作完成,请使用/mcbot connect <cqhttp/mirai> <host:port> 与框架对接
*************************************
在框架默认配置下,请使用/mcbot connect <cqhttp/mirai>
如果使用的cqhttp,配置完cqhttp后,本模组会自动连接
*************************************
全部命令:
/mcbot connect <cqhttp/mirai> <host:port>
/mcbot setFrame <cqhttp/mirai>
/mcbot addGroup <GroupId>
/mcbot removeGroup <GroupId>
/mcbot setBot <BotId>
/mcbot setVerifyKey <VerifyKey>
/mcbot setFrame <cqhttp/mirai> 默认cqhttp
/mcbot addGroup <GroupId> 添加群
/mcbot removeGroup <GroupId> 删除群
/mcbot setBot <BotId> 设置机器人id
/mcbot setVerifyKey <VerifyKey> mirai可能用
/mcbot receive <all|chat|cmd> <true|false>
/mcbot send <all|join|leave|death|achievements|welcome> <true|false>
/mcbot status
/mcbot help
/mcbot status 机器人状态
/mcbot help 帮助
/mcbot reload 重载配置
/mcbot customs 列出所有自定义命令
*************************************
感谢您的支持,如有问题请联系我
QQ群:720975019找群主
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cn.evolvefield.mods.botapi.common.command;


import cn.evolvefield.mods.botapi.init.handler.CustomCmdHandler;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;

public class ListCustomCommand {

public static int execute(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
StringBuilder out = new StringBuilder();
for (String s : CustomCmdHandler.INSTANCE.getCustomCmdMap().keySet()) {
out.append(s).append("\n");
}
context.getSource().sendSuccess(Component.literal(out.toString()), true);
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static void init() {
)

)
.then(Commands.literal("customs").executes(ListCustomCommand::execute))
.then(Commands.literal("reload").executes(ReloadConfigCmd::execute))
.then(Commands.literal("disconnect").executes(DisconnectCommand::execute))
.then(Commands.literal("setGuild")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,31 @@ public void writeDefault() {
json.addProperty("role", 0);
json.addProperty("enable", true);

var json2 = new JsonObject();
json.addProperty("alies", "say");
json.addProperty("content", "say %");
json.addProperty("role", 1);
json.addProperty("enable", true);

FileWriter writer = null;
FileWriter writer2 = null;

try {
var file = new File(dir, "list.json");
var file2 = new File(dir, "say.json");
writer = new FileWriter(file);
writer2 = new FileWriter(file2);

GSON.toJson(json, writer);
GSON.toJson(json2, writer2);

writer.close();
writer2.close();
} catch (Exception e) {
Static.LOGGER.error("An error occurred while generating default custom cmd", e);
} finally {
IOUtils.closeQuietly(writer);
IOUtils.closeQuietly(writer2);
}

}
Expand Down

0 comments on commit 42416ee

Please sign in to comment.