Audit Logs : VoiceStatUpdates

Hey ! How to separate the logs of a member who is disconnected and a member who leaves himself ?
DT
d.js toolkit199d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
A
Aiwoz199d ago
if (oldChannel && !newChannel) {



const { AuditLogEvent } = require('discord.js');

const fetchedLogs = await (oldState, newState).guild.fetchAuditLogs({
limit: 1,
type: 'MEMBER_DISCONNECT',
});

const log = fetchedLogs.entries.first();
const { executor } = log;

console.log(executor);
if (oldChannel && !newChannel) {



const { AuditLogEvent } = require('discord.js');

const fetchedLogs = await (oldState, newState).guild.fetchAuditLogs({
limit: 1,
type: 'MEMBER_DISCONNECT',
});

const log = fetchedLogs.entries.first();
const { executor } = log;

console.log(executor);
M
M4LIO199d ago
Bad type 🙂 AuditLogEvent.MemberDisconnect @Aiwoz
M
M4LIO199d ago
https://discordjs.guide/popular-topics/audit-logs.html#who-deleted-a-message Same code,
const { AuditLogEvent, Events } = require('discord.js');

client.on(Events.GuildAuditLogEntryCreate, async auditLog => {
// Define your variables.
// The extra information here will be the channel.
const { action, extra: channel, executorId, targetId } = auditLog;

// Check only for deleted messages.
if (action !== AuditLogEvent.MemberDisconnect) return;

// Ensure the executor is cached.
const executor = await client.users.fetch(executorId);

// Ensure the author whose message was deleted is cached.
const target = await client.users.fetch(targetId);

// Log the output.
console.log(`member disconnected from ${channel}.`);
});
const { AuditLogEvent, Events } = require('discord.js');

client.on(Events.GuildAuditLogEntryCreate, async auditLog => {
// Define your variables.
// The extra information here will be the channel.
const { action, extra: channel, executorId, targetId } = auditLog;

// Check only for deleted messages.
if (action !== AuditLogEvent.MemberDisconnect) return;

// Ensure the executor is cached.
const executor = await client.users.fetch(executorId);

// Ensure the author whose message was deleted is cached.
const target = await client.users.fetch(targetId);

// Log the output.
console.log(`member disconnected from ${channel}.`);
});
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
A
Aiwoz198d ago
Thank you but how can you tell if he leaves the voice or if he gets disconnected?
M
M4LIO198d ago
MemberDisconnected = MemberLeave the AudioLogEntry so check if executor or not
A
Aiwoz198d ago
With if(action) ?
M
M4LIO198d ago
yes
A
Aiwoz198d ago
Thank you. ^^
Want results from more Discord servers?
Add your server
More Posts
Log when a member gets timed outIs it possible for a Discord Bot to send a message in a Channel when a member gets Timed Out so foWhy isnt a public endpoint needed on discord.js ?When developing using discord api (without discord.js library) by itself, per their guides, a publiMessage broker / Message queueIs there any native support for message brokers like rabbitmq? Thanks in advanceFATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memoryI am getting this error like 20 seconds after the bot is on but 2 days ago it was working fine and iWhat method to check if invite is paused?Ping if you know the answer (pls)🐛 Issue: Permission Error (50013) When Deleting a Role with Discord Bot**Description:** I am encountering a 50013 Permission error when my Discord bot tries to delete a roget all mesages after a specific timeIm making a purge command but when i try to delete messages it says it can only delete messages thatusing rest API to update server bannerI'm trying to use the REST api to update my server banner. The problem is that it seems to work - aboort erroron latest djsInvalid bitfield in audit log channel permissions eventHey, I currently have the issue that errors like these are sent multiple times a minute into my bot'StatusHello Everyone. I am currently having trouble on setting my bots status. Would anyone have a basic errors in my codehey so im trying to make a streaming selfbot but ive been getting loads of errors whenever i try to TTSi want to create a simple discord bot, that will read user messages in specific channel and bot willBot Crashing After a non permission user runds commandclient.on('messageCreate', (message) => { // Check if the message starts with "!announce" and thExtending Guild, Channel, Member etc - TypeScriptIs it possible to extend upon Guild, Channel, Member etc objects? I have tried extending them but Does anyone have a https request bot infrastructure??djs versionsWhat version would be the best to create a discord bot in ? have any suggestions?Anyone can help me to fix old code ?Hi there! Actually i'm stuck on an old code. ```ts const fullPermissions = commandsCol.reduce< Problems in developing discord botHello everyone, I'm new here , sorry, if i do something wrong. I'm trying to develop my own bot, I'mHow would you accomplish this?I've got the following situation. My bot is attempting to collect information from a user. At first,