add roles
This commit is contained in:
		
							parent
							
								
									26a4c93ee1
								
							
						
					
					
						commit
						e502f72858
					
				@ -10,4 +10,22 @@ export async function getRole(guildId) {
 | 
			
		||||
        console.log("缓存命中")
 | 
			
		||||
        return myCache.get("roleList")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export async function getGuild(name){
 | 
			
		||||
    let { data } = await client.meApi.meGuilds();
 | 
			
		||||
 | 
			
		||||
    // return data.forEach((item)=>{
 | 
			
		||||
    //     // return
 | 
			
		||||
    //     if(item.name == name){
 | 
			
		||||
    //         return item.id
 | 
			
		||||
    //     }
 | 
			
		||||
    // })
 | 
			
		||||
    for(const i of data){
 | 
			
		||||
        if(i.name == name){
 | 
			
		||||
            return i.id
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -10,6 +10,7 @@
 | 
			
		||||
    "mitt": "^3.0.0",
 | 
			
		||||
    "mysql": "^2.18.1",
 | 
			
		||||
    "node-cache": "^5.1.2",
 | 
			
		||||
    "node-schedule": "^2.1.0",
 | 
			
		||||
    "qq-guild-bot": "^2.9.4"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,36 @@
 | 
			
		||||
import dayjs from "dayjs"
 | 
			
		||||
import { getRole } from "../../bin/channel-core/tools.js"
 | 
			
		||||
import { client } from "../../bin/channel-core/base.js"
 | 
			
		||||
import { getGuild, getRole } from "../../bin/channel-core/tools.js"
 | 
			
		||||
import { onMessageCreate } from "../../bin/message/index.js"
 | 
			
		||||
import { query } from "../../bin/mysql/base.js"
 | 
			
		||||
import { addouter } from "../../bin/server/base.js"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async function getActiveList(){
 | 
			
		||||
    const sql = `select  userid,count(*) from active where date_sub(curdate(), INTERVAL 30 DAY) <= date(activedate) GROUP BY userid`
 | 
			
		||||
    const list = await query(sql)
 | 
			
		||||
    console.log(list)
 | 
			
		||||
    let user = []
 | 
			
		||||
    for(let i of list){
 | 
			
		||||
        if(i["count(*)"] > 2){
 | 
			
		||||
            user.push(i.userid)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return user
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async function setrole(){
 | 
			
		||||
    const gid = await getGuild("web前端")
 | 
			
		||||
    const list = await getActiveList()
 | 
			
		||||
    console.log(list,24)
 | 
			
		||||
    for(let i of list){
 | 
			
		||||
        let { data } = await client.memberApi.memberAddRole(gid, "10868905", i);
 | 
			
		||||
    }
 | 
			
		||||
    console.log(list)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async function getlist(){
 | 
			
		||||
    const list = await query("select * from active")
 | 
			
		||||
    return list
 | 
			
		||||
@ -105,6 +132,10 @@ function createMessage({msg}){
 | 
			
		||||
}
 | 
			
		||||
onMessageCreate(createMessage)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// getRole()
 | 
			
		||||
 | 
			
		||||
// const res = await activeCount('384023542260794903')
 | 
			
		||||
// console.log(res)
 | 
			
		||||
setrole()
 | 
			
		||||
init()
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user