put COMMAND context to EVAL context
This commit is contained in:
parent
d06ca203ae
commit
6156620a0c
1 changed files with 6 additions and 0 deletions
|
@ -1,10 +1,12 @@
|
||||||
package me.chayapak1.chomens_bot.commands;
|
package me.chayapak1.chomens_bot.commands;
|
||||||
|
|
||||||
|
import me.chayapak1.chomens_bot.Bot;
|
||||||
import me.chayapak1.chomens_bot.command.Command;
|
import me.chayapak1.chomens_bot.command.Command;
|
||||||
import me.chayapak1.chomens_bot.command.CommandContext;
|
import me.chayapak1.chomens_bot.command.CommandContext;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.luaj.vm2.LuaValue;
|
import org.luaj.vm2.LuaValue;
|
||||||
|
import org.luaj.vm2.lib.jse.CoerceJavaToLua;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -36,6 +38,10 @@ public class ServerEvalCommand implements Command {
|
||||||
|
|
||||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||||
try {
|
try {
|
||||||
|
final Bot bot = context.bot();
|
||||||
|
|
||||||
|
bot.eval().globals().set("context", CoerceJavaToLua.coerce(context));
|
||||||
|
|
||||||
final LuaValue output = context.bot().eval().run(String.join(" ", args));
|
final LuaValue output = context.bot().eval().run(String.join(" ", args));
|
||||||
|
|
||||||
context.sendOutput(Component.text(output.toString()).color(NamedTextColor.GREEN));
|
context.sendOutput(Component.text(output.toString()).color(NamedTextColor.GREEN));
|
||||||
|
|
Loading…
Reference in a new issue