Skip to content

Commit

Permalink
Make more eye pleasing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattythedev01 committed Oct 14, 2024
1 parent 1f1ab6f commit 7b103a9
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 130 deletions.
6 changes: 4 additions & 2 deletions src/badges.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"badges": [
{
"name": "Staff",
"emoji": "<:Staff1:1293960445614493826>"
"emoji": "<:Staff1:1293960445614493826>",
"description": "For the lovely people who help the developers with the reviewing and developing of SimplyQuote"
},
{
"name": "Ongoingstreak",
"emoji": "<:flame:1293960724892094667>"
"emoji": "<:flame:1293960724892094667>",
"description": "Obtain this badge by having a 10+ day ongoing streak of uploading quotes!"
}
]
}
54 changes: 49 additions & 5 deletions src/commands/community/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ const {
ButtonStyle,
} = require("discord.js");
const Quote = require("../../schemas/qoutesSchema");
const badges = require("../../badges.json").badges;

module.exports = {
data: new SlashCommandBuilder()
.setName("lists")
.setDescription("Lists quotes or authors with pagination.")
.setDescription("Lists quotes, authors, or badges with pagination.")
.addStringOption((option) =>
option
.setName("type")
.setDescription("Choose to list quotes or authors")
.setDescription("Choose to list quotes, authors, or badges")
.setRequired(true)
.addChoices(
{ name: "Quotes", value: "quotes" },
{ name: "Authors", value: "authors" }
{ name: "Authors", value: "authors" },
{ name: "Badges", value: "badges" }
)
)
.addIntegerOption((option) =>
Expand All @@ -44,17 +46,25 @@ module.exports = {
pageSize,
skip
);
} else {
} else if (type === "authors") {
await module.exports.listAuthors(
client,
interaction,
page,
pageSize,
skip
);
} else if (type === "badges") {
await module.exports.listBadges(
client,
interaction,
page,
pageSize,
skip
);
}
} catch (err) {
console.error("[ERROR] Error in the listquotes command:", err);
console.error("[ERROR] Error in the lists command:", err);
await interaction.reply({
content: "An error occurred while executing the command.",
ephemeral: true,
Expand Down Expand Up @@ -138,6 +148,40 @@ module.exports = {
);
},

listBadges: async (client, interaction, page, pageSize, skip) => {
const totalBadges = badges.length;
const totalPages = Math.ceil(totalBadges / pageSize);

if (totalBadges === 0) {
return interaction.reply({
content: "No badges found in the database.",
ephemeral: true,
});
}

const paginatedBadges = badges.slice(skip, skip + pageSize);

const badgeDescriptions = paginatedBadges.map((badge, index) => {
return `${skip + index + 1}. ${badge.emoji} **${badge.name}**\n> ${
badge.description
}`;
});

const embed = new EmbedBuilder()
.setColor("#FFD700")
.setTitle(`Badges (Page ${page}/${totalPages})`)
.setDescription(badgeDescriptions.join("\n\n"))
.setTimestamp();

await module.exports.sendPaginatedEmbed(
interaction,
embed,
page,
totalPages,
"badges"
);
},

sendPaginatedEmbed: async (interaction, embed, page, totalPages, type) => {
const buttons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
Expand Down
37 changes: 21 additions & 16 deletions src/commands/general/information.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const tips = require("../../tip.json");
module.exports = {
data: new SlashCommandBuilder()
.setName("information")
.setDescription("Provides instructions on how to use the quote system.")
.setDescription("Discover the magic of our Quote System!")
.toJSON(),
testMode: false,
devOnly: false,
Expand All @@ -16,37 +16,42 @@ module.exports = {
try {
const randomTip = tips.tips[Math.floor(Math.random() * tips.tips.length)];
const infoEmbed = new EmbedBuilder()
.setColor("#FF6B6B") // Vibrant coral color
.setTitle("📚 Quote System Guide")
.setColor("#4A5EAD") // Royal blue color
.setTitle("✨ Embark on Your Quotation Odyssey ✨")
.setDescription(
"Welcome to our amazing Quote System! Here's how you can contribute and enjoy the wisdom shared by our community."
"Welcome, wordsmith, to a realm where wisdom flourishes and inspiration knows no bounds. Prepare to embark on an extraordinary journey through our Quote System!"
)
.addFields(
{
name: "📝 Adding a Quote",
name: "🖋️ Craft Your Legacy",
value:
"Use `/add-quote <category> <quote>` to contribute your favorite quotes to our database.",
"```/add-quote <category> <quote>```\nImmortalize your thoughts or share timeless wisdom. Every word you contribute weaves into the tapestry of our collective knowledge.",
},
{
name: "🌟 Quote Selection",
name: "🌠 Shine Among the Stars",
value:
"Your quote might be chosen to inspire others! Selected quotes are shared globally in designated channels every 24 hours.",
"Your quote could be the beacon that guides others! Every 24 hours, we cast a spotlight on select quotes, sharing them across our global network of inspiration seekers.",
},
{
name: "🔍 Categories",
name: "🗂️ Curate Your Collection",
value:
"Organize your quotes by category to make them easier to find and appreciate.",
"Categories are the constellations in our universe of quotes. Organize your insights to help others navigate the vast expanse of wisdom.",
},
{
name: "💡 Benefits",
name: "🎭 Unlock Your Potential",
value:
"Share wisdom, inspire others, and be part of a growing collection of thought-provoking quotes!",
"• Earn badges and climb the ranks\n• Watch your influence grow with each contribution\n• Inspire and be inspired by a community of thinkers",
},
{
name: "🚀 Begin Your Adventure",
value:
"Ready to leave your mark? Start by sharing your first quote and watch as your journey unfolds. The path to wisdom awaits!",
}
)
.setThumbnail(interaction.guild.iconURL({ dynamic: true }))
.setThumbnail(interaction.guild.iconURL({ dynamic: true, size: 256 }))
.setFooter({
text: `Pro Tip: ${randomTip}`,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
text: `💡 Sage Advice: ${randomTip}`,
iconURL: client.user.displayAvatarURL({ dynamic: true }),
})
.setTimestamp();

Expand All @@ -58,7 +63,7 @@ module.exports = {
);
await interaction.reply({
content:
"Oops! An error occurred while fetching the information. Please try again later or contact support if the issue persists.",
"Oh no! The cosmic energies seem to be misaligned. Please try again later or seek the wisdom of our support sages if the issue persists.",
ephemeral: true,
});
}
Expand Down
64 changes: 47 additions & 17 deletions src/commands/general/qouteLeaderboard.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const User = require("../../schemas/userSchema");
const tips = require("../../tip.json"); // Import the tips.json file
const Rating = require("../../schemas/ratingSchema");
const tips = require("../../tip.json");
const badges = require("../../badges.json");

module.exports = {
data: new SlashCommandBuilder()
.setName("quoteleaderboard")
.setDescription(
"Displays a leaderboard of users with the most quotes and highest ratings."
"Unveil the pantheon of quote masters and their celestial ratings."
)
.toJSON(),
testMode: false,
Expand All @@ -17,43 +19,70 @@ module.exports = {

run: async (client, interaction) => {
try {
// Aggregate quotes to count per user, sum ratings, and sort by count and ratings in descending order
const leaderboard = await User.aggregate([
{
$lookup: {
from: "ratings",
localField: "userID",
foreignField: "userID",
as: "ratings",
},
},
{
$group: {
_id: "$userID",
totalQuotes: { $sum: 1 },
totalRatings: { $sum: "$rating" },
totalQuotes: { $sum: "$numberOfQuotes" },
totalRatings: { $sum: { $size: "$ratings" } },
avgRating: { $avg: "$ratings.rating" },
},
},
{ $sort: { totalQuotes: -1, totalRatings: -1 } },
{ $limit: 10 }, // Limit to top 10 users
{ $sort: { totalQuotes: -1, avgRating: -1 } },
{ $limit: 10 },
]);

if (leaderboard.length === 0) {
await interaction.reply({
content: "No quotes found in the database.",
content:
"The cosmic library awaits its first scribes. Be the pioneer!",
ephemeral: true,
});
return;
}

// Fetch usernames for each user ID in the leaderboard
const leaderboardWithNames = await Promise.all(
leaderboard.map(async (entry) => {
const leaderboardWithDetails = await Promise.all(
leaderboard.map(async (entry, index) => {
const user = await client.users.fetch(entry._id);
return `${user.username}: ${entry.totalQuotes} quotes, ${entry.totalRatings} ratings`;
const userData = await User.findOne({ userID: entry._id });
const badgeEmojis = userData.Badges.map((badgeName) => {
const badge = badges.badges.find((b) => b.name === badgeName);
return badge ? badge.emoji : "";
}).join(" ");

return {
name: `${index + 1}. ${user.username}`,
value: `Quotes: ${entry.totalQuotes} | Avg Rating: ${
entry.avgRating ? entry.avgRating.toFixed(2) : "N/A"
} ⭐\nStreak: ${userData.streaks} 🔥 | Badges: ${
badgeEmojis || "None yet"
}`,
inline: false,
};
})
);

const randomTip = tips.tips[Math.floor(Math.random() * tips.tips.length)];

const embed = new EmbedBuilder()
.setColor("#0099ff")
.setTitle("Quote Leaderboard")
.setDescription(leaderboardWithNames.join("\n"))
.setColor("#4A5EAD")
.setTitle("🏆 Quotation Pantheon: Masters of Wisdom 🏆")
.setDescription(
"Behold the luminaries whose words light up our cosmic library!"
)
.addFields(leaderboardWithDetails)
.setThumbnail(interaction.guild.iconURL({ dynamic: true, size: 256 }))
.setFooter({
text: `Tip: ${randomTip}`, // Use the random tip in the footer
text: `💡 Sage Wisdom: ${randomTip}`,
iconURL: client.user.displayAvatarURL({ dynamic: true }),
})
.setTimestamp();

Expand All @@ -67,7 +96,8 @@ module.exports = {
err
);
await interaction.reply({
content: "An error occurred while executing the command.",
content:
"The cosmic energies are misaligned. Our sage librarians are working to restore balance. Please try again later.",
ephemeral: true,
});
}
Expand Down
47 changes: 31 additions & 16 deletions src/commands/misc/bot-stats.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const quoteSchema = require("../../schemas/qoutesSchema"); // Updated to use quoteSchema
const defaultQuotes = require("../../defaultQuotes.json"); // Path to defaultQuotes.json
const tips = require("../../tip.json"); // Import the tips.json file
const quoteSchema = require("../../schemas/qoutesSchema");
const defaultQuotes = require("../../defaultQuotes.json");
const tips = require("../../tip.json");

module.exports = {
data: new SlashCommandBuilder()
.setName("bot-stats")
.setDescription("Get statistics about the bot")
.setDescription("Unveil the cosmic tapestry of our bot's journey")
.toJSON(),
userPermissions: [],
botPermissions: [],
Expand All @@ -17,27 +17,42 @@ module.exports = {
(acc, guild) => acc + guild.memberCount,
0
);
const totalQuotes = await quoteSchema.countDocuments(); // Updated to use quoteSchema
const totalDefaultQuotes = defaultQuotes.length; // Get the total number of default quotes
const totalQuotes = await quoteSchema.countDocuments();
const totalDefaultQuotes = defaultQuotes.length;
const randomTip = tips.tips[Math.floor(Math.random() * tips.tips.length)];

const statsEmbed = new EmbedBuilder()
.setColor("#4A5EAD")
.setTitle("🤖 Bot Statistics 📊")
.setDescription("Here's a quick glance at some cool stats")
.setColor("#1E90FF")
.setTitle("Bot Statistics 🚀")
.setDescription(
"Embark on a journey through the celestial tapestry of our bot's universe!"
)
.addFields(
{ name: "🏠 Guilds", value: `${totalGuilds}`, inline: true },
{ name: "👥 Members", value: `${totalMembers}`, inline: true },
{ name: "💬 Community Quotes", value: `${totalQuotes}`, inline: true },
{
name: "📜 Default Quotes",
value: `${totalDefaultQuotes}`,
name: "🏰 Realms Enlightened",
value: `\`\`\`${totalGuilds.toLocaleString()}\`\`\``,
inline: true,
},
{
name: "👥 Starfarers United",
value: `\`\`\`${totalMembers.toLocaleString()}\`\`\``,
inline: true,
},
{
name: "💬 Cosmic Whispers",
value: `\`\`\`${totalQuotes.toLocaleString()}\`\`\``,
inline: true,
},
{
name: "📜 Primordial Wisdom",
value: `\`\`\`${totalDefaultQuotes.toLocaleString()}\`\`\``,
inline: true,
}
)
.setThumbnail(client.user.displayAvatarURL({ dynamic: true, size: 512 }))
.setFooter({
text: `Tip: ${randomTip}`, // Use the random tip in the footer
iconURL: client.user.displayAvatarURL(),
text: `💫 Astral Insight: ${randomTip}`,
iconURL: client.user.displayAvatarURL({ dynamic: true }),
})
.setTimestamp();

Expand Down
Loading

0 comments on commit 7b103a9

Please sign in to comment.