Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/PolestarLabs/polaris into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Flicksie committed Sep 9, 2024
2 parents 1ead273 + a2b310e commit 30401bd
Show file tree
Hide file tree
Showing 11 changed files with 1,822 additions and 1,957 deletions.
4 changes: 2 additions & 2 deletions core/archetypes/Premium.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const RUNNING_MONTH_LONG = new Date().toLocaleString("en", { month: "long" })
.toLowerCase();
const RUNNING_YEAR = new Date().getUTCFullYear();

const CURRENT_VALID_MONTH = 6; // JANUARY = 0; (JULY)
const CURRENT_VALID_MONTH = new Date().getUTCMonth();// JANUARY = 0; (10 NOV

const TURNING_DAY = 5; // when Prime starts
const TURNING_DAY = 1; // when Prime starts
const GRACE_WARNING_DAY = 10; // when Prime starts yelling
const GRACE_TURNING_DAY = 15; // when Prime shuts down

Expand Down
36 changes: 36 additions & 0 deletions core/commands/fun/lookthat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const Picto = require("../../utilities/Picto");

const init = async (msg) => {
let link = (msg.args.join(" ").match(/(http[^ |^>]+)/gm) || [""])[0];

try {
// link ??= msg.mentions[0]?.displayAvatarURL ?? await PLX.getChannelImg(msg) ?? msg.author.displayAvatarURL;
if (!link) link = msg.mentions[0]?.displayAvatarURL ?? await PLX.getChannelImg(msg) ?? msg.author.displayAvatarURL;
} catch (e) {
// link ??= (msg.mentions[0] || msg.author).displayAvatarURL;
if (!link) link = (msg.mentions[0] || msg.author).displayAvatarURL;
}

const [subject, hand] = await Promise.all([
Picto.getCanvas(link),
Picto.getCanvas(`${paths.CDN}/build/assorted/aquelamerda.png`),
]);
const canvas = Picto.new(subject.width, subject.height);
const ctx = canvas.getContext("2d");

ctx.drawImage(subject, 0, 0);
ctx.drawImage(hand, subject.width - subject.height, 0, subject.height, subject.height);

//return msg.channel.send($t("responses.forFun.thatShit", { lngs: msg.lang } ), file(await canvas.toBuffer(), "latts.png"));
return msg.channel.send( "Olha só **aquela** merda!", file(await canvas.toBuffer(), "latts.png"));
};

