From 0218583d24e0e4dcf6bd81b0454bef42478f91c8 Mon Sep 17 00:00:00 2001 From: admin_rb Date: Wed, 8 Apr 2026 11:37:01 +0200 Subject: [PATCH] migrated --- buttons/quotes/quotes_list_left.js | 4 +- buttons/quotes/quotes_list_right.js | 4 +- commands/legacy/nuts/nutsGet.js | 19 ++++-- commands/legacy/quotes/quoteadd.js | 2 +- commands/slash/applications/nuts.js | 62 ++++++++++--------- commands/slash/applications/quotes.js | 2 +- events/ClientReady.js | 4 +- selectMenus/quotes/quotes_list_mentionable.js | 2 +- 8 files changed, 58 insertions(+), 41 deletions(-) diff --git a/buttons/quotes/quotes_list_left.js b/buttons/quotes/quotes_list_left.js index 4d156fb..256315b 100644 --- a/buttons/quotes/quotes_list_left.js +++ b/buttons/quotes/quotes_list_left.js @@ -15,7 +15,7 @@ module.exports = { const db = mClient.db(process.env.M_DB) const quotesColl = db.collection('items_quotes') - const quotes = await quotesColl.find({ by: target.id }).toArray() + const quotes = await quotesColl.find({ userID: target.id }).toArray() var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1)) if (!index) { index = 0 } @@ -64,7 +64,7 @@ module.exports = { .setURL(messageLink) .setTitle(`- Quote #${index + 1} -`) .setDescription(description) - .setFooter({ text: (`${footer} #${found.messageID} <@${found.by}>`) }) + .setFooter({ text: (`${footer} #${found.messageID} <@${found.userID}>`) }) const select = new ActionRowBuilder() .addComponents( new UserSelectMenuBuilder() diff --git a/buttons/quotes/quotes_list_right.js b/buttons/quotes/quotes_list_right.js index 89b18e6..ee1f2e2 100644 --- a/buttons/quotes/quotes_list_right.js +++ b/buttons/quotes/quotes_list_right.js @@ -15,7 +15,7 @@ module.exports = { const db = mClient.db(process.env.M_DB) const quotesColl = db.collection('items_quotes') - const quotes = await quotesColl.find({ by: target.id }).toArray() + const quotes = await quotesColl.find({ userID: target.id }).toArray() var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1)) if (!index) { index = 0 } @@ -64,7 +64,7 @@ module.exports = { .setURL(messageLink) .setTitle(`- Quote #${index + 1} -`) .setDescription(description) - .setFooter({ text: (`${footer} #${found.messageID} <@${found.by}>`) }) + .setFooter({ text: (`${footer} #${found.messageID} <@${found.userID}>`) }) const select = new ActionRowBuilder() .addComponents( new UserSelectMenuBuilder() diff --git a/commands/legacy/nuts/nutsGet.js b/commands/legacy/nuts/nutsGet.js index 459dfff..5866f38 100644 --- a/commands/legacy/nuts/nutsGet.js +++ b/commands/legacy/nuts/nutsGet.js @@ -7,11 +7,11 @@ module.exports = { async execute(message, args) { const db = mClient.db(process.env.M_DB) const nutsColl = db.collection('items_nuts') + const nutsStatsColl = db.collection('stats_nuts') const cdColl = db.collection('items_cooldowns') - const cdData = await cdColl.findOne({ userID: message.author.id }) - if (cdData || cdData?.cooldown > (Date.now() / 1000)) { + if (cdData?.cooldown > (Date.now() / 1000)) { return await message.reply({ content: `Du kannst erst wieder nussen :(`, }) @@ -21,10 +21,10 @@ module.exports = { await cdColl.findOneAndUpdate({ userID: message.author.id }, { - $set: { + $set: { cooldown: cd, application: 'nuts' - } + } }, { upsert: true }) @@ -39,6 +39,17 @@ module.exports = { upsert: true }) + await nutsStatsColl.findOneAndUpdate( + { userID: message.author.id }, + { $inc: { [`stat.${amount}`]: 1 } }, + { upsert: true } + ) + + await nutsStatsColl.findOneAndUpdate( + { userID: "__global" }, + { $inc: { [`stat.${amount}`]: 1 } }, + { upsert: true } + ) let content = `Du hast ${amount} Nüsse bekommen! :chestnut:` if (!amount) { content = `Du hast leider keine Nüsse bekommen :(` diff --git a/commands/legacy/quotes/quoteadd.js b/commands/legacy/quotes/quoteadd.js index 4d6ab57..ff6b70d 100644 --- a/commands/legacy/quotes/quoteadd.js +++ b/commands/legacy/quotes/quoteadd.js @@ -45,7 +45,7 @@ module.exports = { messageID: quoteMessage.id, channelID: quoteChannel.id, guildID: quoteGuild.id, - by: msgData.author.id, + userID: msgData.author.id, count: 0 } }, { upsert: true }) diff --git a/commands/slash/applications/nuts.js b/commands/slash/applications/nuts.js index 6dfa62e..be21073 100644 --- a/commands/slash/applications/nuts.js +++ b/commands/slash/applications/nuts.js @@ -168,9 +168,9 @@ async function nutsStats(interaction) { var type = interaction?.options?.getString('type') || 'lookup' var target = interaction?.options?.getUser('lookup') || {} - if(type == 'global') { + if (type == 'global') { target.id = '__global' - } else if (!target?.id){ + } else if (!target?.id) { target = interaction.user } @@ -285,7 +285,7 @@ async function nutsNut(interaction, quickMode) { const formatNut = (amount) => `${amount} ${amount === 1 ? 'Nuss' : 'Nüsse'}` // check cooldown - if (cdData || cdData?.cooldown > Date.now() / 1000) { + if (cdData?.cooldown > Date.now() / 1000) { // on cooldown embed.setTitle('To Nut or Not to Nut...') embed.setDescription(` kannst du wieder nussen! ;)`) @@ -298,18 +298,7 @@ async function nutsNut(interaction, quickMode) { } embed.setDescription('\u200B') // pseudo animation - embed.setThumbnail(assets.box) - await interaction.editReply({ - embeds: [embed], - files: [`${asset_path}nuts_box.png`] - }) - await delay(1337) - embed.setThumbnail(assets.explosion) - await interaction.editReply({ - embeds: [embed], - files: [`${asset_path}nuts_explosion.gif`] - }) - await delay(1337) + // set 1 hour cooldown const cd = Math.floor((Date.now() + 3600000) / 1000) @@ -346,23 +335,40 @@ async function nutsNut(interaction, quickMode) { { upsert: true } ) - let assetFile - if (amount === 0) assetFile = assets.none - else if (amount > 8) assetFile = assets.high - else if (amount > 4) assetFile = assets.normal - else assetFile = assets.low - - embed.setTitle(`Du hast ${formatNut(amount)} bekommen!`) - embed.setThumbnail(assetFile) if (quickMode) { return interaction.editReply({ content: `Du hast ${formatNut(amount)} bekommen! :chestnut:` }) + } else { + embed.setImage(assets.box) + await interaction.editReply({ + embeds: [embed], + files: [`${asset_path}nuts_box.png`] + }) + await delay(1337) + embed.setImage(assets.explosion) + await interaction.editReply({ + embeds: [embed], + files: [`${asset_path}nuts_explosion.gif`] + }) + await delay(1337) + + let assetFile + if (amount === 0) assetFile = assets.none + else if (amount > 8) assetFile = assets.high + else if (amount > 4) assetFile = assets.normal + else assetFile = assets.low + + embed.setTitle(`Du hast ${formatNut(amount)} bekommen!`) + embed.setThumbnail(assetFile) + embed.setImage(null) + + return interaction.editReply({ + embeds: [embed], + files: [`${asset_path}${assetFile.split('://')[1]}`] + }) } - return interaction.editReply({ - embeds: [embed], - files: [`${asset_path}${assetFile.split('://')[1]}`] - }) + } module.exports = { data: new SlashCommandBuilder() @@ -446,4 +452,4 @@ module.exports = { break; } } -} \ No newline at end of file +} diff --git a/commands/slash/applications/quotes.js b/commands/slash/applications/quotes.js index 1e17dc6..31664ec 100644 --- a/commands/slash/applications/quotes.js +++ b/commands/slash/applications/quotes.js @@ -310,7 +310,7 @@ async function quotesLeaderboard(interaction, page = 1, limit = 5) { return { name: `${skip + index + 1}.`, - value: `[#${data.messageID}](https://discord.com/channels/${data.guildID}/${data.channelID}/${data.messageID})\n**by** <@${data.by}> • ⭐ ${data.count}\n_Posted on **${timestamp}**_\n${message.content}` + value: `[#${data.messageID}](https://discord.com/channels/${data.guildID}/${data.channelID}/${data.messageID})\n**by** <@${data.userID}> • ⭐ ${data.count}\n_Posted on **${timestamp}**_\n${message.content}` }; } catch { return { diff --git a/events/ClientReady.js b/events/ClientReady.js index 6bdcfcf..d2d6a8f 100644 --- a/events/ClientReady.js +++ b/events/ClientReady.js @@ -35,7 +35,7 @@ module.exports = { // Fetch birthday role const bdayRoleColl = db.collection('config_roles'); const bdayRoleEntry = await bdayRoleColl.findOne({ guildID: guild.id }); - const birthdayRoleID = bdayRoleEntry.roleID; + const birthdayRoleID = bdayRoleEntry?.roleID; if (!birthdayRoleID) { console.warn("No birthday role configured in DB"); @@ -54,7 +54,7 @@ module.exports = { console.error(`Failed to add birthday role to ${member.user.tag}:`, err) ); console.log(`Added birthday role to ${member.user.tag}`); - client.emit('Birthday', member); + //client.emit('Birthday', member); } else { // Default fallback: remove birthday role if present if (member.roles.cache.has(birthdayRoleID)) { diff --git a/selectMenus/quotes/quotes_list_mentionable.js b/selectMenus/quotes/quotes_list_mentionable.js index 6becef5..8fc862b 100644 --- a/selectMenus/quotes/quotes_list_mentionable.js +++ b/selectMenus/quotes/quotes_list_mentionable.js @@ -16,7 +16,7 @@ module.exports = { const target = await interaction.guild.members.fetch(interaction.members.keys().next().value) const db = mClient.db(process.env.M_DB) const quotesColl = db.collection('items_quotes') - const quotes = await quotesColl.find({ by: target.id }).toArray() + const quotes = await quotesColl.find({ userID: target.id }).toArray() const member = interaction.message.guild.members.cache.get(target.user.id) const memberRoles = member.roles.cache .filter((roles) => roles.id !== interaction.message.guild.id)