32 lines
701 B
JavaScript
32 lines
701 B
JavaScript
import { myCache } from "../cache/index.js";
|
|
import { client } from "./base.js";
|
|
|
|
export async function getRole(guildId) {
|
|
if(!myCache.get("roleList")){
|
|
let { data } = await client.roleApi.roles(guildId);
|
|
myCache.set("roleList",data)
|
|
return data
|
|
}else{
|
|
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
|
|
}
|
|
}
|
|
}
|
|
|