Skip to content

Commit

Permalink
added ToS
Browse files Browse the repository at this point in the history
  • Loading branch information
mattythedev01 committed Oct 15, 2024
1 parent 94182a8 commit 070026c
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/commands/community/add-quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = {
DmAuthorized: null,
Authorized: true,
Badges: ["None"],
TosAgreement: false,
});
} else {
user.numberOfQuotes += 1;
Expand Down
112 changes: 112 additions & 0 deletions src/events/ready/tos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const {
EmbedBuilder,
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
} = require("discord.js");
const userSchema = require("../../schemas/userSchema");

module.exports = async (client) => {
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return;

const user = await userSchema.findOne({ userID: interaction.user.id });

if (!user || !user.TosAgreement) {
const tosEmbed = new EmbedBuilder()
.setColor("#0099ff")
.setTitle("SimplyQuotes Terms of Service")
.setDescription(
"Please read and accept our Terms of Service before using SimplyQuotes."
)
.addFields(
{
name: "1. Quote Submission",
value:
"By submitting quotes, you confirm that you have the right to share them and grant SimplyQuotes permission to use and display them.",
},
{
name: "2. Content Guidelines",
value:
"Quotes must not contain explicit, offensive, or copyrighted material. SimplyQuotes reserves the right to remove any quote that violates these guidelines.",
},
{
name: "3. User Responsibility",
value:
"Users are responsible for the content they submit. SimplyQuotes is not liable for any submitted content.",
},
{
name: "4. Moderation",
value:
"SimplyQuotes may moderate, edit, or remove quotes at its discretion to maintain quality and appropriateness.",
},
{
name: "5. Privacy",
value:
"We respect your privacy. Please refer to our Privacy Policy for details on how we handle user data.",
},
{
name: "6. Changes to ToS",
value:
"SimplyQuotes may update these terms. Users will be notified of any significant changes.",
}
)
.setFooter({
text: "By clicking 'I accept', you agree to abide by these terms.",
});

const acceptButton = new ButtonBuilder()
.setCustomId("accept_tos")
.setLabel("I accept")
.setStyle(ButtonStyle.Primary);

const row = new ActionRowBuilder().addComponents(acceptButton);

await interaction.reply({
embeds: [tosEmbed],
components: [row],
ephemeral: true,
});

const filter = (i) =>
i.customId === "accept_tos" && i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({
filter,
time: 60000,
});

collector.on("collect", async (i) => {
if (i.customId === "accept_tos") {
await userSchema.findOneAndUpdate(
{ userID: interaction.user.id },
{ $set: { TosAgreement: true } },
{ upsert: true, new: true }
);

await i.update({
content:
"You have accepted the Terms of Service. You can now use SimplyQuotes commands.",
embeds: [],
components: [],
ephemeral: true,
});
}
});

return;
}

// If TosAgreement is true, allow the command to proceed
try {
const command = client.commands.get(interaction.commandName);
if (!command) return;
await command.run(client, interaction);
} catch (error) {
console.error(error);
await interaction.reply({
content: "There was an error while executing this command!",
ephemeral: true,
});
}
});
};
1 change: 1 addition & 0 deletions src/schemas/userSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const userSchema = new Schema({
min: 0,
max: 100,
},
TosAgreement: Boolean,
});

module.exports = model("User", userSchema);

0 comments on commit 070026c

Please sign in to comment.