Skip to content

Discord Bot to add and retrieve events from Google Calendar

License

Notifications You must be signed in to change notification settings

DavDeDev/DisCal

Repository files navigation

Contributors Forks Stargazers Issues MIT License


Logo

DisCal

Manage your shared event calendar from Discord
Explore the docs »

View Codeseen · Report Bug · Request Feature

Table of Contents
  1. Project Status
  2. About The Project
  3. Getting Started
  4. Usage
  5. Roadmap
  6. Contributing
  7. License
  8. Contact

Project Status

Currently, the project development has slowed down a bit due to my external commitments. I have been juggling multiple responsibilities, which has limited the amount of time I can dedicate to this project. However, I am still actively working on it and making progress whenever I have the opportunity.

If you have any questions or concerns regarding the project or its progress, please feel free to reach out to me. Thank you for your support and understanding.

About The Project

Idea

Typical situation in our #events channel on Discord:

sequenceDiagram
    participant E as #35;events
    actor A as Albi
    actor J as Jack
    actor U as Umbi
    actor D as David
    
    Note over D: David is Offline

    loop Every minute
        U->>+E: Sends event A
        J->>+E: Sends event B
        A->>+E: Sends event C
        J->>+E: Sends event A (again)
    end
    Note over E,U: 50+ messages
    Note over D: David is Online
    D-->>E: TL#59;DR

    Note over E,D: After a while...
loop Every time before an event which requires registration
    A->>+D: "Are you coming tomorrow to the event?"
    D->>+A: "Oh, I didnt know about it"
    A->>+D: "WHAAAT? Umbi sent it in #35;Events"
    D-->>D: "I should've checked the channel"
    D->>+A: "You send too many messages :/"
    A->>+D: "Too bad, next time..."
%Note right of D: I still try<br>without registration%
    
end
Loading

But what if...

sequenceDiagram
    participant C as Shared<br>Calendar
    participant E as #35;Events
    participant B as DisCal
    actor P as People
    actor D as David
    
    Note over D: Offline

    loop Every minute
        P->>+B: Input event's details
        B->>+C: Event already in the calendar?
        alt event already exists in the calendar
            C->>+B: Sends event
            B->>+P: Display event's details
        else event not yet in the calendar
        par 
            B->>+E: Create clear embeds with all details
        and
            B->>+C: Adds event to Calendar
        end
        
        end
    end
    Note over E,D: 20+ messages (less duplicate events)
    D->>C: Checks events directly from the phone

loop Before events
    Note over P,D: Notification on smartphone
end
Loading

(back to top)

Built With

Node.js Badge TypeScript Badge Discord Badge Google Cloud Badge Google Calendar Badge

(back to top)

Getting Started

This instruction page assumes you already have Node.js, NPM installed

Prerequisites

Obtaining credentials.json from GCP:

  1. Create a new project in GCP: Go to the Google Cloud Console, create a new project, and provide a suitable name.
  2. Enable Google Calendar API: In the GCP Console, navigate to the API Library by selecting Library from the sidebar menu. Search for "Google Calendar API" and click on it. Then, click the Enable button to activate the API for your project.
  3. Create a service account: In the GCP Console, navigate to IAM & Admin > Service Accounts. Click on the Create Service Account button. Provide a name and description for the service account, and click Create. Make sure to grant the service account the necessary permissions to manage calendars by assigning the Calendar role.
  4. Generate and download the credentials: After creating the service account, click on the service account's name to view its details. Navigate to the Keys tab, and click on Add Key > Create new key. Select JSON as the key type and click Create. This will download a JSON file containing the service account's credentials. Rename the downloaded file to credentials.json.
  5. Add the service account to the calendar: Share the calendar you want to manage with the service account. In the calendar's settings, go to the Share with specific people section and enter the email address associated with the service account (found in the credentials.json file) to grant it access to the calendar.

You will place credentials.json in the .env file

For additional clarification or assistance, you can refer to this comment or feel free to contact me.

Setup Discord Bot from Discord Developer Platform:

  1. Create a new application: Go to the Discord Developer Portal and log in to your Discord account. Click on the New Application button and provide a name for your bot.
  2. Create a bot user: After creating the application, navigate to the Bot tab in the left sidebar and click on Add Bot. Confirm the prompt by clicking on "Yes, do it!" This will create a bot user for your application.
  3. Obtain the bot token: Under the bot's settings, you will find the Token section. Click on the "Copy" button to copy the bot token. This token will be added to DISCORD_TOKEN environmental variable in the .env file.
  4. Invite the bot to your server: Scroll up to the top of the bot's settings page and locate the OAuth2 tab in the left sidebar. In the Scopes section, select the bot checkbox. This will generate a URL below. Copy the URL and open it in a new browser tab. From there, you can select a server to invite your bot to. Make sure to have the necessary permissions to add the bot to the selected server.

For additional clarification or assistance, you can refer to this comment or feel free to contact me.

Installation

  1. Clone the repo
    git clone https://github.com/DavDeDev/DisCal.git
  2. Install NPM packages
    npm install
  3. Follow the instruction in the .env.example file
  4. Deploy your Bot commands to a server:
    npm run deploy-commands
  5. Run your bot:
    npm run start:dev

(back to top)

Usage

After you run npm run start:dev, the bot will work as a common Discord Bot, so you can start typing / in the server specified in the .env file and commands will pop-up in the Discord UI.

(back to top)

Roadmap

  • Releasing a first stable version

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

LinkedIn Badge Gmail Badge GitHub Badge

(back to top)