Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
reduced cooldown, added reduced cooldown on failure
Browse files Browse the repository at this point in the history
30s -> 10s
failure cooldown: 2.5s
  • Loading branch information
Supinic committed Aug 10, 2021
1 parent 0bbc109 commit 4f6aa84
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions commands/totalcountline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
Name: "totalcountline",
Aliases: ["acl","tcl"],
Author: "supinic",
Cooldown: 30000,
Cooldown: 10000,
Description: "Fetches the total amount of a user's (or yours, if nobody was specified) chat lines in all tracked channels summed together.",
Flags: ["mention","pipe","skip-banphrase"],
Params: null,
Expand All @@ -12,27 +12,29 @@ module.exports = {
if (!target) {
target = context.user;
}

const userData = await sb.User.get(target);
if (!userData) {
return {
reply: `That user was not found in the database!`
success: false,
reply: `That user was not found in the database!`,
cooldown: 2500
};
}

const data = (await sb.Query.getRecordset(rs => rs
.select("SUM(Message_Count) AS Total")
.from("chat_data", "Message_Meta_User_Alias")
.where("User_Alias = %n", userData.ID)
.single()
));

if (data.Total === null) {
return {
reply: `That user is being tracked, but they have not said any lines in the channels I watch.`
};
}

const who = (context.user.ID === userData.ID) ? "You have" : "That user has";
return {
reply: `${who} sent ${sb.Utils.groupDigits(data.Total)} chat lines across all tracked channels so far.`
Expand Down

0 comments on commit 4f6aa84

Please sign in to comment.