diff --git a/src/events/guildMemberAdd.js b/src/events/guildMemberAdd.js index b066932d..12664f3a 100644 --- a/src/events/guildMemberAdd.js +++ b/src/events/guildMemberAdd.js @@ -7,7 +7,7 @@ module.exports = async (client, member) => { const guildDb = await client.database.getGuild(member.guild.id, false); if (guildDb && guildDb?.welcome) { - const channel = await member.guild.channels.fetch(guildguildDb.welcomeChannel).catch(err => { + const channel = await member.guild.channels.fetch(guildDb.welcomeChannel).catch(err => { }); if (!channel?.id) return; @@ -51,17 +51,47 @@ module.exports = async (client, member) => { randomDaily = guildDb.customMessages.filter(c => c.type !== "nsfw")[Math.floor(Math.random() * guildDb.customMessages.filter(c => c.type !== "nsfw").length)].msg; } + if (guildDb.customTypes === "regular") { + let array = []; + array.push(...General, ...WhatYouDo) + randomDaily = array[Math.floor(Math.random() * array.length)] + } else if (guildDb.customTypes === "mixed") { + let array = []; + if (guildDb.customMessages.filter(c => c.type !== "nsfw").length != 0) { + array.push(guildDb.customMessages.filter(c => c.type !== "nsfw")[Math.floor(Math.random() * guildDb.customMessages.filter(c => c.type !== "nsfw").length)].msg); + } else { + randomDaily = [...General, ...WhatYouDo] + } + array.push(...General, ...WhatYouDo) + randomDaily = array[Math.floor(Math.random() * array.length)] + } else if (guildDb.customTypes === "custom") { + if (guildDb.customMessages.filter(c => c.type !== "nsfw").length === 0) { + return this.client.webhookHandler.sendWebhook( + channel, + guildDb.dailyChannel, + { + content: 'There\'s currently no custom Would You messages to be displayed for daily messages! Either make new ones or turn off daily messages.', + }, + guildDb.dailyThread + ).catch(err => { + console.log(err); + }); + } + + randomDaily = guildDb.customMessages.filter(c => c.type !== "nsfw")[Math.floor(Math.random() * guildDb.customMessages.filter(c => c.type !== "nsfw").length)].msg; + } + let mention = null - if (guildDb.welcomePing) {mention = `<@${member.user.id}>`} + if (guildDb.welcomePing) { mention = `<@${member.user.id}>` } let welcomeEmbed = new EmbedBuilder() - .setTitle(`${client.translation.get(guildDb?.language, 'Welcome.embed.title')} ${member.user.username}!`) - .setColor("#0598F6") - .setThumbnail(member.user.avatarURL()) - .setDescription(randomDaily); + .setTitle(`${client.translation.get(guildDb?.language, 'Welcome.embed.title')} ${member.user.username}!`) + .setColor("#0598F6") + .setThumbnail(member.user.avatarURL()) + .setDescription(randomDaily); - return channel.send({content: mention, embeds: [welcomeEmbed]}).catch((err) => { + return channel.send({ content: mention, embeds: [welcomeEmbed] }).catch((err) => { console.log(err) }); } diff --git a/src/events/interactionCreate.js b/src/events/interactionCreate.js index 4fd148cf..d94c90f4 100644 --- a/src/events/interactionCreate.js +++ b/src/events/interactionCreate.js @@ -36,7 +36,7 @@ module.exports = async (client, interaction) => { ephemeral: true, }); } - } else if (interaction.isButton()) { + } else if (interaction.isButton() && !restrict.includes(interaction.customId)) { if (guildDb.replayType === "Guild" && client.used.has(interaction.user.id)) { return interaction.reply({ ephemeral: true, @@ -58,7 +58,7 @@ module.exports = async (client, interaction) => { }).catch(() => { }); try { - if (!restrict.includes(interaction.customId) && !interaction.customId.startsWith("voting_") && !interaction.customId.startsWith("result_")) { + if (!interaction.customId.startsWith("voting_") && !interaction.customId.startsWith("result_")) { if (guildDb.replayType === "Channels" && guildDb.replayChannels.find(x => x.id === interaction.channel.id)) { client.used.set(`${interaction.user.id}-${interaction.channel.id}`, Date.now() + guildDb.replayChannels.find(x => x.id === interaction.channel.id).cooldown) setTimeout(() => client.used.delete(`${interaction.user.id}-${interaction.channel.id}`), guildDb.replayChannels.find(x => x.id === interaction.channel.id).cooldown)