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

WIP: Setup discord bot #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

WIP: Setup discord bot #1

wants to merge 2 commits into from

Conversation

zzuziak
Copy link

@zzuziak zzuziak commented Oct 27, 2022

Fixes partially snapshot-webhook/40

Background

This PR sets up the Discord Bot as a separate repo from snapshot-webhook

PR details
The logic is moved from snapshot-webhook to this repo in the following way:

  • sets up the Discord client and connects to the existing Snapshot bot
  • exposes an API endpoint for notifying subscribers about the proposals which is to be called from snapshot-webhook
  • uses the same DB as snapshot-webhook

Current implementation (there is an error with Missing access, haven't sorted it out yet but it must be my settings on Discord for the app):

discordBot1

Related PRs

  • will have to be merged before a change in snapshot-webhook, PR to come

To Dos

  • would be great to refactor the client into separate files (easier to manage if there are new features in the future) -> might be done in separate PR
  • set up ENV variables in prod required to initiate the client and db

@bonustrack @ChaituVR any comments welcome 🙏

@zzuziak
Copy link
Author

zzuziak commented Jan 30, 2023

Hey @ChaituVR could you have a look at this PR? Refactoring of the client can be done in a separate PR 🙏

Comment on lines +14 to +24
router.post('/event-to-subscribers', async (req, res) => {
const event: string = req.body.event || '';
const proposalId: string = req.body.proposalId || '';

try {
await sendEventToDiscordSubscribers(event, proposalId);
return res.json({ success: true });
} catch (e) {
return res.json({ error: e });
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zzuziak

  • We should make sure this route is used only by us.
  • snapshot-webhook sends a secret in the authentication header, Example:
  • Untitled 2
  • We can add a variable in .env and check if the header is equal or not (for development env can be empty)
  • For
const proposalId: string = req.body.proposalId || '';

In the event payload proposal id is proposal.id

@@ -0,0 +1,39 @@
<div align="center">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is weird here https://github.com/snapshot-labs/discord-bot/tree/setup-discord-bot
I see plain html 🙈 not sure why
Untitled 3

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

Successfully merging this pull request may close these issues.

2 participants