chore: initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import type {Bot} from '@wp2508/mineflayer';
|
||||
import type {BaseFunction, FunctionArgument} from '../../../types/bot/function/function.ts';
|
||||
|
||||
export class init implements BaseFunction<[]> {
|
||||
readonly name = 'close_current_window';
|
||||
readonly i18n = {
|
||||
lang: 'zh-CN', name: '关闭当前窗口', description: '关闭当前打开的容器窗口;没有打开窗口时直接成功',
|
||||
};
|
||||
readonly args: FunctionArgument[] = [];
|
||||
|
||||
async run(bot: Bot, args: []): Promise<boolean> {
|
||||
if (!Array.isArray(args) || args.length !== 0) return false;
|
||||
const window = bot.currentWindow;
|
||||
if (!window) return true;
|
||||
try {
|
||||
await bot.closeWindow(window);
|
||||
return bot.currentWindow == null;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user