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. diff --git a/src/buttons/higher.js b/src/buttons/higher.js index 62a41ba0..bb403765 100644 --- a/src/buttons/higher.js +++ b/src/buttons/higher.js @@ -87,8 +87,10 @@ 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..b1cb6188 100644 --- a/src/buttons/lower.js +++ b/src/buttons/lower.js @@ -87,8 +87,10 @@ 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/welcomeTest.js b/src/buttons/welcomeTest.js index e9c6a0df..cc9cd166 100644 --- a/src/buttons/welcomeTest.js +++ b/src/buttons/welcomeTest.js @@ -1,88 +1,17 @@ -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/commands/higherlower.js b/src/commands/higherlower.js index c11f71ac..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, - 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", }, )}`, ) diff --git a/src/events/guildMemberAdd.js b/src/events/guildMemberAdd.js index 33bae8bd..1b8bc8a4 100644 --- a/src/events/guildMemberAdd.js +++ b/src/events/guildMemberAdd.js @@ -27,18 +27,18 @@ module.exports = async (client, member) => { ) return; const { General } = await require( - `../../data/rather-${guildDb.language}.json`, + `../data/rather-${guildDb.language}.json`, ); const { WhatYouDo } = await require( - `../../data/wwyd-${guildDb.language}.json`, + `../data/wwyd-${guildDb.language}.json`, ); - let randomDaily = []; - if (guildDb.customTypes === "regular") { + let randomMessage = []; + if (guildDb.welcomeType === "regular") { let array = []; array.push(...General, ...WhatYouDo); - randomDaily = array[Math.floor(Math.random() * array.length)]; - } else if (guildDb.customTypes === "mixed") { + 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( @@ -50,30 +50,17 @@ module.exports = async (client, member) => { ].msg, ); } else { - randomDaily = [...General, ...WhatYouDo]; + randomMessage = [...General, ...WhatYouDo]; } array.push(...General, ...WhatYouDo); - randomDaily = array[Math.floor(Math.random() * array.length)]; - } else if (guildDb.customTypes === "custom") { + randomMessage = array[Math.floor(Math.random() * array.length)]; + } else if (guildDb.welcomeType === "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")[ + randomMessage = guildDb.customMessages.filter((c) => c.type !== "nsfw")[ Math.floor( Math.random() * guildDb.customMessages.filter((c) => c.type !== "nsfw").length, @@ -81,70 +68,17 @@ module.exports = async (client, member) => { ].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); - }); - } - - 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); });