From 434ddea5697fed74c564688a9526ea3b47421ef1 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 5 Oct 2023 16:53:58 +0200 Subject: [PATCH 1/4] feat(higherlower): fix src --- src/buttons/higher.js | 4 ++-- src/buttons/lower.js | 4 ++-- src/commands/higherlower.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/buttons/higher.js b/src/buttons/higher.js index 62a41ba0..1c693dd9 100644 --- a/src/buttons/higher.js +++ b/src/buttons/higher.js @@ -87,8 +87,8 @@ module.exports = { client.translation.get(guildDb?.language, "HigherLower.description", { keyword: game.items.current.keyword, history: game.items.history[game.items.history.length - 1].keyword, - source: game.items.current.link, - source2: game.items.history[game.items.history.length - 1].link, + source: game.items.current.link || "https://wouldyoubot.gg/nolink", + source2: game.items.history[game.items.history.length - 1].link || "https://wouldyoubot.gg/nolink", }), ) .setColor("Green") diff --git a/src/buttons/lower.js b/src/buttons/lower.js index 124fae7c..81174f44 100644 --- a/src/buttons/lower.js +++ b/src/buttons/lower.js @@ -87,8 +87,8 @@ module.exports = { client.translation.get(guildDb?.language, "HigherLower.description", { keyword: game.items.current.keyword, history: game.items.history[game.items.history.length - 1].keyword, - source: game.items.current.link, - source2: game.items.history[game.items.history.length - 1].link, + source: game.items.current.link || "https://wouldyoubot.gg/nolink", + source2: game.items.history[game.items.history.length - 1].link || "https://wouldyoubot.gg/nolink", }), ) .setColor("Green") diff --git a/src/commands/higherlower.js b/src/commands/higherlower.js index c11f71ac..45ae1166 100644 --- a/src/commands/higherlower.js +++ b/src/commands/higherlower.js @@ -96,8 +96,8 @@ module.exports = { keyword: game.items.current.keyword, history: game.items.history[game.items.history.length - 1].keyword, - source: game.items.current.link, - source2: game.items.history[game.items.history.length - 1].link, + source: game.items.current.link || "https://wouldyoubot.gg/nolink", + source2: game.items.history[game.items.history.length - 1].link || "https://wouldyoubot.gg/nolink", }, )}`, ) From c0a44a870d0a927d2593c41f057e247710e674ab Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 5 Oct 2023 17:40:50 +0200 Subject: [PATCH 2/4] revamp test + welcome functions --- src/buttons/welcomeTest.js | 81 +------------------- src/events/guildMemberAdd.js | 141 ++++++++--------------------------- 2 files changed, 33 insertions(+), 189 deletions(-) diff --git a/src/buttons/welcomeTest.js b/src/buttons/welcomeTest.js index e9c6a0df..5698126f 100644 --- a/src/buttons/welcomeTest.js +++ b/src/buttons/welcomeTest.js @@ -1,88 +1,13 @@ -const { EmbedBuilder } = require("discord.js"); const Sentry = require("@sentry/node"); + module.exports = { data: { name: "welcomeTest", description: "Welcome Test", }, async execute(interaction, client, guildDb) { - const { General } = await require( - `../data/rather-${guildDb.language}.json`, - ); - const { WhatYouDo } = await require( - `../data/wwyd-${guildDb.language}.json`, - ); - - let randomDaily = []; - 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) => { - Sentry.captureException(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 = `<@${interaction.member.user.id}>`; - } - - let welcomeEmbed = new EmbedBuilder() - .setTitle( - `${client.translation.get(guildDb?.language, "Welcome.embed.title")} ${ - interaction.member.user.username - }!`, - ) - .setColor("#0598F6") - .setThumbnail(interaction.member.user.avatarURL()) - .setDescription(randomDaily); + client.emit("guildMemberAdd", interaction); - return interaction.reply({ - content: `${client.translation.get( - guildDb.language, - "Settings.welcomeTestSuccess", - )}\n\n ${mention ? mention : ""}`, - embeds: [welcomeEmbed], - ephemeral: true, - }); + interaction.reply({content: "Welcome test has been sent!", ephemeral: true }).catch((err) => { Sentry.captureException(err) }); }, }; diff --git a/src/events/guildMemberAdd.js b/src/events/guildMemberAdd.js index 33bae8bd..ebb16f31 100644 --- a/src/events/guildMemberAdd.js +++ b/src/events/guildMemberAdd.js @@ -26,125 +26,44 @@ module.exports = async (client, member) => { ]) ) return; - const { General } = await require( - `../../data/rather-${guildDb.language}.json`, - ); - const { WhatYouDo } = await require( - `../../data/wwyd-${guildDb.language}.json`, - ); + const { General } = await require(`../data/rather-${guildDb.language}.json`); + const { WhatYouDo } = await require(`../data/wwyd-${guildDb.language}.json`); - let randomDaily = []; - 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() * + let randomMessage = []; + if (guildDb.welcomeType === "regular") { + let array = []; + array.push(...General, ...WhatYouDo); + randomMessage = array[Math.floor(Math.random() * array.length)]; + } else if (guildDb.welcomeType === "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) => { - Sentry.captureException(err); - }); - } + ) + ].msg, + ); + } else { + randomMessage = [...General, ...WhatYouDo]; + } + array.push(...General, ...WhatYouDo); + randomMessage = array[Math.floor(Math.random() * array.length)]; + } else if (guildDb.welcomeType === "custom") { + if (guildDb.customMessages.filter((c) => c.type !== "nsfw").length === 0) { + } - randomDaily = guildDb.customMessages.filter((c) => c.type !== "nsfw")[ - Math.floor( - Math.random() * + randomMessage = 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) => { - Sentry.captureException(err); - }); + ].msg; } - 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}>`; - } - - let welcomeEmbed = new EmbedBuilder() - .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] }) + .send({ content: `${client.translation.get(guildDb?.language, "Welcome.embed.title")} ${guildDb.welcomePing ? `<@${member.user.id}>` : `${member.user.username}`}! ${randomMessage}` }) .catch((err) => { Sentry.captureException(err); }); From 346b0868a201f773e095cb6b65cd7ce27e700c10 Mon Sep 17 00:00:00 2001 From: mezotv Date: Fri, 6 Oct 2023 01:27:46 +0000 Subject: [PATCH 3/4] chore(style): format files --- src/buttons/higher.js | 4 +- src/buttons/lower.js | 4 +- src/buttons/welcomeTest.js | 8 +++- src/commands/higherlower.js | 7 +++- src/events/guildMemberAdd.js | 79 +++++++++++++++++++++--------------- 5 files changed, 64 insertions(+), 38 deletions(-) diff --git a/src/buttons/higher.js b/src/buttons/higher.js index 1c693dd9..bb403765 100644 --- a/src/buttons/higher.js +++ b/src/buttons/higher.js @@ -88,7 +88,9 @@ module.exports = { keyword: game.items.current.keyword, history: game.items.history[game.items.history.length - 1].keyword, source: game.items.current.link || "https://wouldyoubot.gg/nolink", - source2: game.items.history[game.items.history.length - 1].link || "https://wouldyoubot.gg/nolink", + source2: + game.items.history[game.items.history.length - 1].link || + "https://wouldyoubot.gg/nolink", }), ) .setColor("Green") diff --git a/src/buttons/lower.js b/src/buttons/lower.js index 81174f44..b1cb6188 100644 --- a/src/buttons/lower.js +++ b/src/buttons/lower.js @@ -88,7 +88,9 @@ module.exports = { keyword: game.items.current.keyword, history: game.items.history[game.items.history.length - 1].keyword, source: game.items.current.link || "https://wouldyoubot.gg/nolink", - source2: game.items.history[game.items.history.length - 1].link || "https://wouldyoubot.gg/nolink", + source2: + game.items.history[game.items.history.length - 1].link || + "https://wouldyoubot.gg/nolink", }), ) .setColor("Green") diff --git a/src/buttons/welcomeTest.js b/src/buttons/welcomeTest.js index 5698126f..cc9cd166 100644 --- a/src/buttons/welcomeTest.js +++ b/src/buttons/welcomeTest.js @@ -6,8 +6,12 @@ module.exports = { description: "Welcome Test", }, async execute(interaction, client, guildDb) { - client.emit("guildMemberAdd", interaction); + client.emit("guildMemberAdd", interaction); - interaction.reply({content: "Welcome test has been sent!", ephemeral: true }).catch((err) => { Sentry.captureException(err) }); + interaction + .reply({ content: "Welcome test has been sent!", ephemeral: true }) + .catch((err) => { + Sentry.captureException(err); + }); }, }; diff --git a/src/commands/higherlower.js b/src/commands/higherlower.js index 45ae1166..91d617d6 100644 --- a/src/commands/higherlower.js +++ b/src/commands/higherlower.js @@ -96,8 +96,11 @@ module.exports = { keyword: game.items.current.keyword, history: game.items.history[game.items.history.length - 1].keyword, - source: game.items.current.link || "https://wouldyoubot.gg/nolink", - source2: game.items.history[game.items.history.length - 1].link || "https://wouldyoubot.gg/nolink", + source: + game.items.current.link || "https://wouldyoubot.gg/nolink", + source2: + game.items.history[game.items.history.length - 1].link || + "https://wouldyoubot.gg/nolink", }, )}`, ) diff --git a/src/events/guildMemberAdd.js b/src/events/guildMemberAdd.js index ebb16f31..1b8bc8a4 100644 --- a/src/events/guildMemberAdd.js +++ b/src/events/guildMemberAdd.js @@ -26,44 +26,59 @@ module.exports = async (client, member) => { ]) ) return; - const { General } = await require(`../data/rather-${guildDb.language}.json`); - const { WhatYouDo } = await require(`../data/wwyd-${guildDb.language}.json`); + const { General } = await require( + `../data/rather-${guildDb.language}.json`, + ); + const { WhatYouDo } = await require( + `../data/wwyd-${guildDb.language}.json`, + ); - let randomMessage = []; - if (guildDb.welcomeType === "regular") { - let array = []; - array.push(...General, ...WhatYouDo); - randomMessage = array[Math.floor(Math.random() * array.length)]; - } else if (guildDb.welcomeType === "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() * + let randomMessage = []; + if (guildDb.welcomeType === "regular") { + let array = []; + array.push(...General, ...WhatYouDo); + randomMessage = array[Math.floor(Math.random() * array.length)]; + } else if (guildDb.welcomeType === "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 { - randomMessage = [...General, ...WhatYouDo]; - } - array.push(...General, ...WhatYouDo); - randomMessage = array[Math.floor(Math.random() * array.length)]; - } else if (guildDb.welcomeType === "custom") { - if (guildDb.customMessages.filter((c) => c.type !== "nsfw").length === 0) { - } + ) + ].msg, + ); + } else { + randomMessage = [...General, ...WhatYouDo]; + } + array.push(...General, ...WhatYouDo); + randomMessage = array[Math.floor(Math.random() * array.length)]; + } else if (guildDb.welcomeType === "custom") { + if ( + guildDb.customMessages.filter((c) => c.type !== "nsfw").length === 0 + ) { + } - randomMessage = guildDb.customMessages.filter((c) => c.type !== "nsfw")[ - Math.floor( - Math.random() * + randomMessage = guildDb.customMessages.filter((c) => c.type !== "nsfw")[ + Math.floor( + Math.random() * guildDb.customMessages.filter((c) => c.type !== "nsfw").length, - ) - ].msg; - } + ) + ].msg; + } return channel - .send({ content: `${client.translation.get(guildDb?.language, "Welcome.embed.title")} ${guildDb.welcomePing ? `<@${member.user.id}>` : `${member.user.username}`}! ${randomMessage}` }) + .send({ + content: `${client.translation.get( + guildDb?.language, + "Welcome.embed.title", + )} ${ + guildDb.welcomePing + ? `<@${member.user.id}>` + : `${member.user.username}` + }! ${randomMessage}`, + }) .catch((err) => { Sentry.captureException(err); }); From f96c3a069e645110e06087e65eda8da0d4d82d61 Mon Sep 17 00:00:00 2001 From: Shikhar02347893 <120932504+Shikhar02347893@users.noreply.github.com> Date: Sat, 7 Oct 2023 00:16:20 +0530 Subject: [PATCH 4/4] Pull request template and Issue template added. (#174) * Pull request template and Issue template added. * Issue template and pull request modified. * Issue template modified. --- ISSUE_TEMPLATE.md | 50 ++++++++++++++++++++++++++++++++++++++++ PULL_REQUEST_TEMPLATE.md | 24 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 ISSUE_TEMPLATE.md create mode 100644 PULL_REQUEST_TEMPLATE.md diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..94ee0fac --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,50 @@ +### Issue Description + +## Bug Report: + +# Description: +Report a problem or error in the software. +# Expected Behavior: +Describe what should happen. +# Actual Behavior: +Explain what is happening instead. +# Steps to Reproduce: +Provide steps to reproduce the issue. +# Screenshots: +Attach screenshots if applicable. +# Related Issues/PRs: +List any related issues or pull requests. + +## Feature Request: + +# Description: +Propose a new feature or enhancement to the software. +# Expected Behavior: +Describe how the new feature should work. +# Rationale: +Explain why this feature would be beneficial. +# Related Issues/PRs: +Link to related issues or pull requests. + +## Documentation Issue: + +# Description: +Report an issue with the documentation. +# Type: +Specify if it's a documentation error, missing documentation, or unclear documentation. +# Page/Section: +Mention the affected documentation page or section. +# Suggested Improvement: +Provide suggestions for improvement. + +## Question / Support Request: + +# Description: +Ask a question or request help with using the software. +# Context: +Provide context or details about the problem you're facing. +# Expected Answer: +Describe what you're expecting in response. +# Additional Information: +Include any relevant information. + diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..6f04188d --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ + +## Description + +**Link to the issue (if applicable)**: +Provide a link to the related issue (e.g., #[issue_number]). + +**Description**: +Explain the purpose and context of this PR. + +## Changes Made + +List the changes you made in this PR. + +## Testing + +Describe the testing process you followed to ensure that the changes in this PR are effective and do not introduce new issues. Include information about the test cases you ran or any manual testing steps. + +## Screenshots (if applicable) + +Add screenshots or GIFs to showcase the changes visually. + +## Additional Notes + +Include any additional information or context that reviewers should be aware of.