getuser returns promise and guildcreate event implemented
This commit is contained in:
@ -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)
|
||||
});
|
||||
}
|
||||
|
7
index.js
7
index.js
@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user