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

[do not merge yet] Move Discord bot to another repo #41

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

Conversation

zzuziak
Copy link

@zzuziak zzuziak commented Oct 27, 2022

Fixes #40

Background
This PR separates Discord bot from the current service.

Changes

  • remove discord client setup and dependencies
  • refactor sendEventToDiscordSubscribers into an API call to the new discord-bot

Related PRs

  • to be merged after the discord-bot has been merged and deployed 👉 PR

Testing
Can be tested once the discord-bot is up an running to make sure everything is set correctly 🙏

To dos

  • clean the ENV in prod (remove DISCORD_CLIENT_ID and DISCORD_TOKEN)
  • set DISCORD_BOT_URL in prod

@ChaituVR @bonustrack it's not final yet but you can already have a look 🧹

@zzuziak zzuziak marked this pull request as ready for review October 27, 2022 18:21
Comment on lines +83 to +100
async function sendEventToDiscordSubscribers(event: string, proposalId: string) {
try {
const url = `${discordBotUrl}/api/event-to-subscribers`;
const params = {
event,
proposalId
};
await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ params })
});

return console.log('[events] Notify Discord subscribers success');
} catch (error) {
console.log("[events] Discord API Failure", error);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I feel like we should include this ${discordBotUrl}/api/event-to-subscribers in our webhooks table. sending events that way will be more secure.

Copy link
Author

Choose a reason for hiding this comment

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

Could you potentially give me a reference link for that? 🙏

I can also implement authorization for the post request on the discord-bot side, then we can store i.e. a bearer token in the env.

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.

Move Discord bot to a separate server
2 participants