diff --git a/buttons/honor/honor_menu_dishonor.js b/buttons/honor/honor_menu_dishonor.js index c499851..ed16d85 100644 --- a/buttons/honor/honor_menu_dishonor.js +++ b/buttons/honor/honor_menu_dishonor.js @@ -9,7 +9,7 @@ module.exports = { let description = interaction.message.embeds[0].data.description const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1)) const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') const reason = `[-] Quick Menu Dishonor` const theirHonorLevel = await honorsColl.findOne({ userID: target.id }) diff --git a/buttons/honor/honor_menu_history.js b/buttons/honor/honor_menu_history.js index 45cfbba..73fd99b 100644 --- a/buttons/honor/honor_menu_history.js +++ b/buttons/honor/honor_menu_history.js @@ -9,7 +9,7 @@ module.exports = { let description = interaction.message.embeds[0].data.description const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1)) const db = mClient.db(process.env.M_DB) - const reasonsColl = db.collection('honor-reasons') + const reasonsColl = db.collection('history_honors') const history = await reasonsColl.findOne({ userID: target.user.id }) const embed = new EmbedBuilder() diff --git a/buttons/honor/honor_menu_honor.js b/buttons/honor/honor_menu_honor.js index 5252636..9fd5c19 100644 --- a/buttons/honor/honor_menu_honor.js +++ b/buttons/honor/honor_menu_honor.js @@ -9,7 +9,7 @@ module.exports = { let description = interaction.message.embeds[0].data.description const target = await interaction.guild.members.fetch(description.split(' ')[0].slice(2, -1)) const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') const reason = `[+] Quick Menu Honor` const theirHonorLevel = await honorsColl.findOne({ userID: target.id }) diff --git a/buttons/honor/honor_multi_confirm.js b/buttons/honor/honor_multi_confirm.js index bb23d6d..d6199c1 100644 --- a/buttons/honor/honor_multi_confirm.js +++ b/buttons/honor/honor_multi_confirm.js @@ -20,8 +20,8 @@ module.exports = { const reason = `${temp[1].slice(7, -1)}` const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') - const reasonsColl = db.collection('honor-reasons') + const honorsColl = db.collection('items_honors') + const reasonsColl = db.collection('history_honors') const theirHonorLevel = await honorsColl.findOne({ userID: target.id }) await honorsColl.findOneAndUpdate({ userID: target.id }, { $inc: { honors: honor } }, { upsert: true }) diff --git a/buttons/honor/honors_leaderboard_left.js b/buttons/honor/honors_leaderboard_left.js index 9480798..e97e69c 100644 --- a/buttons/honor/honors_leaderboard_left.js +++ b/buttons/honor/honors_leaderboard_left.js @@ -7,7 +7,7 @@ module.exports = { description: 'navigate a page up', async execute(interaction) { const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') const min = 0 let skip = interaction.message.embeds[0].data.description.split('.') skip = Number(skip[0]) - 6 diff --git a/buttons/honor/honors_leaderboard_right.js b/buttons/honor/honors_leaderboard_right.js index 5cfe146..55f8878 100644 --- a/buttons/honor/honors_leaderboard_right.js +++ b/buttons/honor/honors_leaderboard_right.js @@ -6,7 +6,7 @@ module.exports = { description: 'navigate a page down', async execute(interaction) { const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') const max = await honorsColl.countDocuments() let skip = interaction.message.embeds[0].data.description.split('.') skip = Number(skip[0]) +4 diff --git a/buttons/honor/honors_leaderboard_self.js b/buttons/honor/honors_leaderboard_self.js index 8149056..bea20a5 100644 --- a/buttons/honor/honors_leaderboard_self.js +++ b/buttons/honor/honors_leaderboard_self.js @@ -6,7 +6,7 @@ module.exports = { description: 'navigate to your own placement', async execute(interaction) { const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') const self = await honorsColl.find({ userID: interaction.user.id }).toArray() const all = await honorsColl.find().sort({ honors: -1 }).toArray() diff --git a/buttons/nuts/nuts_give_confirm.js b/buttons/nuts/nuts_give_confirm.js index 800995f..e288ce9 100644 --- a/buttons/nuts/nuts_give_confirm.js +++ b/buttons/nuts/nuts_give_confirm.js @@ -12,7 +12,7 @@ module.exports = { const to = await interaction.message.guild.members.fetch(temp[6].slice(2,-1)) const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') await nutsColl.findOneAndUpdate({ userID: from.id }, { $inc: { nuts: -amount } }, { upsert: true }) await nutsColl.findOneAndUpdate({ userID: to.id }, { $inc: { nuts: +amount } }, { upsert: true }) diff --git a/buttons/nuts/nuts_give_fake.js b/buttons/nuts/nuts_give_fake.js index 57ac848..5226238 100644 --- a/buttons/nuts/nuts_give_fake.js +++ b/buttons/nuts/nuts_give_fake.js @@ -10,7 +10,7 @@ module.exports = { const to = await interaction.message.guild.members.fetch(temp[6].slice(2,-1)) const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') const yourBalance = await nutsColl.findOne({ userID: from.id }) const theirBalance = await nutsColl.findOne({ userID: to.id }) diff --git a/buttons/nuts/nuts_leaderboard_left.js b/buttons/nuts/nuts_leaderboard_left.js index 9b4fee8..86908cc 100644 --- a/buttons/nuts/nuts_leaderboard_left.js +++ b/buttons/nuts/nuts_leaderboard_left.js @@ -7,7 +7,7 @@ module.exports = { description: 'navigate a page up', async execute(interaction) { const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') const min = 0 let skip = interaction.message.embeds[0].data.description.split('.') skip = Number(skip[0]) - 6 diff --git a/buttons/nuts/nuts_leaderboard_right.js b/buttons/nuts/nuts_leaderboard_right.js index f8225d4..7c41ec1 100644 --- a/buttons/nuts/nuts_leaderboard_right.js +++ b/buttons/nuts/nuts_leaderboard_right.js @@ -6,7 +6,7 @@ module.exports = { description: 'navigate a page down', async execute(interaction) { const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') const max = await nutsColl.countDocuments({ nuts: { $gt: 0 } }) let skip = interaction.message.embeds[0].data.description.split('.') skip = Number(skip[0]) +4 diff --git a/buttons/nuts/nuts_leaderboard_self.js b/buttons/nuts/nuts_leaderboard_self.js index d295c9b..edbd454 100644 --- a/buttons/nuts/nuts_leaderboard_self.js +++ b/buttons/nuts/nuts_leaderboard_self.js @@ -6,7 +6,7 @@ module.exports = { description: 'navigate to your own placement', async execute(interaction) { const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') const self = await nutsColl.find({ userID: interaction.user.id }).toArray() const all = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).toArray() diff --git a/buttons/quotes/quotes_leaderboard_left.js b/buttons/quotes/quotes_leaderboard_left.js index 4e2224b..0d6844c 100644 --- a/buttons/quotes/quotes_leaderboard_left.js +++ b/buttons/quotes/quotes_leaderboard_left.js @@ -8,7 +8,7 @@ module.exports = { async execute(interaction) { await interaction.deferReply() const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] }) let skip = interaction.message.embeds[0].data.fields[0].value.split('.') diff --git a/buttons/quotes/quotes_leaderboard_right.js b/buttons/quotes/quotes_leaderboard_right.js index 5b69312..b5d96e8 100644 --- a/buttons/quotes/quotes_leaderboard_right.js +++ b/buttons/quotes/quotes_leaderboard_right.js @@ -8,7 +8,7 @@ module.exports = { async execute(interaction) { await interaction.deferReply() const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] }) let skip = interaction.message.embeds[0].data.fields[0].value.split('.') diff --git a/buttons/quotes/quotes_list_left.js b/buttons/quotes/quotes_list_left.js index c6c556a..16c7dae 100644 --- a/buttons/quotes/quotes_list_left.js +++ b/buttons/quotes/quotes_list_left.js @@ -14,7 +14,7 @@ module.exports = { if (!target) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) } const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') const quotes = await quotesColl.find({ by: target.id }).toArray() var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1)) diff --git a/buttons/quotes/quotes_list_right.js b/buttons/quotes/quotes_list_right.js index c0bf531..432b28f 100644 --- a/buttons/quotes/quotes_list_right.js +++ b/buttons/quotes/quotes_list_right.js @@ -14,7 +14,7 @@ module.exports = { if (!target) { return interaction.reply({ content: 'Please use a Filter', ephemeral: true }) } const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') const quotes = await quotesColl.find({ by: target.id }).toArray() var index = Number((await interaction.message.embeds[0].data.title).split(' ')[2].slice(1)) diff --git a/commands/channels/channels.js b/commands/channels/channels.js deleted file mode 100644 index 9b5ab16..0000000 --- a/commands/channels/channels.js +++ /dev/null @@ -1,106 +0,0 @@ -const { SlashCommandBuilder, Events } = require('discord.js') -const { mClient } = require('../..') -require('dotenv').config() - -async function channelSet(interaction) { - const channel = interaction.options.getChannel('channel') - const purpose = interaction.options.getString('purpose') - const db = mClient.db(process.env.DB) - const channelColl = db.collection('channels') - - await channelColl.findOneAndUpdate({ - $and: [{ guildID: channel.guild.id }, { purpose: purpose }] - }, { - $set: { - guildID: channel.guild.id, - purpose: purpose, - channelID: channel.id - } - }, { - upsert: true - }) - - return await interaction.editReply({ - content: `Set <#${channel.id}> as ${purpose} channel!`, ephemeral: true - }) -} -async function channelSimulate(interaction) { - const purpose = interaction.options.getString('purpose') - switch (purpose) { - case 'birthday': - await interaction.client.emit('Birthday', interaction.member) - break; - case 'wge': - // For Future WGE Use - break; - case 'welcome': - await interaction.client.emit(Events.GuildMemberAdd, interaction.member) - break; - case 'logs': - // For Future Log Use - break; - default: - break; - } - return interaction.reply({ content: 'Done.', ephemeral: true }) -} -module.exports = { - data: new SlashCommandBuilder() - .setName('channels') - .setDescription('rund um den honor') - .addSubcommand(s => - s - .setName('set') - .setDescription('set a channel for a specific purpose') - .addStringOption(o => - o.setName('purpose').setDescription('set the purpose').setRequired(true).addChoices({ - name: 'birthday', - value: 'birthday' - }, { - name: 'welcome', - value: 'welcome' - }, { - name: 'logs', - value: 'logs' - }, { - name: 'wge', - value: 'wge' - })) - .addChannelOption(c => - c.setName('channel').setDescription('choose a channel').setRequired(true) - ) - ) - .addSubcommand(s => - s - .setName('simulate') - .setDescription('simulate a specific channel event') - .addStringOption(o => - o.setName('purpose').setDescription('set the purpose').setRequired(true).addChoices({ - name: 'birthday', - value: 'birthday' - }, { - name: 'welcome', - value: 'welcome' - }, { - name: 'logs', - value: 'logs' - }, { - name: 'wge', - value: 'wge' - })) - ) - , - async execute(interaction) { - switch (interaction.options._subcommand) { - case 'set': - await interaction.deferReply() - channelSet(interaction) - break; - case 'simulate': - channelSimulate(interaction) - break; - default: - break; - } - } -} \ No newline at end of file diff --git a/commands/config/config.js b/commands/config/config.js new file mode 100644 index 0000000..0c521d8 --- /dev/null +++ b/commands/config/config.js @@ -0,0 +1,169 @@ +const { SlashCommandBuilder, Events } = require('discord.js') +const { mClient } = require('../..') +require('dotenv').config() + +async function channelSet(interaction) { + const channel = interaction.options.getChannel('channel') + const purpose = interaction.options.getString('purpose') + const db = mClient.db(process.env.M_DB) + const channelColl = db.collection('config_channels') + + await channelColl.findOneAndUpdate({ + $and: [{ guildID: channel.guild.id }, { purpose: purpose }] + }, { + $set: { + guildID: channel.guild.id, + purpose: purpose, + channelID: channel.id + } + }, { + upsert: true + }) + + return await interaction.editReply({ + content: `Set <#${channel.id}> as ${purpose} channel!`, ephemeral: true + }) +} +async function channelSimulate(interaction) { + const purpose = interaction.options.getString('purpose') + switch (purpose) { + case 'birthday': + await interaction.client.emit('Birthday', interaction.member) + break; + case 'wge': + // For Future WGE Use + break; + case 'welcome': + await interaction.client.emit(Events.GuildMemberAdd, interaction.member) + break; + case 'logs': + // For Future Log Use + break; + default: + break; + } + return interaction.reply({ content: 'Done.', ephemeral: true }) +} +async function roleSet(interaction) { + const guild = interaction.guild + const purpose = interaction.options.getString('purpose') + const role = interaction.options.getRole('role') + + const db = mClient.db(process.env.M_DB) + const roleColl = db.collection('config_roles') + + switch (purpose) { + case 'birthday': + await roleColl.findOneAndUpdate({ + $and: [{ guildID: guild.id }, { purpose: purpose }] + }, { + $set: { + guildID: guild.id, + purpose: purpose, + roleID: role.id + } + }, { + upsert: true + }) + break; + default: + break; + } + + return await interaction.editReply({ + content: `Set ${role} as default role for ${purpose} in ${guild} ` + }) +} +module.exports = { + data: new SlashCommandBuilder() + .setName('config') + .setDescription('configurations for admins') + .addSubcommandGroup(sg => + sg + .setName('channels') + .setDescription('configure channels for certain events') + .addSubcommand(s => + s.setName('set') + .setDescription('sets channel') + .addStringOption(o => + o.setName('purpose').setDescription('set the purpose').setRequired(true).addChoices({ + name: 'birthday', + value: 'birthday' + }, { + name: 'welcome', + value: 'welcome' + }, { + name: 'logs', + value: 'logs' + }, { + name: 'wge', + value: 'wge' + })) + .addChannelOption(c => + c.setName('channel').setDescription('choose a channel').setRequired(true) + ) + ) + .addSubcommand(s => + s + .setName('simulate') + .setDescription('simulate a specific channel event') + .addStringOption(o => + o.setName('purpose').setDescription('set the purpose').setRequired(true).addChoices({ + name: 'birthday', + value: 'birthday' + }, { + name: 'welcome', + value: 'welcome' + }, { + name: 'logs', + value: 'logs' + }, { + name: 'wge', + value: 'wge' + })) + ) + ) + .addSubcommandGroup(sg => + sg.setName('roles') + .setDescription('configure roles for certain events') + .addSubcommand(s => + s.setName('set') + .setDescription('sets roles') + .addStringOption(o => + o.setName('purpose').setDescription('set the purpose').setRequired(true).addChoices({ + name: 'birthday', + value: 'birthday' + })) + .addRoleOption(c => + c.setName('role').setDescription('choose a role').setRequired(true) + ) + ) + ), + async execute(interaction) { + switch (interaction.options._group) { + case 'channels': + switch (interaction.options._subcommand) { + case 'set': + await interaction.deferReply() + channelSet(interaction) + break; + case 'simulate': + channelSimulate(interaction) + break; + default: + break; + } + case 'roles': + switch (interaction.options._subcommand) { + case 'set': + await interaction.deferReply() + roleSet(interaction) + break; + default: + break; + } + default: + break; + } + } +} \ No newline at end of file diff --git a/commands/honors/honors.js b/commands/honors/honors.js index 7000810..17f5430 100644 --- a/commands/honors/honors.js +++ b/commands/honors/honors.js @@ -5,7 +5,7 @@ function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function honorHoner(interaction) { const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') const target = await interaction.options.getUser('target') const reason = `[+] ${await interaction.options.getString('reason') ?? 'No reason provided'}` @@ -40,7 +40,7 @@ async function honorHoner(interaction) { } async function honerDishonor(interaction) { const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') const target = await interaction.options.getUser('target') const reason = `[-] ${await interaction.options.getString('reason') ?? 'No reason provided'}` @@ -93,7 +93,7 @@ async function honorLeaderboard(interaction) { .setCustomId('honors_leaderboard_right') ) const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') let skip = 0 const honorsData = await honorsColl.find({}).sort({ honors: -1 }).skip(skip).limit(5).toArray() let fields @@ -116,7 +116,7 @@ async function honorHistory(interaction) { var target = interaction.options.getUser('target') if (!target) { target = interaction.user } const db = mClient.db(process.env.M_DB) - const reasonsColl = db.collection('honor-reasons') + const reasonsColl = db.collection('history_honors') var history = await reasonsColl.findOne({ userID: target.id }) const embed = new EmbedBuilder() @@ -136,7 +136,7 @@ async function honorCheck(interaction) { var target = interaction.options.getUser('target') if (!target) { target = interaction.user } const db = mClient.db(process.env.M_DB) - const honorsColl = db.collection('honors') + const honorsColl = db.collection('items_honors') var honors = await honorsColl.findOne({ userID: target.id }) honors = honors?.honors ?? 0 diff --git a/commands/nuts/nuts.js b/commands/nuts/nuts.js index 139dd16..1fb4993 100644 --- a/commands/nuts/nuts.js +++ b/commands/nuts/nuts.js @@ -39,7 +39,7 @@ async function nutsGive(interaction) { var amount = await interaction.options.getNumber('amount') const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') const yourBalance = await nutsColl.findOne({ userID: from.id }) const theirBalance = await nutsColl.findOne({ userID: to.id }) if (amount <= 0) { @@ -69,7 +69,7 @@ async function nutsCheck(interaction) { } const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') const nutsData = await nutsColl.findOne({ userID: target.id }) let content @@ -118,7 +118,7 @@ async function nutsLeaderboard(interaction) { .setCustomId('nuts_leaderboard_right') ) const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') let skip = 0 const nutsData = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).skip(skip).limit(5).toArray() let fields @@ -139,7 +139,7 @@ async function nutsLeaderboard(interaction) { } async function nutsStats(interaction) { const db = mClient.db(process.env.M_DB) - const nStatsColl = db.collection('nut-stats') + const nStatsColl = db.collection('stats_nuts') const stats = await nStatsColl.find({}).sort({ amount: 1 }).toArray() let nutMin = { count: 0, @@ -188,7 +188,7 @@ async function nutsStats(interaction) { } async function nutsCooldown(interaction) { const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('cooldown') + const nutsColl = db.collection('items_cooldowns') const cooldown = await nutsColl.findOne({ userID: interaction.user.id }) let content = `Du kannst wieder nussen! :)` @@ -213,8 +213,8 @@ async function nutsCooldown(interaction) { } async function nutsNut(interaction) { const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') - const cdColl = db.collection('cooldown') + const nutsColl = db.collection('items_nuts') + const cdColl = db.collection('items_cooldowns') const cdData = await cdColl.findOne({ userID: interaction.user.id }) const embed = new EmbedBuilder() diff --git a/commands/quotes/quotes.js b/commands/quotes/quotes.js index 32559aa..c5327e9 100644 --- a/commands/quotes/quotes.js +++ b/commands/quotes/quotes.js @@ -48,7 +48,7 @@ async function quotesAdd(interaction) { } const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') const found = await quotesColl.findOne({ messageID: messageID }) if (found) { return await interaction.editReply({ content: 'Quote Already in Database', ephemeral: true }) } await quotesColl.findOneAndUpdate({ messageID: messageID }, { @@ -87,7 +87,7 @@ async function quotesRemove(interaction) { const id = await interaction.options.getString('id') const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') const found = await quotesColl.findOne({ messageID: id }) if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) } @@ -98,7 +98,7 @@ async function quotesRemove(interaction) { async function quotesSearch(interaction) { const id = interaction.options.getString("id") const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') const found = await quotesColl.findOne({ messageID: id }) if (!found) { return await interaction.reply({ content: 'ID not found!', ephemeral: true }) } @@ -158,7 +158,7 @@ async function quotesSearch(interaction) { async function quotesRandom(interaction) { var user = interaction.options.getUser("by") const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') var rdm if (user) { rdm = await quotesColl.aggregate([ @@ -269,7 +269,7 @@ async function quotesList(interaction) { } async function quotesLeaderboard(interaction) { const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') let skip = 0 const minValue = 0 const maxValue = await quotesColl.countDocuments({ $and: [{ guildID: interaction.guild.id }, { count: { $gt: 0 } }] }) diff --git a/commands/social/birthday.js b/commands/social/birthday.js index 47c7d3e..f9b9997 100644 --- a/commands/social/birthday.js +++ b/commands/social/birthday.js @@ -44,7 +44,7 @@ async function birthdayAdd(interaction) { } const db = mClient.db(process.env.M_DB) - const bdayColl = db.collection('birthdays') + const bdayColl = db.collection('items_birthdays') const found = await bdayColl.findOne({ userID: target.id }) if (found) { @@ -77,7 +77,7 @@ async function birthdayDelete(interaction) { } const db = mClient.db(process.env.M_DB) - const bdayColl = db.collection('birthdays') + const bdayColl = db.collection('items_birthdays') const found = await bdayColl.findOne({ userID: target.id }) if (!found) { @@ -102,7 +102,7 @@ async function birthdayEdit(interaction) { } const db = mClient.db(process.env.M_DB) - const bdayColl = db.collection('birthdays') + const bdayColl = db.collection('items_birthdays') const found = await bdayColl.findOne({ userID: target.id }) if (!found) { @@ -143,7 +143,7 @@ function isToday(day, month) { async function birthdayGet(interaction) { let target = await interaction.options.getUser('user') const db = mClient.db(process.env.M_DB) - const bdayColl = db.collection('birthdays') + const bdayColl = db.collection('items_birthdays') const found = await bdayColl.findOne({ userID: target.id }) if (!found) { diff --git a/events/Birthday.js b/events/Birthday.js index d2b4237..d0f0da1 100644 --- a/events/Birthday.js +++ b/events/Birthday.js @@ -8,11 +8,11 @@ module.exports = { once: false, async execute(member, client) { console.log(`${member.user.username} hat Geburtstag!`) + let found = null - - const db = mClient.db(process.env.DB) - const channelsColl = db.collection('channels') - const found = await channelsColl.find( + const db = mClient.db(process.env.M_DB) + const channelsColl = db.collection('config_channels') + found = await channelsColl.find( { $and: [ { guildID: member.guild.id }, @@ -25,12 +25,13 @@ module.exports = { return console.log('Channel not yet set for birthday!') } - const guild = client.guilds.cache.get(found[0].guildID); const channel = guild.channels.cache.get(found[0].channelID); - - const roleID = '702877228857557002' - const role = guild.roles.cache.get(roleID) + const roleColl = db.collection('config_roles') + + // Bot Role MUST BE above birthday Role, Birthday Role MUST BE above user roles + found = await roleColl.findOne({guildID: member.guild.id}) + const role = guild.roles.cache.get(found.roleID) try { await member.roles.add(role) @@ -79,8 +80,9 @@ module.exports = { ctx.strokeText(text, textX, 60 + pfp.height); ctx.fillText(text, textX, 60 + pfp.height); - ctx.font = '30px sans-serif'; - text = `🥳 ${member.user.globalName ? member.user.globalName : member.user.username} 🎉`; + // requires apt-get install ttf-ancient-fonts + ctx.font = '30px "Noto Emoji", "Segoe UI Emoji", "Apple Color Emoji", sans-serif'; + text = `🎉 ${member.user.globalName ? member.user.globalName : member.user.username} 🎉`; textWidth = ctx.measureText(text).width; textX = canvas.width / 2 - textWidth / 2; textHeight = 30; // Approximate height of the text diff --git a/events/ClientReady.js b/events/ClientReady.js index e2926a2..6bdcfcf 100644 --- a/events/ClientReady.js +++ b/events/ClientReady.js @@ -5,7 +5,9 @@ module.exports = { name: Events.ClientReady, once: true, async execute(client) { - console.log(`Ready! Logged in as ${client.user.tag}`) + console.log(`Ready! Logged in as ${client.user.tag}`); + + // Set presence client.user.setPresence({ activities: [{ name: 'Red Dead Depression', @@ -13,40 +15,58 @@ module.exports = { url: 'https://twitch.tv/desq_blocki' }], status: 'online' - }) + }); - // if today is birthday - function isToday(day, month) { - const currentYear = new Date().getFullYear(); - const inputDate = new Date(currentYear, month - 1, day); + // Check if a date matches today + const isToday = (day, month) => { const today = new Date(); - return ( - inputDate.getDate() === today.getDate() && - inputDate.getMonth() === today.getMonth() && - inputDate.getFullYear() === today.getFullYear() - ); - } - async function isBirthday() { - const db = mClient.db(process.env.M_DB) - const bdayColl = db.collection('birthdays') - const allBirthdays = await bdayColl.find().toArray() - for (let index = 0; index < allBirthdays.length; index++) { - if (isToday(allBirthdays[index].day, allBirthdays[index].month)) { - let guild = client.guilds.cache.get(process.env.D_GuildID) - let member = guild.members.cache.get(allBirthdays[index].userID) - client.emit('Birthday', member) + return today.getDate() === day && today.getMonth() === month - 1; + }; + + // Handle birthdays + const handleBirthdays = async () => { + const guild = await client.guilds.fetch(process.env.D_GuildID); + const db = mClient.db(process.env.M_DB); + + const bdayColl = db.collection('items_birthdays'); + const allBirthdays = await bdayColl.find().toArray(); + const bdayMap = new Map(allBirthdays.map(b => [b.userID, b])); + + // Fetch birthday role + const bdayRoleColl = db.collection('config_roles'); + const bdayRoleEntry = await bdayRoleColl.findOne({ guildID: guild.id }); + const birthdayRoleID = bdayRoleEntry.roleID; + + if (!birthdayRoleID) { + console.warn("No birthday role configured in DB"); + return; + } + + // Fetch all guild members + const members = await guild.members.fetch(); + + for (const member of members.values()) { + const dbEntry = bdayMap.get(member.id); + + if (dbEntry && isToday(dbEntry.day, dbEntry.month)) { + // Today is their birthday + await member.roles.add(birthdayRoleID).catch(err => + 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); } else { - // remove any residual birthday roles - try { - let guild = client.guilds.cache.get(process.env.D_GuildID) - let member = guild.members.cache.get(allBirthdays[index].userID) - await member.roles.remove('702877228857557002') - } catch (error) { - console.error('Could not remove role', error) + // Default fallback: remove birthday role if present + if (member.roles.cache.has(birthdayRoleID)) { + await member.roles.remove(birthdayRoleID).catch(err => + console.error(`Failed to remove birthday role from ${member.user.tag}:`, err) + ); + console.log(`Removed birthday role from ${member.user.tag} (not today or not in DB)`); } } } - } - isBirthday() + }; + + await handleBirthdays(); } -} +}; \ No newline at end of file diff --git a/events/GuildMemberAdd.js b/events/GuildMemberAdd.js index 4d1bef3..271b6b2 100644 --- a/events/GuildMemberAdd.js +++ b/events/GuildMemberAdd.js @@ -9,8 +9,8 @@ module.exports = { once: false, async execute(member, client) { console.log(`${member.user.username} joined the Server`); - const db = mClient.db(process.env.DB) - const channelsColl = db.collection('channels') + const db = mClient.db(process.env.M_DB) + const channelsColl = db.collection('config_channels') const found = await channelsColl.find( { $and: [ diff --git a/legacyCommands/nuts/nutsCheck.js b/legacyCommands/nuts/nutsCheck.js index 580dd6a..4f81afc 100644 --- a/legacyCommands/nuts/nutsCheck.js +++ b/legacyCommands/nuts/nutsCheck.js @@ -32,7 +32,7 @@ module.exports = { } } const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') var nutsData = await nutsColl.findOne({ userID: target.id }) let content diff --git a/legacyCommands/nuts/nutsCooldown.js b/legacyCommands/nuts/nutsCooldown.js index 7cec55d..b2c818b 100644 --- a/legacyCommands/nuts/nutsCooldown.js +++ b/legacyCommands/nuts/nutsCooldown.js @@ -7,7 +7,7 @@ module.exports = { aliases: ['ncd'], async execute(message, args) { const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('cooldown') + const nutsColl = db.collection('items_cooldowns') const cooldown = await nutsColl.findOne({ userID: message.author.id }) let content = `Du kannst wieder nussen! :)` diff --git a/legacyCommands/nuts/nutsGet.js b/legacyCommands/nuts/nutsGet.js index b0cf1b3..0de7966 100644 --- a/legacyCommands/nuts/nutsGet.js +++ b/legacyCommands/nuts/nutsGet.js @@ -6,8 +6,8 @@ module.exports = { aliases: ['n', 'nget', 'nutsget'], async execute(message, args) { const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') - const cdColl = db.collection('cooldown') + const nutsColl = db.collection('items_nuts') + const cdColl = db.collection('items_cooldowns') const cdData = await cdColl.findOne({ userID: message.author.id }) diff --git a/legacyCommands/nuts/nutsGive.js b/legacyCommands/nuts/nutsGive.js index e6189a9..7bd94e3 100644 --- a/legacyCommands/nuts/nutsGive.js +++ b/legacyCommands/nuts/nutsGive.js @@ -48,7 +48,7 @@ module.exports = { } const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') const yourBalance = await nutsColl.findOne({ userID: from.id }) if (amount <= 0) { return await message.reply({ diff --git a/legacyCommands/nuts/nutsLeaderboard.js b/legacyCommands/nuts/nutsLeaderboard.js index 2761040..8630f15 100644 --- a/legacyCommands/nuts/nutsLeaderboard.js +++ b/legacyCommands/nuts/nutsLeaderboard.js @@ -27,7 +27,7 @@ module.exports = { .setCustomId('nuts_leaderboard_right') ) const db = mClient.db(process.env.M_DB) - const nutsColl = db.collection('nuts') + const nutsColl = db.collection('items_nuts') let skip = 0 const nutsData = await nutsColl.find({ nuts: { $gt: 0 } }).sort({ nuts: -1 }).skip(skip).limit(5).toArray() let fields diff --git a/legacyCommands/nuts/nutsStats.js b/legacyCommands/nuts/nutsStats.js index 5c67912..9216bbd 100644 --- a/legacyCommands/nuts/nutsStats.js +++ b/legacyCommands/nuts/nutsStats.js @@ -8,7 +8,7 @@ module.exports = { aliases: ['nstat', 'ns'], async execute(message, args) { const db = mClient.db(process.env.M_DB) - const nStatsColl = db.collection('nut-stats') + const nStatsColl = db.collection('stats_nuts') const stats = await nStatsColl.find({}).sort({ amount: 1 }).toArray() let nutMin = { count: 0, diff --git a/selectMenus/honors/honor_menu_mentionable.js b/selectMenus/honors/honor_menu_mentionable.js index ec7b5f3..46bc3ab 100644 --- a/selectMenus/honors/honor_menu_mentionable.js +++ b/selectMenus/honors/honor_menu_mentionable.js @@ -15,7 +15,7 @@ module.exports = { } else { var target = await interaction.guild.members.fetch(interaction.members.keys().next().value) var db = mClient.db(process.env.M_DB) - var honorsColl = db.collection('honors') + var honorsColl = db.collection('items_honors') var theirHonorLevel = await honorsColl.findOne({ userID: target.id }) const member = interaction.message.guild.members.cache.get(target.user.id) diff --git a/selectMenus/quotes/quotes_list_mentionable.js b/selectMenus/quotes/quotes_list_mentionable.js index a70e96e..6becef5 100644 --- a/selectMenus/quotes/quotes_list_mentionable.js +++ b/selectMenus/quotes/quotes_list_mentionable.js @@ -15,7 +15,7 @@ module.exports = { } else { const target = await interaction.guild.members.fetch(interaction.members.keys().next().value) const db = mClient.db(process.env.M_DB) - const quotesColl = db.collection('quotes') + const quotesColl = db.collection('items_quotes') const quotes = await quotesColl.find({ by: target.id }).toArray() const member = interaction.message.guild.members.cache.get(target.user.id) const memberRoles = member.roles.cache