Skip to content

Commit

Permalink
Release 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
elijaholmos authored Nov 1, 2021
2 parents 157f925 + 7bcf7d5 commit d113689
Show file tree
Hide file tree
Showing 33 changed files with 1,301 additions and 724 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# [2.5.0](https://github.com/Leyline-gg/leyline-discord/releases/tag/v2.5.0) (2021-10-31)

## Dev Notes
The custom punishment system introduced previously has been rebranded to Justice System to better reflect the core values of Leyline. All "punish" wording has been changed to either "justice" or "sentence".
A lot of what we're doing at Leyline involves making new paths and breaking away from traditions and creating our own standard. Trial & error is a big component of this process, which means rebrands and revisions are more common than with a well-established company. In addition to the renaming of the Discord justice system, Leyline Points are also being renamed across the platform to Good Points. For more info on any of the changes we make, whether on Discord or not, the weekly AMA on Saturday is a great place to ask your questions in a casual environment and get responses from the core Leyline team.

## New Features
- Good Acts submissions can now be manually approved by Moderators
- This feature makes use of Discord's context menus
- It can be used to manually approve any message as a Good Act
- When a message is manually approved, the same process for automatic approval occurs (see previous changelogs for details)
- Any users that reacted to the message prior to its approval will receive GP
- Any users that react to the message within 24h of its approval will receive GP
- The approved act will be recorded on the user's Proof of Good ledger
- Good Acts and Kind Words submissions now support custom emoji for moderator reactions
- Good Acts and Kind Words submission approvals & rejections are now logged in a private staff-only channel
- The log information displayed in the embeds has been reformatted

## Existing Feature Changes
- All `punish` subcommands have been split into their own commands
- Example: `/punish warn` is now `/warn`
- All uses of the phrase "punish" have been renamed to either "justice" or "sentence"
- All front-facing references to LLP have been renamed to GP. This includes:
- `inspect` command
- `profile` command
- all logs and DMs associated with user submissions
- the LLP tag has been changed to GP
- Good Acts and Kind Words submission approvals & rejections are no longer logged in #bot-log
- `awardnft channel` subcommand now only takes voice or stage channels for the `channel` parameter
- `sudosay` command now only takes non-thread text channels for the `channel` parameter
- The green color for success embeds has been darkened slightly

## Bug Fixes
- `profile` command displaying an incorrect GP value

# [2.4.0](https://github.com/Leyline-gg/leyline-discord/releases/tag/v2.4.0) (2021-10-12)

## Dev Notes
Expand Down
14 changes: 14 additions & 0 deletions api/collectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,17 @@ export const getDiscordReactions = async function (uid) {
doc.id === uid && res++;
return res;
}

/**
* Get the Firestore document for a collector, if it exists
* @param {String} id The collector's id
* @returns {Promise<FirebaseFirestore.DocumentData | undefined>} JSON collector data or undefined if non-existent
*/
export const fetchCollector = async function (id) {
const collector = await admin
.firestore()
.collection('discord/bot/reaction_collectors')
.doc(id)
.get();
return collector.data();
}
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './polls';
export * from './collectors';
export * from './llp';
export * from './points';
export * from './nfts';
export * from './userConnections';
export * from './items';
Expand Down
24 changes: 12 additions & 12 deletions api/llp.js → api/points.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import admin from 'firebase-admin';

