Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

消息接受类增加event.isCommand()判断是否指令 #40

Closed
smallshen opened this issue Apr 21, 2020 · 5 comments
Closed

消息接受类增加event.isCommand()判断是否指令 #40

smallshen opened this issue Apr 21, 2020 · 5 comments
Labels

Comments

@smallshen
Copy link

使用指令的同时也算一条消息,没有东西判断这条消息是否为指令。
希望增加 method .isCommand(); return boolen;用来判断该消息是否为指令。
或者直接舍弃,如果是指令只触发指令的listener不触发消息的listener。

@hykilpikonna
Copy link
Member

hykilpikonna commented Apr 21, 2020

因为指令系统也是基于消息事件实现的啦w
( 就是说指令也是一个监听器w
去掉大概会好麻烦吧w

@smallshen
Copy link
Author

谢谢了!!!
如果能加一个event.isCommand();会方便很多。

@hykilpikonna
Copy link
Member

刚才发错了, 刚才那个 this 是 CommandManager 啦w
看这个:

final boolean isGM = event instanceof EventGroupMessage;
final boolean isDM = event instanceof EventDiscussMessage;
final boolean isPM = event instanceof EventPrivateMessage;

try
{
    CommandArgsParser.parse(event.getBot().getCommandManager(), event.getMessage(), isDM || isGM);
}
catch (NotACommandException | CommandNotFoundException e)
{
    // 不是指令
    return;
}

@smallshen
Copy link
Author

谢谢

@smallshen smallshen reopened this Apr 21, 2020
@smallshen
Copy link
Author

希望下一个版本这个能变成一个method

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants