[api/commands] Resupport execute return
This commit is contained in:
parent
1e41fe3601
commit
9fbbf5bb2f
1 changed files with 15 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { ApplicationCommand, ApplicationCommandInputType, ApplicationCommandType } from "@lib/api/commands/types";
|
||||
import { after } from "@lib/api/patcher";
|
||||
import { commands as commandsModule } from "@metro/common";
|
||||
import { after, instead } from "@lib/api/patcher";
|
||||
import { logger } from "@lib/utils/logger";
|
||||
import { commands as commandsModule, messageUtil } from "@metro/common";
|
||||
|
||||
let commands: ApplicationCommand[] = [];
|
||||
|
||||
|
|
@ -48,6 +49,18 @@ export function registerCommand(command: ApplicationCommand): () => void {
|
|||
opt.displayDescription ??= opt.description;
|
||||
}
|
||||
|
||||
instead("execute", command, (args, orig) => {
|
||||
Promise.resolve(
|
||||
orig.apply(command, args)
|
||||
).then(ret => {
|
||||
if (ret && typeof ret === "object") {
|
||||
messageUtil.sendMessage(args[1].channel.id, ret);
|
||||
}
|
||||
}).catch(err => {
|
||||
logger.error("Failed to execute command", err);
|
||||
});
|
||||
});
|
||||
|
||||
// Add it to the commands array
|
||||
commands.push(command);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue