From c30325afc0f36b4c439ff1a5f54559bff2f89d3a Mon Sep 17 00:00:00 2001 From: legop3 Date: Thu, 22 Jan 2026 01:10:09 -0500 Subject: [PATCH] adjustmentos --- server/config.example.yaml | 1 - server/src/services/discordBotService.js | 48 +++--------------------- 2 files changed, 5 insertions(+), 44 deletions(-) diff --git a/server/config.example.yaml b/server/config.example.yaml index 91e1af1d..f1c4f277 100644 --- a/server/config.example.yaml +++ b/server/config.example.yaml @@ -47,4 +47,3 @@ discord: roles: announcementPing: "123456789012345678" adminPing: "123456789012345678" - stalker: "123456789012345678" diff --git a/server/src/services/discordBotService.js b/server/src/services/discordBotService.js index 70066ce6..13ce55ca 100644 --- a/server/src/services/discordBotService.js +++ b/server/src/services/discordBotService.js @@ -44,7 +44,6 @@ if (!enabled) { const intents = [ GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, ]; @@ -978,36 +977,10 @@ function buildBatteryCaption(type, payload) { } } -async function getRoleMemberIds(channelId, roleId) { - if (!channelId || !roleId) return []; - const channel = await fetchChannel(channelId); - if (!channel?.guild) return []; - const guild = channel.guild; - let role = guild.roles.cache.get(roleId) || null; - if (!role) { - try { - role = await guild.roles.fetch(roleId); - } catch (err) { - logger.warn('Failed to fetch Discord role', { roleId, error: err.message }); - return []; - } - } - if (!role) return []; - if (!role.members || role.members.size === 0) { - try { - await guild.members.fetch(); - } catch (err) { - logger.warn('Failed to fetch guild members', { guildId: guild.id, error: err.message }); - } - } - return Array.from(role.members?.keys?.() || []); -} - async function announce({ channelId, content, pingRoleId, - pingUserIds, prefixMentions = true, includeSiteUrl = true, color, @@ -1018,11 +991,6 @@ async function announce({ if (!channelId) return; const mentionChunks = []; if (pingRoleId) mentionChunks.push(`<@&${pingRoleId}>`); - if (Array.isArray(pingUserIds)) { - pingUserIds.forEach((id) => { - if (id) mentionChunks.push(`<@${id}>`); - }); - } const prefix = prefixMentions && mentionChunks.length ? `${mentionChunks.join(' ')} ` : ''; const payloadEmbeds = Array.isArray(embeds) && embeds.length > 0 @@ -1031,32 +999,26 @@ async function announce({ const allowedMentions = { parse: [], roles: pingRoleId ? [pingRoleId] : [], - users: Array.isArray(pingUserIds) ? pingUserIds : [], }; await sendToChannel( channelId, `${prefix}${content || ''}`.trim(), { embeds: payloadEmbeds }, allowedMentions, - !(pingRoleId || (Array.isArray(pingUserIds) && pingUserIds.length > 0)), // keep mentions intact when pinging + !pingRoleId, // keep mention intact when pinging ); } async function announceUserStatus({ channelId, content, color, title, description, embeds }) { const roles = discordConfig.roles || {}; - const pingRoleId = roles.announcementPing || null; - const pingUserIds = await getRoleMemberIds(channelId, roles.stalker || null); + const mode = getMode(); + const allowPing = mode !== MODES.ADMIN && mode !== MODES.LOCKDOWN; + const pingRoleId = allowPing ? roles.announcementPing || null : null; const mainLine = pingRoleId ? `<@&${pingRoleId}> ${content}`.trim() : content; - const stalkerMentions = - Array.isArray(pingUserIds) && pingUserIds.length > 0 - ? pingUserIds.map((id) => `<@${id}>`).join(' ') - : ''; - const message = [mainLine, stalkerMentions].filter(Boolean).join('\n'); await announce({ channelId, - content: message, + content: mainLine, pingRoleId, - pingUserIds, prefixMentions: false, color, title,