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

automate year and alumni roles #331

Merged
merged 5 commits into from
Aug 21, 2022
Merged

Conversation

victorzheng02
Copy link
Contributor

Summary of Changes

  • When users use .set profile year, year roles will be automatically assigned/removed.

Motivation and Explanation

  • Manually creating new roles for each new year is tiring and could be automated. Furthermore, we have an easy way to identify alumni since the profile feature already exists.

Related Issues

resolves #229

Steps to Reproduce

  • Run .profile set
  • Observe if the year is less than the current year, then you will automatically be assigned the alumni role
  • Observe that if the year is within the currentYears range identified by the original ticket known as the enum "validRoleYears" on the pr, then you will get that year assigned as a role to you.
  • Observe that if the year is within the currentYears range and the role does not exist, the bot will automatically create this role.

Demonstration of Changes

BEFORE:
image
MESSAGE SENT:
image
AFTER:
image

Further Information and Comments

Copy link
Collaborator

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments. To make the code a bit cleaner, when logging errors, can we do throw new Error('error message here') instead, and can we remove the logging of non-errors?

src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few more comments. There are also some merge conflicts to be resolved.

src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
src/components/profile.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

const [customization, description] = Object.entries(data)[0];

if (customization === 'year') {
// onlyDescription here would be the new year role
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace onlyDescription with description?

Copy link
Collaborator

@marko-polo-cheno marko-polo-cheno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to set roles for everyone so far who has done a user profile?

await db.run(query, onlyDescription, userId);
description.replace(/'/g, "''");
query = `UPDATE user_profile_table SET last_updated=CURRENT_DATE, ${customization}=? WHERE user_id=?`;
await db.run(query, description, member.id);
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this else should be like... === 0 right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess we never have more than 1 tho

@victorzheng02 victorzheng02 merged commit 1c83a65 into master Aug 21, 2022
@victorzheng02 victorzheng02 deleted the victor_automate_year_roles branch August 21, 2022 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Set Profile Updates to automatically update discord year roles
3 participants