module.exports = {
init,
pub: false,
cmd: "thatshit",
perms: 3,
cat: "fun",
botPerms: ["attachFiles", "embedLinks"],
aliases: ["aquelamerda", "ltts", "look at that shit"],
};
5 changes: 3 additions & 2 deletions core/commands/moderation/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ async function saveLanguage(langTo,scope,interaction,P){
const init = async (msg, args) => {
const P = { lngs: msg.lang };
const language = args[0];


const serverData = await DB.servers.get(msg.guild.id);
if (!PLX.modPass(msg.member, "kickMembers", serverData)) return msg.channel.send($t("responses.errors.insuperms", P));

const langOptions = shuffle(Languages.i18n).map(lang => {
const emj = typeof lang.flag.id === 'string'
Expand All @@ -44,7 +46,6 @@ const init = async (msg, args) => {
if ( !langOptions.filter(x=>x.default).length ) langOptions.find(x=>x.value==='en').default = true;

if (language === "refresh") {
const serverData = await DB.servers.get(msg.guild.id);
msg.guild.LANG = serverData.modules.LANGUAGE;
return msg.addReaction(_emoji("yep").reaction);
}
Expand Down
120 changes: 84 additions & 36 deletions core/commands/social/commend.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
/* eslint-disable consistent-return */
const Timed = require("../../structures/TimedUsage");


const init = async function (msg, args) {
async function init(msg, args) {
const P = { lngs: msg.lang, prefix: msg.prefix };

const Target = await PLX.resolveMember(msg.guild.id, args[0], { enforceDB: true }).catch(() => {});
const Target = await PLX.resolveMember(msg.guild.id, args[0], {
enforceDB: true,
}).catch(() => {});
if (!Target) return msg.reply($t("responses.errors.kin404", P));

const userData = await DB.users.findOne({ id: msg.author.id });
const targetData = await DB.commends.parseFull({ id: Target.id }) || { id: Target.id, whoIn: [], whoOut: [] };
if (!userData || !targetData) return "Error, one of the users are not present in Database";


const targetData = (await DB.commends.parseFull({ id: Target.id })) || {
id: Target.id,
whoIn: [],
whoOut: [],
};
if (!userData || !targetData) {
return "Error, one of the users are not present in Database";
}
/*
if (!userData.personal?.ip) {
return {embed: {description: `You have to Log-in at least once in our [Dashboard](https://pollux.gg) in order to give commends!` } };
Expand All @@ -23,14 +29,24 @@ const init = async function (msg, args) {
return msg.channel.send(_emoji("nope") + $t("responses.commend.noSelf", P));
}
*/
//const hasVoted = await (Promise.promisify(PLX.topGG.hasVoted))( msg.author.id ).timeout(2000).catch(err=> true);
const hasVoted = await PLX.topGG.hasVoted( msg.author.id ).catch(err=> true);
if (!hasVoted && !userData.prime?.active){
return {embeds: [{description: `To commend globally you must have upvoted us in the last 12 hours!\n[Vote for Pollux here!](https://top.gg/bot/271394014358405121/vote)` }] };
// const hasVoted = await (Promise.promisify(PLX.topGG.hasVoted))( msg.author.id ).timeout(2000).catch(err=> true);
const hasVoted = await PLX.topGG.hasVoted(msg.author.id).catch(() => true);
if (!hasVoted && !userData.prime?.active) {
return {
embeds: [
{
description: `To commend globally you must have upvoted us in the last 12 hours!
[Vote for Pollux here!](https://top.gg/bot/271394014358405121/vote)`,
},
],
};
}

const preafter = async function preafter(M, D) {
if (userData.modules.inventory.find((itm) => itm.id === "commendtoken")?.count >= 1) {
if (
userData.modules.inventory.find((itm) => itm.id === "commendtoken")
?.count >= 1
) {
if (Target.id === msg.author.id) {
msg.channel.send(_emoji("nope") + $t("responses.commend.noSelf", P));
return false;
Expand All @@ -42,8 +58,6 @@ const init = async function (msg, args) {
return true;
};



const after = async function after(msg, Dly) {
await Promise.all([
userData.removeItem("commendtoken"),
Expand All @@ -52,20 +66,19 @@ const init = async function (msg, args) {

P.target = Target.nick || (Target.user || Target).username;
P.author = msg.member.nick || msg.author.username;
P.cmcount = (targetData.totalIn + 1) || 0;
P.cmcount = targetData.totalIn + 1 || 0;
P.pplcount = targetData.whoIn.length + 1;

const embed = new Embed()
.thumbnail(`${paths.DASH}/build/rank.png`)
.color("#3b9ea5")
.timestamp(new Date())
.description(`
.timestamp(new Date()).description(`
${$t("responses.commend.give", P)}
${$t("responses.commend.totals", P)}
`);

Progression.emit("command.commend.commit", { msg, userID: msg.author.id });
msg.channel.send({ embed });
await msg.channel.send({ embed });
};

const reject = function (msg, Daily, r) {
Expand All @@ -83,36 +96,73 @@ const init = async function (msg, args) {
P.remaining = `<t:${~~((userDaily.last + Daily.day) / 1000)}:R>`;
const embed = new Embed();
embed.setColor("#3b9ea5");
embed.description(`${_emoji("future")} ${dailyAvailable ? _emoji("online") + $t("responses.commend.check_yes", P) : _emoji("dnd") + $t("responses.commend.check_no", P)}\
\n\n:reminder_ribbon: × **${userData.modules.inventory.find((i) => i.id === "commendtoken")?.count || 0}**`);
embed.description(`${_emoji("future")} ${
dailyAvailable
? _emoji("online") + $t("responses.commend.check_yes", P)
: _emoji("dnd") + $t("responses.commend.check_no", P)
}\
\n\n:reminder_ribbon: × **${
userData.modules.inventory.find((i) => i.id === "commendtoken")
?.count || 0
}**`);
return msg.channel.send({ embed });
};
// TODO[epic=Constants Module] Replace
Timed.init(msg, "commend", { day: 3.6e+6 * 4 }, after, reject, status, preafter);
};
await Timed.init(
msg,
"commend",
{ day: 3.6e6 * 4 },
after,
reject,
status,
preafter
);
}

const info = async (msg, args) => {
const Target = await PLX.getTarget(args[0] || msg.author, msg.guild);
if (!Target) return msg.reply($t("responses.errors.kin404", P));

const targetData = await DB.commends.parseFull({ id: Target.id }) || { id: Target.id, whoIn: [], whoOut: [] };
const targetData = (await DB.commends.parseFull({ id: Target.id })) || {
id: Target.id,
whoIn: [],
whoOut: [],
};

const metas = await DB.users.find({ id: { $in: targetData.whoIn.map((u) => u.id) } }, { id: 1, meta: 1 }).sort({ amt: -1 })
const metas = await DB.users
.find(
{ id: { $in: targetData.whoIn.map((u) => u.id) } },
{ id: 1, meta: 1 }
)
.sort({ amt: -1 })
.lean()
.exec();
const commendT3 = targetData.whoIn.map((u) => ({ name: metas.find((x) => x.id === u.id)?.meta?.tag || `<@${u.id}>`, amt: u.count })).sort((c1, c2) => c2.amt - c1.amt);
const commendT3 = targetData.whoIn
.map((u) => ({
name: metas.find((x) => x.id === u.id)?.meta?.tag || `<@${u.id}>`,
amt: u.count,
}))
.sort((c1, c2) => c2.amt - c1.amt);
const embed = new Embed()
.color("#3b9ea5")
.thumbnail(`${paths.CDN}/build/rank.png`)
.description(`__**Commend Info for ${Target.mention}**__\
\n\u2003 Total Commends Received: **${targetData.totalIn || 0}**\
\n\u2003 Total Commends Given: **${targetData.totalOut || 0}**\
${commendT3.length == 0 ? ""
: `\n\n__**Top Commenders**__\
\n\u2003 ${commendT3[0] ? `**${commendT3[0].name}** > ${commendT3[0].amt}` : ""}\
\n\u2003 ${commendT3[1] ? `**${commendT3[1].name}** > ${commendT3[1].amt}` : ""}\
\n\u2003 ${commendT3[2] ? `**${commendT3[2].name}** > ${commendT3[2].amt}` : ""}`
}`);
${
commendT3.length == 0
? ""
: `\n\n__**Top Commenders**__\
\n\u2003 ${
commendT3[0] ? `**${commendT3[0].name}** > ${commendT3[0].amt}` : ""
}\
\n\u2003 ${
commendT3[1] ? `**${commendT3[1].name}** > ${commendT3[1].amt}` : ""
}\
\n\u2003 ${
commendT3[2] ? `**${commendT3[2].name}** > ${commendT3[2].amt}` : ""
}`
}`);

return { embed };
};
Expand All @@ -124,9 +174,7 @@ module.exports = {
cmd: "commend",
perms: 3,
cat: "social",
botPerms: [ "attachFiles", "embedLinks" ],
aliases: [ "com", "rec", "rep" ],
autoSubs: [
{ label: "info", gen: info },
],
botPerms: ["attachFiles", "embedLinks"],
aliases: ["com", "rec", "rep"],
autoSubs: [{ label: "info", gen: info }],
};
Loading

0 comments on commit 30401bd

Please sign in to comment.