getuser returns promise and guildcreate event implemented

This commit is contained in:
2023-04-24 21:29:17 +02:00
parent d2d97c54fc
commit 20159c0379
2 changed files with 13 additions and 2 deletions

View File

@ -41,7 +41,13 @@ let GetUser = async (sql, server, user) => {
throw `could not create user on server ${server} with userid ${user} due to error: ` + error
}
// results will contain the results of the query
return results[0];
return new Promise((resolve, reject) => {
if (results[0] != undefined) {
resolve(results[0]);
} else {
reject("user not found");
}
})
// fields will contain information about the returned results fields (if any)
});
}

View File

@ -11,7 +11,7 @@ let token = process.env.TOKEN;
const rest = new REST({ version: '10' }).setToken(token);
const ws = new WebSocketManager({
token,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent | GatewayIntentBits.GuildMembers | GatewayIntentBits.Guilds,
rest,
});
@ -71,5 +71,10 @@ bot.on(GatewayDispatchEvents.MessageReactionRemove, async (reaction, user) => {
HandleReaction(reaction, user, server, "remove", bot)
});
bot.on(GatewayDispatchEvents.GuildCreate, async ( guild) => {
console.log(guild.data.id)
console.log(await guild.api.guilds.getMembers(guild.data.id))
})
ws.connect();