diff --git a/README.md b/README.md index 2b246f4..46954f6 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ To change the token or key later, edit `.env` directly, then run the installer a - To add, remove, or change greetings, edit `greetings.yaml`. Use `{user}` anywhere in a greeting and it gets replaced with a mention of the person who joined. - Same for goodbyes: edit `goodbyes.yaml`. Use `{user}` there too, it gets replaced with the username of whoever left (a plain name, not a mention, since Discord can't ping someone no longer in the server). - The join greeting posts to whichever channel is named `general` in your server. To use a different channel, change `GREETING_CHANNEL_NAME` near the top of `index.js` to that channel's name (no `#`) and restart it (re-run the installer, or `pm2 restart discord-bot`). If no channel with that name exists, nothing posts and `bot.error.log` will note it. -- Any Discord Scheduled Event on your server gets an automatic reminder posted to that same channel 5 minutes before it starts, like "EVENT: Movie Night starting soon!" Each event only gets reminded once. To change how far ahead it reminds, edit `EVENT_REMINDER_MINUTES` near the top of `index.js` and restart it. +- Any Discord Scheduled Event on your server gets an automatic reminder posted to that same channel 5 minutes before it starts, like "EVENT: Movie Night starting soon!" If the event's title matches an existing game role, that role gets tagged too, like "@The Forest EVENT: The Forest starting soon!" Each event only gets reminded once. To change how far ahead it reminds, edit `EVENT_REMINDER_MINUTES` near the top of `index.js` and restart it. - `!info` gets platforms and Multiplayer/Co-Op/Cross-Play from that game's Steam store page when it has one. For non-Steam games (GOG/Epic exclusives etc.) there is no such lookup available, so "not listed" there means "couldn't confirm it," not "definitely single-player only." - The ownership count on `!info` combines two sources: anyone who ran `!own` for that game, plus anyone who linked their Steam profile with `!my-steam-profile` and actually owns it there. Discord itself has no concept of game ownership, so there is no fully automatic way to get this - `!own` needs people to mark their own games by hand, and `!my-steam-profile` only auto-detects Steam copies (not GOG/Epic) and only if that person's Steam profile has "game details" set to public. Everything self-reported through `!own` is stored in `owned.json`; Steam profile links are stored in `steamlinks.json`, both in this folder, in plain text. - `!popular` combines both sources across every game, not just one at a time: anything self-reported with `!own`, plus a full scan of every Steam-linked member's library (Steam already hands back the game name with that lookup, so no extra API calls are needed). The same game reported through `!own` and detected in someone's Steam library counts as one shared total, not two. Games with only one confirmed owner are left out, and everything is sorted most-owned first. diff --git a/index.js b/index.js index 9c84689..eb49460 100644 --- a/index.js +++ b/index.js @@ -2201,7 +2201,11 @@ async function checkUpcomingEvents(client) { } try { - await channel.send("EVENT: " + event.name + " starting soon!"); + const roles = loadRoles(); + const match = findGameRole(roles, event.name); + const role = match && guild.roles.cache.get(match.entry.roleId); + const mention = role ? role.toString() + " " : ""; + await channel.send(mention + "EVENT: " + event.name + " starting soon!"); } catch (err) { console.error("Could not send event reminder:", err.message); } @@ -2337,8 +2341,11 @@ async function handleRoleInteraction(interaction, roleId) { const entries = sortedRoleEntries(); const counts = roleMemberCounts(interaction.guild, entries); - if (counts[roleId] !== undefined) { - counts[roleId] = Math.max(0, counts[roleId] + (hadRole ? -1 : 1)); + const role = interaction.guild.roles.cache.get(roleId); + const cacheHasMember = role ? role.members.has(interaction.member.id) : false; + const shouldHaveMember = !hadRole; + if (counts[roleId] !== undefined && cacheHasMember !== shouldHaveMember) { + counts[roleId] = Math.max(0, counts[roleId] + (shouldHaveMember ? 1 : -1)); } const picker = buildRolePickerComponents(entries, counts); try {