Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analytics command #95

Closed
8 tasks
Marchand-Nicolas opened this issue Feb 13, 2025 · 11 comments · Fixed by #106
Closed
8 tasks

analytics command #95

Marchand-Nicolas opened this issue Feb 13, 2025 · 11 comments · Fixed by #106
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers OD Boost Issue reserved for the OD Boost open for contribution An issue that is available for an Only Dust contribution

Comments

@Marchand-Nicolas
Copy link
Collaborator

Description 📹

Reuse discord/interactions/helpCommand.ts to create an /analytics command. This command should generate a unique token, store it in the database, and provide the user with a link to process.env.BASE_URL/analytics/<GuildID>/<Token>. The token ensures authorization before accessing analytics.

Proposed Actions 🛠️

Here’s a checklist of actions to follow for resolving this issue:

  1. Fork and Create Branch:
    Fork the repository and create a new branch using the issue number:

    git checkout -b fix-[issue-number]
  2. Implement Changes:

    • Create a new command handleAnalyticsCommand.ts in discord/interactions/.
    • Import necessary dependencies (REST, ChatInputCommandInteraction, Client).
    • Extract guildId and userId from interaction.
    • Generate a secure token (e.g., UUID or crypto-generated).
    • Store the token in the database, associated with the guildId and userId.
    • Construct the URL:
      const analyticsUrl = `${process.env.BASE_URL}/analytics/${guildId}/${token}`;
    • Reply to the user with the URL in an ephemeral message.
    • Handle errors gracefully.

    Example Code:

    import { REST } from "@discordjs/rest";
    import { ChatInputCommandInteraction, Client } from "discord.js";
    import { v4 as uuidv4 } from "uuid"; // For token generation
    import { saveTokenToDatabase } from "../../utils/database"; // Assume DB handling function
    
    export const handleAnalyticsCommand = async (
      interaction: ChatInputCommandInteraction,
      client: Client,
      restClient: REST
    ) => {
      try {
        const userId = interaction.member?.user?.id;
        const guildId = interaction.guildId;
        if (!userId || !guildId) return;
    
        const token = uuidv4();
        await saveTokenToDatabase(guildId, userId, token); 
    
        const analyticsUrl = `${process.env.BASE_URL}/analytics/${guildId}/${token}`;
    
        await interaction.reply({
          content: `View analytics here: [Click Here](${analyticsUrl})`,
          ephemeral: true,
        });
      } catch (error) {
        console.error("Error handling /analytics command:", error);
      }
    };
  3. Run Tests and Commit Changes:
    Make sure your changes don't break existing functionality and commit with a clear message:

    git commit -m "Fix: Implement analytics command with token authentication"

Required 📋

To keep our workflow smooth, please make sure you follow these guidelines:

  • Assignment: Don't create a pull request if you weren’t assigned to this issue.
  • Timeframe: Complete the task within 3 business days.
  • Closing the Issue: In your PR description, close the issue by writing Close #[issue_id].
  • Review Process:
    • Once you've submitted your PR, change the label to "ready for review".
    • If changes are requested, address them and then update the label back to "ready for review" once done.
  • Testing: Test your PR locally before pushing, and verify that tests and build are working after pushing.

Thank you for your contribution 🙏

⚠️ WARNING: Failure to follow the requirements above may result in being added to the OnlyDust blacklist, affecting your ability to receive future rewards.

@Marchand-Nicolas Marchand-Nicolas added enhancement New feature or request good first issue Good for newcomers OD Boost Issue reserved for the OD Boost open for contribution An issue that is available for an Only Dust contribution labels Feb 13, 2025
@emarc99
Copy link
Contributor

emarc99 commented Feb 13, 2025

Could I be assigned to this?

@Verifieddanny
Copy link
Contributor

Can I contribute to this one?

@chiscookeke11
Copy link
Contributor

May I take this issue on?

@No-bodyq
Copy link

Would love to tackle this!

@Elite-tch
Copy link
Contributor

Could I grab this task?

@Nikhil-550
Copy link

I'd like to take this issue. I am new to open source and want to contribute for this issue.If i will be assigned i will do my best work and i have experience with this kind of stuffs.As i worked on it in my own development projects.

@thetribalgod
Copy link

May I take care of this?

@jaiminRaiyani
Copy link

Can I work on this, please?

@Ugo-X
Copy link
Contributor

Ugo-X commented Feb 15, 2025

Please, I would love to work on this!

@SudiptaPaul-31
Copy link
Contributor

Can I be assigned to this issue

@Elite-tch
Copy link
Contributor

@Marchand-Nicolas Thanks for assigning me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers OD Boost Issue reserved for the OD Boost open for contribution An issue that is available for an Only Dust contribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.