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

feat: Post Discord channel message on points earned #83

Merged
merged 5 commits into from
May 17, 2024

Conversation

raysubham
Copy link
Contributor

What does this PR do?

  1. Posts discord channel message whenever someone earns new points

Fixes #75

Screen.Recording.2024-05-05.at.6.42.02.AM.mov

How should this be tested?

  • Create a discord bot and install it in the server.
  • Get the bot token and channel ID and add the env variables
  • Award points and the discord message should be posted

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at oss.gg
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Copy link

vercel bot commented May 5, 2024

@raysubham is attempting to deploy a commit to the formbricks Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

github-actions bot commented May 5, 2024

Thank you for following the naming conventions for pull request titles! 🙏

@jobenjada
Copy link
Member

Hey!

So i've created and installed the Discord bot. However, when I run this branch, the normal GitHub comment on point award does not work anymore and I get this error:

AggregateError: 
    Error: SyntaxError: Unexpected token < in JSON at position 0
        at eval (webpack-internal:///(api)/./lib/github/hooks/issue.ts:342:19)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async Promise.all (index 2)
        at async middleware (/Users/johannes/Developer/ossgg/oss.gg/node_modules/.pnpm/@[email protected]/node_modules/@octokit/webhooks/dist-node/index.js:613:5)
    at /Users/johannes/Developer/ossgg/oss.gg/node_modules/.pnpm/@[email protected]/node_modules/@octokit/webhooks/dist-node/index.js:422:19
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async middleware (/Users/johannes/Developer/ossgg/oss.gg/node_modules/.pnpm/@[email protected]/node_modules/@octokit/webhooks/dist-node/index.js:613:5) {
  event: {
    id: 'c53f5740-0d42-11ef-9469-f7b2f6403416',
    name: 'issue_comment',
    payload: {
      action: 'created',
      issue: [Object],
      comment: [Object],
      repository: [Object],
      sender: [Object],
      installation: [Object]
    }
  },
  errors: [
    Error: SyntaxError: Unexpected token < in JSON at position 0
        at eval (webpack-internal:///(api)/./lib/github/hooks/issue.ts:342:19)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async Promise.all (index 2)
        at async middleware (/Users/johannes/Developer/ossgg/oss.gg/node_modules/.pnpm/@[email protected]/node_modules/@octokit/webhooks/dist-node/index.js:613:5) {
      event: [Object]
    }
  ]
}

I'm not very familiar with Trigger but see that you made some changes in the PR which likely cause this (since it doesnt happen on main).

Can you walk me through how I have to set it up correctly? 🤓

Thanks! :)

@raysubham
Copy link
Contributor Author

Hey!

So i've created and installed the Discord bot. However, when I run this branch, the normal GitHub comment on point award does not work anymore and I get this error:

AggregateError: 
    Error: SyntaxError: Unexpected token < in JSON at position 0
        at eval (webpack-internal:///(api)/./lib/github/hooks/issue.ts:342:19)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async Promise.all (index 2)
        at async middleware (/Users/johannes/Developer/ossgg/oss.gg/node_modules/.pnpm/@[email protected]/node_modules/@octokit/webhooks/dist-node/index.js:613:5)
    at /Users/johannes/Developer/ossgg/oss.gg/node_modules/.pnpm/@[email protected]/node_modules/@octokit/webhooks/dist-node/index.js:422:19
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async middleware (/Users/johannes/Developer/ossgg/oss.gg/node_modules/.pnpm/@[email protected]/node_modules/@octokit/webhooks/dist-node/index.js:613:5) {
  event: {
    id: 'c53f5740-0d42-11ef-9469-f7b2f6403416',
    name: 'issue_comment',
    payload: {
      action: 'created',
      issue: [Object],
      comment: [Object],
      repository: [Object],
      sender: [Object],
      installation: [Object]
    }
  },
  errors: [
    Error: SyntaxError: Unexpected token < in JSON at position 0
        at eval (webpack-internal:///(api)/./lib/github/hooks/issue.ts:342:19)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async Promise.all (index 2)
        at async middleware (/Users/johannes/Developer/ossgg/oss.gg/node_modules/.pnpm/@[email protected]/node_modules/@octokit/webhooks/dist-node/index.js:613:5) {
      event: [Object]
    }
  ]
}

I'm not very familiar with Trigger but see that you made some changes in the PR which likely cause this (since it doesnt happen on main).

Can you walk me through how I have to set it up correctly? 🤓

Thanks! :)

Let me check the console error and get back to you.

@raysubham
Copy link
Contributor Author

raysubham commented May 9, 2024

@jobenjada I checked on my local. Discord messages works perfectly. There are no errors for me. Here are the steps that you need to follow:

  1. Install the discord bot on the server & add the bot token in the env variables.
  2. Go to settings -> advanced and toggle on developer mode in discord. Now you can right click on any channel & copy the channel id. Add this id in the env variable.
  3. To setup trigger.dev locally, you can follow this guide: https://trigger.dev/docs/documentation/quickstarts/nextjs This has all the steps mentioned. Trigger.dev cli will add a id in package.json "endpointId": "some-value" Please add this id in the id field of trigger.ts file.
  4. Add this env variable too: TRIGGER_API_URL=https://api.trigger.dev

Note: trigger.dev cli adds a lot of values and boilerplate files on initial installation. We should discard them and not commit them to git.

Let me know if you still face issues while installing.

@jobenjada jobenjada added this pull request to the merge queue May 17, 2024
Merged via the queue into formbricks:main with commit ba50d99 May 17, 2024
2 of 3 checks passed
@jobenjada
Copy link
Member

/award 150

Copy link

oss-gg bot commented May 17, 2024

Awarding raysubham: 150 points!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Discord Notification on Points Awarded
2 participants