用户:
145a查看:1 回复:5 评论:1 创建时间:2022-07-31T17:32:20
const adminList=["这里是管喵列表,填名字"];world.onChat(async({entity:{player:{name:name}},message:message})=>{if(message.startsWith("$")&&adminList.includes(name)){let c=message.slice(1);world.say(`~> ${c}`);try{c=await eval(`!async function(){${c}}`)}catch(a){c=a}finally{world.say(`<~ ${c}`)}}});
啾咪啾咪!const adminList=["这里是管喵列表,填名字"];
world.onChat(async({entity:{player:{name:name}},message:message})=>{
if(message.startsWith("$")&&adminList.includes(name)){
let c=message.slice(1);
world.say(`~> ${c}`);
try{
c=await eval(`!async function(){${c}}`)
}
catch(a){
c=a
}
finally{
world.say(`<~ ${c}`)
}
}
});点赞0
评论
七式草莓请注意执行的代码不能为多条语句(即包含分号),否则会出bug
const adminList = ["这里是管喵列表,填名字"];
world.onChat(async ({ entity, message }) => {
if (message.startsWith("$") && adminList.includes(entity.player.name)) {
var result = message.slice(1)
var text = ''
var error = false
if (result.includes('await')) {
try {
text = await eval(`(async() => {return ${result}})()`)
} catch (err) {
if (err.name == 'SyntaxError') {
try {
text = await eval(`(async() => {${result}})()`)
} catch (err) {
text = err, error = true
}
} else {
text = err, error = true
}
}
} else {
try {
text = eval(`${result}`)
} catch (err) {
text = err, error = true
}
}
try {
text = text.valueOf()
} catch (err) { }
if (typeof text == 'object' && !error) {
try {
text = JSON.stringify(text)
} catch (err) { }
}
world.say('<~ ' + text)
}
});点赞0
评论