Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix helper pings in meta discussions when triggered by TripSit mode #896

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ WOLFRAM_TOKEN = <Optional> # For WolframAlpha API
IMGUR_ID = <Optional> # For Imgur API
IMGUR_SECRET = <Optional> # For Imgur API
YOUTUBE_TOKEN = <Optional> # For YouTube API
IMDB_TOKEN = <Optional> # For IMDB API
```
IMDB_TOKEN = <Optional> # For IMDB API
11 changes: 9 additions & 2 deletions src/discord/commands/global/d.tripsitmode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

const F = f(__filename);

async function tripsitmodeOn(

Check warning on line 43 in src/discord/commands/global/d.tripsitmode.ts

View workflow job for this annotation

GitHub Actions / Lint

Refactor this function to reduce its Cognitive Complexity from 60 to the 50 allowed
interaction:ChatInputCommandInteraction,
target:GuildMember,
) {
Expand Down Expand Up @@ -227,6 +227,7 @@
const now = new Date();
const diff = now.getTime() - createdDate.getTime();
const minutes = Math.floor(diff / 1000 / 60);
// const seconds = Math.floor(diff / 1000); // Uncomment this for dev server
if (minutes > 5) {
const helperStr = `and/or ${roleHelper}`;
// log.debug(F, `Target has open ticket, and it was created over 5 minutes ago!`);
Expand All @@ -247,9 +248,15 @@
// If the meta thread exists, update the name and ping the team
if (ticketData.meta_thread_id) {
let metaMessage = '';
if (minutes > 5) {
if (minutes > 5) { // Switch to seconds > 10 for dev server
const helperString = `and/or ${roleHelper}`;
metaMessage = `Hey ${roleTripsitter} ${guildData.role_helper ?? helperString} team, ${interaction.member} has indicated that ${target.displayName} needs assistance!`; // eslint-disable-line max-len
try {
metaMessage = `Hey ${roleTripsitter} ${guildData.role_helper ? helperString : ''} team, ${interaction.member} has indicated that ${target.displayName} needs assistance!`;

Check warning on line 254 in src/discord/commands/global/d.tripsitmode.ts

View workflow job for this annotation

GitHub Actions / Lint

This line has a length of 182. Maximum allowed is 120
} catch (err) {
// If for example helper role has been deleted but the ID is still stored, do this
metaMessage = `Hey ${roleTripsitter} team, ${interaction.member} has indicated that ${target.displayName} needs assistance!`;

Check warning on line 257 in src/discord/commands/global/d.tripsitmode.ts

View workflow job for this annotation

GitHub Actions / Lint

This line has a length of 137. Maximum allowed is 120
log.error(F, `Stored Helper ID for guild ${guildData.id} is no longer valid. Role is unfetchable or deleted.`);

Check warning on line 258 in src/discord/commands/global/d.tripsitmode.ts

View workflow job for this annotation

GitHub Actions / Lint

This line has a length of 123. Maximum allowed is 120
}
} else {
metaMessage = `${interaction.member} has indicated that ${target.displayName} needs assistance!`;
}
Expand Down
Loading