ServiceNowDevProgram / Points-Thing

The official application repository for the bot @Points-Thing on the sndevs.com workspace.
https://github.com/ServiceNowDevProgram/Hacktoberfest
4 stars 57 forks source link

Add support for tagging in !leaderboard without mentions #25

Closed SapphicFire closed 1 year ago

SapphicFire commented 1 year ago

Reason for change:

Per chat in Slack and @wiz0floyd's suggestion to support tagging users to get dynamic and up-to-date names, I've put this together to support name replacement with User ID (controlled by system property: x_snc_pointsthing.leaderboard_tagging)

Detail:

Added a new function, update_tag_chat to replace leaderboard names with tags. Simplified showcase of its usage below:

var userArr = [{name: "some_name", id: "U0K4BD8DC"}];
var resp = this.send_chat(chat_gr, "some_name (7)", true);
this.update_tag_chat(resp, userArr);

Process for comparison:

Before:

image

After (tags are working, users just don't exist but are based off my Member ID):

image

SapphicFire commented 1 year ago

Diff on Script Include isn't playing nice - I added handling for my system property in the leaderboard function, and then updated it to call my new function if it is set true. And of course, the new function 😄