Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Serverless Discord Bot built using GEMISIS/discord-bot-cdk-construct to retrieve stores cart cookies from MediaMarkt and Saturn

License

Notifications You must be signed in to change notification settings

timbru31/mms-discord-cookie-bot

Repository files navigation

Cookie Monster

This serverless Discord Bot built using GEMISIS/discord-bot-cdk-construct serves you stored basket cookies for MediaMarkt and Saturn from a DynamoDB.

Supported stores

  • MediaMarkt Austria
  • MediaMarkt Germany
  • MediaMarkt Spain
  • Saturn

Installation/Deployment

Clone repository, setup the AWS CDK.
You can restrict access to specific user roles, by setting the USER_ROLES environment variable. Configure the DynamoDB ARN by setting it as an environment variable COOKIE_ARN, for example:

export COOKIE_ARN="arn:aws:dynamodb:eu-central-1:9999999:table/my-cookie-jar"
export USER_ROLES="12345678"

If you omit the ARN then the construct will create a new DynamoDB table for you.

You need to create a new Discord bot and register the Slash command (make sure to use the Bot token not the OAuth 2 token!). Ensure to configure two options: store and productId - or alter the code. 😉

To deploy the application, run cdk deploy (see below for more commands).

In the AWS Secrets Manager, modify the created secret (paste it as plain text JSON object):

{
  appId: "XXXXX",
  publicKey: "XXXXX",
  clientId: "XXXXX", // OAuth 2 - can be the same as appId
  authToken: "XXXXX", // OAuth 2
}

Enter the CDK construct Lambda URL with the suffix /event as your interaction URL.
Finally, configure the OAuth 2 scope (bot and applications.commands) and use the URL to add the bot to your server.

You can configure a comma separated list of user roles that should be allowed to access the slash command (variable USER_ROLES). Violations are logged.

Useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

Built by (c) Tim Brust and contributors. Released under the GPL v3 license.