/**
* Get the latest LLP balance of a Leyline user
* Get the latest GP balance of a Leyline user
* Taken from webapp's api package `userService.ts`
* @param {String} uid Leyline UID
* @returns {Promise<Number>} User's most up-to-date LLP balance
* @returns {Promise<Number>} User's most up-to-date GP balance
*/
export const getLLPBalance = async function (uid) {
export const getPointsBalance = async function (uid) {
const userDoc = await admin.firestore().doc(`users/${uid}`).get();
const userData = userDoc.data();

Expand All @@ -28,12 +28,12 @@ export const getLLPBalance = async function (uid) {
}

/**
* Get a Leyline user's total LLP earned
* Get a Leyline user's total GP earned
* Taken from webapp's api `userService.ts`
* @param {String} uid Leyline UID
* @returns {Promise<Number>} Total LLP earned up until this point
* @returns {Promise<Number>} Total GP earned up until this point
*/
export const getTotalEarnedLLP = async function (uid) {
export const getTotalEarnedPoints = async function (uid) {
const snapshotRef = await admin.firestore()
.collection('leaderboards')
.orderBy('snapshot_time', 'desc')
Expand All @@ -51,11 +51,11 @@ export const getTotalEarnedLLP = async function (uid) {
}

/**
* Get a Leyline user's total LLP earned for volunteering
* Get a Leyline user's total GP earned for volunteering
* @param {String} uid Leyline UID
* @returns {Promise<Number>} Approximate total LLP earned for volunteering
* @returns {Promise<Number>} Approximate total GP earned for volunteering
*/
export const getVolunteerLLP = async function (uid) {
export const getVolunteerPoints = async function (uid) {
const snapshot = await admin.firestore()
.collection('leyline_points')
.where('uid', '==', uid)
Expand All @@ -66,12 +66,12 @@ export const getVolunteerLLP = async function (uid) {
}

/**
* Award a specific amount of LLP to a user, with an option to include transaction metadata
* Award a specific amount of GP to a user, with an option to include transaction metadata
* @param {String} uid Leyline UID
* @param {Number} amount Amount of LLP to award
* @param {Number} amount Amount of GP to award
* @param {Object} [metadata] Metadata for transaction. Should contain a `category` property
*/
export const awardLLP = async function (uid, amount, metadata = {}) {
export const awardPoints = async function (uid, amount, metadata = {}) {
return await admin.firestore().collection('leyline_points').add({
uid: uid,
leyline_points: amount,
Expand Down
43 changes: 34 additions & 9 deletions classes/LeylineBot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, Collection } from "discord.js";
import { Client, Collection, Emoji } from "discord.js";
import config from '../config.js';
import { ConfirmInteraction, EmbedBase, Logger, CloudConfig } from ".";

Expand Down Expand Up @@ -116,13 +116,26 @@ export class LeylineBot extends Client {
}

/**
* Sends a discord message on the bot's behalf to a public log channel, specific for punishments
* Sends a discord message on the bot's behalf to a public log channel, specific for sentences
* @param {Object} args
* @param {EmbedBase} args.embed Singular embed object to be sent in message
* @returns {Promise<Message>} Promise which resolves to the sent message
*/
async logPunishment({embed, ...options}) {
return (await this.channels.fetch(this.config.channels.punishment_log)).send({
async logSentence({embed, ...options}) {
return (await this.channels.fetch(this.config.channels.mod_log)).send({
embeds: [embed],
...options,
});
}

/**
* Sends a discord message on the bot's behalf to a private log channel, specific for submissions
* @param {Object} args
* @param {EmbedBase} args.embed Singular embed object to be sent in message
* @returns {Promise<Message>} Promise which resolves to the sent message
*/
async logSubmission({embed, ...options}) {
return (await this.channels.fetch(this.config.channels.submission_log)).send({
embeds: [embed],
...options,
});
Expand All @@ -149,21 +162,21 @@ export class LeylineBot extends Client {
* Replies to an interaction
* @param {Object} args Destructured arguments
* @param {Interaction} args.intr Discord.js `Interaction`
* @param {EmbedBase} [args.embed] Singular embed object to be included in reply
* @param {EmbedBase} [args.embed] Singular embed object to be included in reply. If unspecified, existing embeds are removed
* @returns {Promise<Message>} The reply that was sent
*/
intrReply({intr, embed, ...options}) {
intrReply({intr, embed=null, ...options}) {
const payload = {
...embed && { embeds: [embed] },
embeds: !!embed ? [embed] : [],
fetchReply: true,
...options,
};
return (intr.deferred || intr.replied) ? intr.editReply(payload) : intr.reply(payload);
}

intrUpdate({intr, embed, ...options}) {
intrUpdate({intr, embed=null, ...options}) {
const payload = {
...embed && { embeds: [embed] },
embeds: !!embed ? [embed] : [],
fetchReply: true,
...options,
};
Expand Down Expand Up @@ -232,4 +245,16 @@ export class LeylineBot extends Client {
return `<t:${timestamp /1000 |0}:${letter}>`;
}

/**
* Construct an Discord.js emoji from destructured parameters (such as Firestore data)
* @param {Object} args Destructured arguments, see `Emoji` constructor
* @returns {Emoji}
*/
constructEmoji({name, id, animated=false, ...other} = {}) {
return Object.assign(new Emoji(this, {
name,
id,
animated,
}), other);
}
}
8 changes: 4 additions & 4 deletions classes/LeylineUser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Firebase from '../api';

export class LeylineUser {
// hours donated, blood donated, llp balance, days slept/exercised
// hours donated, blood donated, gp balance, days slept/exercised
// leaderboard positions? for all time
// avatar, total items in inventory
constructor(uid) {
Expand All @@ -10,9 +10,9 @@ export class LeylineUser {
this.uid = uid;
//this.discord_uid = discord_uid || (await Firebase.getDiscordDoc(uid, true)).id;
this._username = doc?.username;
this.llp = await Firebase.getLLPBalance(uid);
this.total_llp = await Firebase.getTotalEarnedLLP(uid);
this.volunteer_llp = await Firebase.getVolunteerLLP(uid);
this.gp = await Firebase.getPointsBalance(uid);
this.total_gp = await Firebase.getTotalEarnedPoints(uid);
this.volunteer_gp = await Firebase.getVolunteerPoints(uid);
this.rankings = await Firebase.getUserRankings(uid);
this.inventory = await Firebase.getInventoryItems(uid);
this.profile_url = `https://leyline.gg/profile/${doc?.profile_id}`;
Expand Down
Loading

0 comments on commit d113689

Please sign in to comment.