gblazzy
gblazzy
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
Yh I ran it through GPT to try and find the mistake
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
Status
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
Yh
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
Yeah but how to fix?
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
Sorry to bother you
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
Still no change. 😭
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
I have the right status set so in theory it should give me the role and log it not say ion got the role
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
No description
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
Still getting the same issues, nothing really changes, still also showing “4”
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
alr
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
so how do i fix it
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
im still new to this stuff 😭
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
wdym
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
No description
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
The newest version, just installed it again today. And all the logs is when someone changes there status, and when it removes the role
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
Also I just noticed I posted this in the wrong area 😭
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
That is my code
33 replies
DIAdiscord.js - Imagine an app
Created by gblazzy on 9/25/2024 in #djs-voice
need help with this code
const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences, // Needed to track user presence
],
});

// Define the target custom status and role ID
const TARGET_CUSTOM_STATUS = '.gg/dallaspd'; // The custom status you want to check for
const ROLE_ID = '1287515637714911322'; // The ID of the role you want to assign

client.on('ready', () => {
console.log(`${client.user.username} is online!`);
});

client.on('presenceUpdate', async (oldPresence, newPresence) => {
const member = newPresence.member;

if (!member) return; // Ensure this is a guild member

// Log user's status change
console.log(`${member.user.tag} changed status:`);

// Check activities for the target custom status
const activities = newPresence.activities;
const hasTargetStatus = activities.some(activity =>
activity.type === 'CUSTOM' && activity.name === TARGET_CUSTOM_STATUS
);

// Log current activities
activities.forEach(activity => {
console.log(`- ${activity.type}: ${activity.name}`);
});

// Find the role by ID
const role = member.guild.roles.cache.get(ROLE_ID);

// If the user has the target custom status
if (hasTargetStatus) {
console.log(`${member.user.tag} has the target custom status: "${TARGET_CUSTOM_STATUS}".`);

// Check if the user already has the role
if (role) {
if (!member.roles.cache.has(role.id)) {
try {
await member.roles.add(role);
console.log(`Assigned role "${role.name}" to ${member.user.tag}.`);
} catch (error) {
console.error(`Failed to add role: ${error}`);
}
} else {
console.log(`${member.user.tag} already has the role "${role.name}".`);
}
} else {
console.error(`Role with ID ${ROLE_ID} not found.`);
}
} else {
// If the user doesn't have the target status, check if they have the role and remove it
if (role && member.roles.cache.has(role.id)) {
try {
await member.roles.remove(role);
console.log(`Removed role "${role.name}" from ${member.user.tag}.`);
} catch (error) {
console.error(`Failed to remove role: ${error}`);
}
} else {
console.log(`${member.user.tag} does not have the role "${role ? role.name : 'unknown'}".`);
}
}
});

client.login('TOCKEN');
const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences, // Needed to track user presence
],
});

// Define the target custom status and role ID
const TARGET_CUSTOM_STATUS = '.gg/dallaspd'; // The custom status you want to check for
const ROLE_ID = '1287515637714911322'; // The ID of the role you want to assign

client.on('ready', () => {
console.log(`${client.user.username} is online!`);
});

client.on('presenceUpdate', async (oldPresence, newPresence) => {
const member = newPresence.member;

if (!member) return; // Ensure this is a guild member

// Log user's status change
console.log(`${member.user.tag} changed status:`);

// Check activities for the target custom status
const activities = newPresence.activities;
const hasTargetStatus = activities.some(activity =>
activity.type === 'CUSTOM' && activity.name === TARGET_CUSTOM_STATUS
);

// Log current activities
activities.forEach(activity => {
console.log(`- ${activity.type}: ${activity.name}`);
});

// Find the role by ID
const role = member.guild.roles.cache.get(ROLE_ID);

// If the user has the target custom status
if (hasTargetStatus) {
console.log(`${member.user.tag} has the target custom status: "${TARGET_CUSTOM_STATUS}".`);

// Check if the user already has the role
if (role) {
if (!member.roles.cache.has(role.id)) {
try {
await member.roles.add(role);
console.log(`Assigned role "${role.name}" to ${member.user.tag}.`);
} catch (error) {
console.error(`Failed to add role: ${error}`);
}
} else {
console.log(`${member.user.tag} already has the role "${role.name}".`);
}
} else {
console.error(`Role with ID ${ROLE_ID} not found.`);
}
} else {
// If the user doesn't have the target status, check if they have the role and remove it
if (role && member.roles.cache.has(role.id)) {
try {
await member.roles.remove(role);
console.log(`Removed role "${role.name}" from ${member.user.tag}.`);
} catch (error) {
console.error(`Failed to remove role: ${error}`);
}
} else {
console.log(`${member.user.tag} does not have the role "${role ? role.name : 'unknown'}".`);
}
}
});

client.login('TOCKEN');
33 replies