用户:
白云上的刺客查看:25 回复:11 评论:25 创建时间:2022-07-20T12:03:34
(纯属自己写的,无抄袭,转载需标明作者:白云上的刺客)
const GUANLIYUAN = ['fRzKQhgmkrcLxafW'];
async function createAdminTable(){
await db.sql`
CREATE TABLE IF NOT EXISTS "admin" (
"name" TEXT NOT NULL,
"isAdmin" TEXT NOT NULL,
"isAuthor" TEXT NOT NULL,
"mutedTime" REAL NOT NULL,
"dangerTime" REAL NOT NULL,
"userKey" TEXT NOT NULL
)
`
}
async function poll(fn,msg) {
while (true) {
try {
return await fn()
} catch (e) {
const m = e.message
if (m.includes('timeout')) {
world.say(m)
}
else {
world.say(msg || e.stack)
}
}
await sleep(2000)
}
}
poll(createAdminTable,'管喵数据库启动中……')
async function getData(entity){
const row = await db.sql`SELECT * FROM "admin" WHERE "userKey"=${entity.player.userKey}`
if(row && row.length==0){
return null;
}
return row[0];
}
async function insertToAdmin(entity){
if(GUANLIYUAN.includes(entity.player.userKey)){
await db.sql`INSERT INTO "admin" ("name","isAdmin","isAuthor","mutedTime","dangerTime","userKey") VALUES (${entity.player.name},${String('否')},${String('是')},${Number(0)},${Number(0)},${entity.player.userKey})`
}else{
await db.sql`INSERT INTO "admin" ("name","isAdmin","isAuthor","mutedTime","dangerTime","userKey") VALUES (${entity.player.name},${String('否')},${String('否')},${Number(0)},${Number(0)},${entity.player.userKey})`
}
}
async function updatePlayerName(entity,name){
try{
await db.sql`UPDATE "admin" SET "name" = ${name} WHERE "userKey" = ${entity.player.name}`
}catch(error){
console.log(error)
}
}
async function updatePlayerMuted(userKey_player,muted){
try{
await db.sql`UPDATE "admin" SET "mutedTime" = ${muted} WHERE "userKey" = ${userKey_player}`
}catch(error){
console.log(error)
}
}
async function updatePlayerDanger(entityUserKey,danger){
try{
await db.sql`UPDATE "admin" SET "dangerTime" = ${danger} WHERE "userKey" = ${entityUserKey}`
}catch(error){
console.log(error)
}
}
async function findAdmin(entityUserKey,what){
try{
for await(const i of db.sql`SELECT * FROM "admin" WHERE "userKey"=${entityUserKey}`){
if(what == '管喵'){
if(i.isAdmin == '是'){
return true;
}else{
return false;
}
}else if(what == '作者'){
if(i.isAuthor == '是'){
return true;
}else{
return false;
}
}
}
}catch(error){
console.log(error)
}
}
world.onPlayerJoin(async({entity})=>{
const getplayerData = await getData(entity)
if(getplayerData==null){
await insertToAdmin(entity)
}
await updatePlayerName(entity,entity.player.name)
while(1){
for await(const dan of db.sql`SELECT * FROM "admin" WHERE "userKey"=${entity.player.userKey}`){
if(dan.dangerTime!=0){
if(new Date().valueOf()>dan.dangerTime){
await db.sql`UPDATE "admin" SET "dangerTime" = 0 WHERE "userKey"=${entity.player.userKey}`
}else{
entity.player.kick()
}
}
if(dan.mutedTime!=0){
if(new Date().valueOf()>dan.mutedTime){
await db.sql`UPDATE "admin" SET "mutedTime" = 0 WHERE "userKey"=${entity.player.userKey}`
entity.muted=false
}else{
entity.player.muted=true
}
}else{
entity.player.muted=false
}
}
await sleep(1000)
}
})
world.onChat(async({entity,message})=>{
if(message == '/管理' && await findAdmin(entity.player.userKey,'管喵') == true || message == '/管理' && await findAdmin(entity.player.userKey,'作者')){
if(await findAdmin(entity.player.userKey,'管喵') == true || await findAdmin(entity.player.userKey,'作者') == true){
option=[]
if(await findAdmin(entity.player.userKey,'管喵')==true){
option=['封号','禁言','解禁','重启']
}
if(await findAdmin(entity.player.userKey,'作者')==true){
option=['封号','禁言','解禁','重启','控制台']
}
names = ['其他:查找名字']
user = []
for await(const pushName of db.sql`SELECT * FROM "admin"`){
names.push(pushName.name)
user.push(pushName.userKey)
}
const choose = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择操作',
options:option
})
if(choose == null || !choose) return;
switch(choose.value){
case '封号':
const one = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择封号的人',
options:names
})
if(one){
if(one.value == '其他:查找名字'){
const findName = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'请输入查找人的名字所包含的汉字(不限字数)',
confirmText:'确定'
})
if(findName){
findNames = []
finduser = []
for await(const some of db.sql`SELECT * FROM "admin" WHERE "name" LIKE ${'%'+findName+'%'}`){
findNames.push(some.name)
finduser.push(some.userKey)
}
if(findNames != ''){
const which = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'请选择玩家',
options:findNames
})
if(which){
const one_day_find = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择封'+which.value+'的天数',
options:['自己输入天数','喵','20','50','70','100','365','3650']
})
if(one_day_find){
if(one_day_find.value == '自己输入天数'){
const one_day_find_input = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'尊敬的'+entity.player.name+'请输入天数',
confirmText:'确定'
})
if(one_day_find_input){
if(typeof parseInt(one_day_find_input) != 'number' || Math.round(parseInt(one_day_find_input)) != one_day_find_input){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'请输入正确数字',
})
return;
}
if(await findAdmin(entity.player.userKey,'作者')==true){
if(await findAdmin(finduser[findNames.indexOf(which.value)],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能手残封了'+which.value,
})
}else{
world.say(which.value+'被作者:'+entity.player.name+'封号了'+parseInt(one_day_find_input)+'天')
await updatePlayerDanger(finduser[findNames.indexOf(which.value)],new Date().valueOf()+1000*60*60*24*parseInt(one_day_find_input))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == which.value){
e.player.kick()
}
})
}
}else if(await findAdmin(entity.player.userKey,'作者')==false){
if(await findAdmin(finduser[findNames.indexOf(which.value)],'管喵')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封管喵'+one.value,
})
}
if(await findAdmin(finduser[findNames.indexOf(which.value)],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封作者'+one.value,
})
}
else{
world.say(which.value+'被管喵:'+entity.player.name+'封号了'+parseInt(one_day_find_input)+'天')
await updatePlayerDanger(finduser[findNames.indexOf(which.value)],new Date().valueOf()+1000*60*60*24*parseInt(one_day_find_input))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == which.value){
e.player.kick()
}
})
}
}
}
}else{
if(await findAdmin(entity.player.userKey,'作者')==true){
if(await findAdmin(finduser[findNames.indexOf(which.value)],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能手残封了'+which.value,
})
}else{
world.say(one.value+'被作者:'+entity.player.name+'封号了'+parseInt(one_day_find.value)+'天')
await updatePlayerDanger(finduser[findNames.indexOf(which.value)],new Date().valueOf()+1000*60*60*24*parseInt(one_day_find.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == which.value){
e.player.kick()
}
})
}
}else if(await findAdmin(entity.player.userKey,'作者')==false){
if(await findAdmin(finduser[findNames.indexOf(which.value)],'管喵')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封管喵'+one.value,
})
}
if(await findAdmin(finduser[findNames.indexOf(which.value)],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封作者'+one.value,
})
}
else{
world.say(one.value+'被管喵:'+entity.player.name+'封号了'+parseInt(one_day_find.value)+'天')
await updatePlayerDanger(finduser[findNames.indexOf(which.value)],new Date().valueOf()+1000*60*60*24*parseInt(one_day_find.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == which.value){
e.player.kick()
}
})
}
}
}
}
}
}else{
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'查找不到名字里含有'+findName+'的玩家',
})
}
}
}else{
const one_day = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择封'+one.value+'的天数',
options:['自己输入天数','喵','20','50','70','100','365','3650']
})
if(one_day){
if(one_day.value == '自己输入天数'){
const one_day_input = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'尊敬的'+entity.player.name+'请输入天数',
confirmText:'确定'
})
if(one_day_input){
if(typeof parseInt(one_day_input) != 'number'|| Math.round(parseInt(one_day_input)) != one_day_input){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'请输入正确数字',
})
return;
}
if(await findAdmin(entity.player.userKey,'作者')==true){
if(await findAdmin(user[names.indexOf(one.value)-1],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能手残封了'+one.value,
})
}else{
world.say(one.value+'被作者:'+entity.player.name+'封号了'+parseInt(one_day_input)+'天')
await updatePlayerDanger(user[names.indexOf(one.value)-1],new Date().valueOf()+1000*60*60*24*parseInt(one_day_input.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == one.value){
e.player.kick()
}
})
}
}else if(await findAdmin(entity.player.userKey,'作者')==false){
if(await findAdmin(user[names.indexOf(one.value)-1],'管喵')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封管喵'+one.value,
})
}
if(await findAdmin(user[names.indexOf(one.value)-1],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封作者'+one.value,
})
}
else{
world.say(one.value+'被管喵:'+entity.player.name+'封号了'+parseInt(one_day.value)+'天')
await updatePlayerDanger(user[names.indexOf(one.value)-1],new Date().valueOf()+1000*60*60*24*parseInt(one_day_input.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == one.value){
e.player.kick()
}
})
}
}
}
}else{
if(await findAdmin(entity.player.userKey,'作者')==true){
if(await findAdmin(user[names.indexOf(one.value)-1],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能手残封了'+one.value,
})
}else{
world.say(one.value+'被作者:'+entity.player.name+'封号了'+parseInt(one_day.value)+'天')
await updatePlayerDanger(user[names.indexOf(one.value)-1],new Date().valueOf()+1000*60*60*24*parseInt(one_day.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == one.value){
e.player.kick()
}
})
}
}else if(await findAdmin(entity.player.userKey,'作者')==false){
if(await findAdmin(user[names.indexOf(one.value)-1],'管喵')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封管喵'+one.value,
})
}
if(await findAdmin(user[names.indexOf(one.value)-1],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封作者'+one.value,
})
}
else{
world.say(one.value+'被管喵:'+entity.player.name+'封号了'+parseInt(one_day.value)+'天')
await updatePlayerDanger(user[names.indexOf(one.value)-1],new Date().valueOf()+1000*60*60*24*parseInt(one_day.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == one.value){
e.player.kick()
}
})
}
}
}
}
}
}
break;
case '禁言':
const two = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择人',
options:names
})
if(two){
if(two.value == '其他:查找名字'){
const findName_two = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'请输入查找人的名字所包含的汉字(不限字数)',
confirmText:'确定'
})
if(findName_two){
findNames2 = []
finduser2 = []
for await(const some2 of db.sql`SELECT * FROM "admin" WHERE "name" LIKE ${'%'+findName_two+'%'}`){
findNames2.push(some2.name)
finduser2.push(some2.userKey)
}
if(findNames2 != ''){
const which2 = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'请选择玩家',
options:findNames2
})
if(which2){
const two_day_find = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择时间',
options:['自己输入天数','喵','20','50','70','100','365','3650']
})
if(two_day_find){
if(two_day_find.value == '自己输入天数'){
const two_day_find_input = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'请输入天数',
})
if(two_day_find_input){
if(typeof parseInt(two_day_find_input) != 'number'|| Math.round(parseInt(two_day_find_input)) != one_day_find_input){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'请输入正确数字',
})
return;
}
if(await findAdmin(entity.player.userKey,'作者')==true){
if(await findAdmin(finduser2[findNames2.indexOf(which2.value)],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能手残封了'+which2.value,
})
}else{
world.say(which2.value+'被作者:'+entity.player.name+'禁言了'+parseInt(two_day_find_input)+'天')
await updatePlayerMuted(finduser2[findNames2.indexOf(which2.value)],new Date().valueOf()+1000*60*60*24*parseInt(two_day_find_input))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == which2.value){
e.player.muted=true
}
})
}
}else if(await findAdmin(entity.player.userKey,'作者')==false){
if(await findAdmin(finduser2[findNames2.indexOf(which2.value)],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封作者'+which2.value,
})
}if(await findAdmin(user[names.indexOf(two.value)-1],'管喵')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封管喵'+which2.value,
})
}else{
world.say(which2.value+'被作者:'+entity.player.name+'禁言了'+parseInt(two_day_find_input)+'天')
await updatePlayerMuted(finduser2[findNames2.indexOf(which2.value)],new Date().valueOf()+1000*60*60*24*parseInt(two_day_find_input))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == which2.value){
e.player.muted=true
}
})
}
}
}
}else{
if(await findAdmin(entity.player.userKey,'作者')==true){
if(await findAdmin(finduser2[findNames2.indexOf(which2.value)],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能手残封了'+which2.value,
})
}else{
world.say(two.value+'被作者:'+entity.player.name+'禁言了'+parseInt(two_day_find.value)+'天')
await updatePlayerMuted(finduser2[findNames2.indexOf(which2.value)],new Date().valueOf()+1000*60*60*24*parseInt(two_day_find.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == which2.value){
e.player.muted=true
}
})
}
}else if(await findAdmin(entity.player.userKey,'作者')==false){
if(await findAdmin(finduser2[findNames2.indexOf(which2.value)],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封作者'+which2.value,
})
}if(await findAdmin(finduser2[findNames2.indexOf(which2.value)],'管喵')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封管喵'+which2.value,
})
}else{
world.say(two.value+'被作者:'+entity.player.name+'禁言了'+parseInt(two_day_find.value)+'天')
await updatePlayerMuted(finduser2[findNames2.indexOf(which2.value)],new Date().valueOf()+1000*60*60*24*parseInt(two_day_find.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == which2.value){
e.player.muted=true
}
})
}
}
}
}
}
}else{
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'查找不到名字里含有'+findName_two+'的玩家',
})
}
}
}else{
const two_day = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择时间',
options:['自己输入天数','喵','20','50','70','100','365','3650']
})
if(two_day){
if(two_day.value == '自己输入天数'){
const two_day_input = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'请输入天数',
})
if(two_day_input){
if(typeof parseInt(two_day_input) != 'number'|| Math.round(parseInt(two_day_input)) != one_day_input){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'请输入正确数字',
})
return;
}
if(await findAdmin(entity.player.userKey,'作者')==true){
if(await findAdmin(user[names.indexOf(two.value)-1],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能手残封了'+two.value,
})
}else{
world.say(two.value+'被作者:'+entity.player.name+'禁言了'+parseInt(two_day_input)+'天')
await updatePlayerMuted(user[names.indexOf(two.value)-1],new Date().valueOf()+1000*60*60*24*parseInt(two_day_input))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == two.value){
e.player.muted=true
}
})
}
}else if(await findAdmin(entity.player.userKey,'作者')==false){
if(await findAdmin(user[names.indexOf(two.value)-1],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封作者'+two.value,
})
}if(await findAdmin(user[names.indexOf(two.value)-1],'管喵')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封管喵'+two.value,
})
}else{
world.say(two.value+'被作者:'+entity.player.name+'禁言了'+parseInt(two_day_input)+'天')
await updatePlayerMuted(user[names.indexOf(two.value)-1],new Date().valueOf()+1000*60*60*24*parseInt(two_day_input))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == two.value){
e.player.muted=true
}
})
}
}
}
}else{
if(await findAdmin(entity.player.userKey,'作者')==true){
if(await findAdmin(user[names.indexOf(two.value)-1],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能手残封了'+two.value,
})
}else{
world.say(two.value+'被作者:'+entity.player.name+'禁言了'+parseInt(two_day.value)+'天')
await updatePlayerMuted(user[names.indexOf(two.value)-1],new Date().valueOf()+1000*60*60*24*parseInt(two_day.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == two.value){
e.player.muted=true
}
})
}
}else if(await findAdmin(entity.player.userKey,'作者')==false){
if(await findAdmin(user[names.indexOf(two.value)-1],'作者')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封作者'+two.value,
})
}if(await findAdmin(user[names.indexOf(two.value)-1],'管喵')==true){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你不能封管喵'+two.value,
})
}else{
world.say(two.value+'被作者:'+entity.player.name+'禁言了'+parseInt(two_day.value)+'天')
await updatePlayerMuted(user[names.indexOf(two.value)-1],new Date().valueOf()+1000*60*60*24*parseInt(two_day.value))
world.querySelectorAll('player').forEach((e)=>{
if(e.player.name == two.value){
e.player.muted=true
}
})
}
}
}
}
}
}
break;
case '解禁':
const three = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择人',
options:names
})
if(three){
if(three.value == '其他:查找名字'){
const three_findName = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'请输入查找人的名字所包含的汉字(不限字数)',
confirmText:'确定'
})
if(three_findName){
three_findNames = []
three_finduser = []
for await(const some1 of db.sql`SELECT * FROM "admin" WHERE "name" LIKE ${'%'+three_findName+'%'}`){
three_findNames.push(some1.name)
three_finduser.push(some1.userKey)
}
if(three_findNames != ''){
const three_no = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'尊敬的'+entity.player.name+',请选择人',
options:three_findNames
})
if(three_no){
await updatePlayerDanger(three_finduser[three_findNames.indexOf(three_no.value)],0)
await updatePlayerMuted(three_finduser[three_findNames.indexOf(three_no.value)],0)
world.say(three_no.value+'被管喵解禁了')
}
}else{
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'查找不到名字里含有'+three_findName+'的玩家',
})
}
}
}else{
await updatePlayerDanger(user[names.indexOf(three.value)-1],0)
await updatePlayerMuted(user[names.indexOf(three.value)-1],0)
world.say(three.value+'被管喵解禁了')
}
}
break;
case '重启':
world.say(entity.player.name+'进行了重启')
await sleep(1000)
while(1){}
break;
case '控制台':
const five = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'尊敬的'+entity.player.name+',请输入代码',
confirmText:'确定'
})
if(five){
try{
const code = eval(five)
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'<~'+code
})
}catch(error){
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'代码错误!\n'+error
})
}
}
break;
default:
return;
}
}
}
})
有BUG评论区里讲,勿骂人,勿喵
白云上的刺客world.onChat(async({entity,message})=>{
if(message.startsWith('@添加管喵') && GUANLIYUAN.includes(entity.player.userKey)){
canInsert=['其他:查找名字']
canInsertuser=[]
for await(const findHave of db.sql`SELECT * FROM "admin"`){
if(findHave.isAdmin != '是' && findHave.isAuthor != '是'){
canInsert.push(findHave.name)
canInsertuser.push(findHave.userKey)
}
}
if(canInsert != ['其他:查找名字']){
const insert = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'选择一个人',
options:canInsert
})
if(insert){
if(insert.value == '其他:查找名字'){
const insert_find = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'请输入ta名字所包含的字符(可以全名)',
confirmText:'确定'
})
if(insert_find){
insert_findName = []
insert_findUser = []
for await(const insertSome of db.sql`SELECT * FROM "admin"`){
if(insertSome.isAdmin != '是' && insertSome.isAuthor != '是'){
insert_findName.push(insertSome.name)
insert_findUser.push(insertSome.userKey)
}
}
if(insert_findName){
const insert_find_who = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'选择一个人',
options:insert_findName
})
if(insert_find_who){
const insert_find_ok = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'是否将'+insert_find_who+'添加为管喵?',
options:['是','否']
})
if(insert_find_ok.value=='是'){
await db.sql`UPDATE "admin" SET "isAdmin" = '是' WHERE "userKey" = ${insert_findUser[insert_findName.indexOf(insert_find_who)]}`
world.say(insert_find_who.value+'被添加为管喵,记得不要乱用权限')
}
}
}else{
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'没有名字包含'+insert_find+'的人'
})
}
}
}else{
const insertOK = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'确定将'+insert.value+'添加为管喵?',
options:['是','不了']
})
if(insertOK){
if(insertOK.value=='是'){
await db.sql`UPDATE "admin" SET "isAdmin" = '是' WHERE "userKey" = ${canInsertuser[canInsert.indexOf(insert.value)-1]}`
world.say(insert.value+'被添加为管喵,记得不要乱用权限')
}
}
}
}
}else{
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'没有新的人了'
})
}
}
if(message.startsWith('@删除管喵') && GUANLIYUAN.includes(entity.player.userKey)){
canInsert=['其他:查找名字']
canInsertuser=[]
for await(const findHave of db.sql`SELECT * FROM "admin"`){
if(findHave.isAdmin == '是' && findHave.isAuthor != '是'){
canInsert.push(findHave.name)
canInsertuser.push(findHave.userKey)
}
}
if(canInsert != ['其他:查找名字']){
const insert = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'选择一个人',
options:canInsert
})
if(insert){
if(insert.value == '其他:查找名字'){
const insert_find = await entity.player.dialog({
type:Box3DialogType.INPUT,
title:'系统',
content:'请输入ta名字所包含的字符(可以全名)',
confirmText:'确定'
})
if(insert_find){
insert_findName = []
insert_findUser = []
for await(c喵t insertSome of db.sql`SELECT * FROM "admin"`){
if(insertSome.isAdmin == '是' && insertSome.isAuthor != '是'){
insert_findName.push(insertSome.name)
insert_findUser.push(insertSome.userKey)
}
}
if(insert_findName != ''){
c喵t insert_find_who = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'选择一个人',
opti喵:insert_findName
})
if(insert_find_who){
c喵t insert_find_ok = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'是否将'+insert_find_who+'从管理员列表删除?',
opti喵:['是','否']
})
if(insert_find_ok.value=='是'){
await db.sql`UPDATE "admin" SET "isAdmin" = '否' WHERE "userKey" = ${insert_findUser[insert_findName.indexOf(insert_find_who)]}`
world.say(insert_find_who.value+'被撤销管理员职位')
}
}
}else{
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'没有名字包含'+insert_find+'的管理员'
})
}
}
}else{
c喵t insertOK = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:'系统',
content:'确定将'+insert.value+'从管理员列表删除?',
opti喵:['是','不了']
})
if(insertOK){
if(insertOK.value=='是'){
await db.sql`UPDATE "admin" SET "isAdmin" = '否' WHERE "userKey" = ${canInsertuser[canInsert.indexOf(insert.value)-1]}`
world.say(insert.value+'被撤销管理员职位')
}
}
}
}
}else{
await entity.player.dialog({
type:Box3DialogType.TEXT,
title:'系统',
content:'你没有添加任何管理员'
})
}
}
})点赞0
评论