Skip to content

Commit

Permalink
Merge pull request discord-akairo#29 from cataclym/dev
Browse files Browse the repository at this point in the history
Fix to Tinder reset time and Emotecount
  • Loading branch information
Ole Hagberg committed Jul 21, 2020
2 parents 2ef0c63 + 80537f2 commit 9f52ead
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
13 changes: 9 additions & 4 deletions commands/emotecount.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@ module.exports = {
let data4 = "";
for (const [key, value] of Object.entries(GuildEmoteCount)) {
const Emote = message.guild.emojis.cache.get(key);
if (data.length < 2000 && Emote) {
if (!Emote) { continue; }
if (data.length <= 2000) {
data += `${Emote} \`${Object.values(value)}\` `;
continue;
}
if (data.length > 2000 && data2.length < 2000 && Emote) {
if (data.length >= 2000 && data2.length <= 2000) {
data2 += `${Emote} \`${Object.values(value)}\` `;
continue;
}
if (data2.length > 2000 && data3.length < 2000 && Emote) {
if (data2.length >= 2000 && data3.length <= 2000) {
data3 += `${Emote} \`${Object.values(value)}\` `;
continue;
}
if (data3.length > 2000 && data4.length < 2000 && Emote) {
if (data3.length >= 2000 && data4.length <= 2000) {
data4 += `${Emote} \`${Object.values(value)}\` `;
continue;
}
}
embed.setDescription(data);
Expand Down
8 changes: 5 additions & 3 deletions commands/tinder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discord = require("discord.js");
const db = require("quick.db");
const Tinder = new db.table("Tinder");
const { getUserFromMention, ResetRolls } = require("../functions/functions.js");
const { getUserFromMention, ResetRolls, timeToMidnight, msToTime } = require("../functions/functions.js");
const embeds = require("../functions/embeds.js");
const { TinderStartup, TinderDBService, NoLikes, NoRolls } = require("../functions/tinder.js");
const { poems } = require("../functions/poems.js");
Expand All @@ -20,7 +20,7 @@ module.exports = {
TinderDBService(message.author);
}
switch (args[0]) {
case "refill": {
case "reset": {
try { if (message.member.hasPermission("ADMINISTRATOR")) {
ResetRolls(message);
return message.react("✅"); }
Expand All @@ -32,7 +32,9 @@ module.exports = {
}
case "marry": { return marry();
}
case "help": { return message.channel.send(embeds.TinderHelp);
case "help": {
embeds.TinderHelp.fields[3] = { name: "Reset", value: "Rolls and likes reset every day. Currently resets in: " + msToTime(timeToMidnight()), inline: true };
return message.channel.send(embeds.TinderHelp);
}
case "test": { // remove
try { if (message.member.hasPermission("ADMINISTRATOR")) { return; }
Expand Down
5 changes: 0 additions & 5 deletions functions/embeds.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
const { MessageEmbed } = require("discord.js");
const { prefix } = require("../config.js");
const { timeToMidnight, msToTime } = require("./functions");

const time2mid = timeToMidnight();
const time2midHrs = msToTime(time2mid);

const TinderHelp = new MessageEmbed()
.setTitle("Tinder help page")
.addFields(
{ name: "Rolls and likes", value: "Using the main command (`" + prefix + "tinder`), costs a roll!\nIf you decide to react with a 💚, you spend 1 like.\nIf you react with a 🌟, you spend all your rolls and likes.", inline: true },
{ name: "How to marry", value: "You can only marry someone you are dating.\nMarrying is simple, type `" + prefix + "tinder marry @someone`\nThey will have to react with a ❤️, to complete the process!", inline: true },
{ name: "Check status", value: "You can check who you have liked, disliked and who you are currently dating as well as who you have married.\n`" + prefix + "tinder list`", inline: true },
{ name: "Reset", value: "Rolls and likes reset every day. Currently resets in: " + time2midHrs, inline: true },
)
.setColor("#31e387")
.setImage();
Expand Down
4 changes: 2 additions & 2 deletions functions/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function DailyResetTimer() {
}, timeToMidnight());
}
function timeToMidnight(){
var d = new Date();
const d = new Date();
return (-d + d.setHours(24,0,0,0));
}
function EmoteDBStartup(client) {
Expand Down Expand Up @@ -149,7 +149,7 @@ function countEmotes(message) {
}

function msToTime(duration) {
var milliseconds = parseInt((duration % 1000) / 100),
let milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
Expand Down
9 changes: 4 additions & 5 deletions functions/tinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ const Tinder = new db.table("Tinder");
const Discord = require("discord.js");
const { timeToMidnight, msToTime } = require("./functions");

const time2mid = timeToMidnight();
const time2midHrs = msToTime(time2mid);

function tinderprofile(message) {
//...
}
Expand All @@ -26,11 +23,13 @@ function TinderDBService(user) { // This is the peak of JS
console.log("Tinder Database Service | Ran " + i + " changes.");
}
function NoLikes() {

const time2mid = timeToMidnight();
const time2midHrs = msToTime(time2mid);
return "You don't have any more likes!\nLikes and rolls reset in: " + time2midHrs;
}
function NoRolls() {

const time2mid = timeToMidnight();
const time2midHrs = msToTime(time2mid);
return "You don't have any more rolls!\nLikes and rolls reset in: " + time2midHrs;
}

Expand Down

0 comments on commit 9f52ead

Please sign in to comment.