mirror of
https://github.com/cloudmaker97/Discord-Captcha-Verification.git
synced 2025-12-06 01:48:34 +00:00
Waiting for the caching state from discord client
This commit is contained in:
parent
d08bf65ef5
commit
ef9d2054d7
2 changed files with 112 additions and 101 deletions
|
|
@ -46,17 +46,21 @@ client.once(Events.ClientReady, readyClient => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
event.on('verification:success', (authenticationObject, internetProtocolAddress) => {
|
client.on('ready', () => {
|
||||||
console.log(authenticationObject.guildId)
|
console.log('Discord is connected and cached');
|
||||||
console.log(authenticationObject.userId)
|
event.emit('discord:ready');
|
||||||
let guild = client.guilds.cache.get(authenticationObject.guildId);
|
});
|
||||||
console.log(guild)
|
|
||||||
let member = guild.members.cache.get(authenticationObject.userId);
|
|
||||||
console.log(member)
|
|
||||||
if(member) {
|
|
||||||
member.roles.add(verifiedRoleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
event.on('verification:success', (authenticationObject, internetProtocolAddress) => {
|
||||||
|
client.guilds.fetch().then(async () => {
|
||||||
|
const guild = await client.guilds.fetch(authenticationObject.guildId);
|
||||||
|
const member = await guild.members.fetch(authenticationObject.userId);
|
||||||
|
const role = guild.roles.cache.get(verifiedRoleId);
|
||||||
|
|
||||||
|
if (role && member) {
|
||||||
|
member.roles.add(role)
|
||||||
|
.then(() => {
|
||||||
|
console.log(`Role ${role.name} has been added to ${member.user.tag}`)
|
||||||
let embedBuilder = new EmbedBuilder();
|
let embedBuilder = new EmbedBuilder();
|
||||||
embedBuilder.setTitle('Verifizierung abgeschlossen');
|
embedBuilder.setTitle('Verifizierung abgeschlossen');
|
||||||
embedBuilder.setFields([
|
embedBuilder.setFields([
|
||||||
|
|
@ -66,8 +70,13 @@ event.on('verification:success', (authenticationObject, internetProtocolAddress)
|
||||||
{ name: 'IP-Informationen', value: `[Informationen anzeigen](https://ipinfo.io/${internetProtocolAddress})`, inline: false },
|
{ name: 'IP-Informationen', value: `[Informationen anzeigen](https://ipinfo.io/${internetProtocolAddress})`, inline: false },
|
||||||
{ name: 'User-ID', value: `${member.id}`, inline: false },
|
{ name: 'User-ID', value: `${member.id}`, inline: false },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
client.channels.cache.get(channelLogsId).send({embeds: [embedBuilder]});
|
client.channels.cache.get(channelLogsId).send({embeds: [embedBuilder]});
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
|
} else {
|
||||||
|
console.log('Role or member not found');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
client.login(discordToken);
|
client.login(discordToken);
|
||||||
|
|
@ -6,8 +6,9 @@ const event = require('../events/index').eventBus;
|
||||||
const blacklist = require('../network/blacklist');
|
const blacklist = require('../network/blacklist');
|
||||||
const database = require('../database/index');
|
const database = require('../database/index');
|
||||||
|
|
||||||
// This will load the blacklist and start the webserver when it's done
|
event.on('discord:ready', () => {
|
||||||
blacklist.loadBlacklist().then(blacklist => {
|
// This will load the blacklist and start the webserver when it's done
|
||||||
|
blacklist.loadBlacklist().then(blacklist => {
|
||||||
console.log('Network-Blacklist has been loaded')
|
console.log('Network-Blacklist has been loaded')
|
||||||
expressApp.use('/', express.static(__dirname + '/public'));
|
expressApp.use('/', express.static(__dirname + '/public'));
|
||||||
expressApp.use(IpFilter(blacklist));
|
expressApp.use(IpFilter(blacklist));
|
||||||
|
|
@ -91,4 +92,5 @@ blacklist.loadBlacklist().then(blacklist => {
|
||||||
expressApp.listen(port, () => {
|
expressApp.listen(port, () => {
|
||||||
console.log(`Webserver is available on http://localhost:${port}`)
|
console.log(`Webserver is available on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue