This discord bot syncs a OneDrive folder with a git repository. This is useful for projects with users, which don't have a technical background and have issues with using git. The bot is limited to a one directional sync. This limits the use cases: e.g game dev projects, where each artists works on its own artworks and no sync from git to OneDrive is required.
The commands need to start with !gj. Due to concurrency issues only one command can run at once.
Adds you to the alert notification list. As soon an error is triggered all channels in the list are notified.
Adds the channel to the debug notification list. As soon any debug output (log, warning, error) is triggered all channels in the list are notified.
Uses the microsoft token by fetching the (toplevel) folders and files of the OneDrive folder.
Removes you from the alert notification list. see addAlert
Removes you from the debug notification list. see addDebug
Sets and refreshes the microsoft token with a refresh_token.
Fetches the current stat of the OneDrive folder and pushes new files into the git repository.
The bot is configured via the config and the local .env. You can find here an example of the required names: .env.example.
The discord.js guide contains a very good documentation on how to create a bot and how to add one to a server. It also explains where to get your token and how to handle it properly.
Follow the documentation and create your application. You can create a secret/apptoken in the "Certificates & secrets" tab. You can easily fetch your OneDrive folderId from the url parameters when viewing it in the browser. The driveId is typically the part before the !
or %21
in the folderId. You can check your íds via the graph explorer and the GET request https://graph.microsoft.com/v1.0/drives/<DRIVE_ID>/items/<FOLDER_ID>
.
Please ensure you use ssh on your system. You might need to change some parts in case you want to use http/ OAuth instead.
- discord.js: github.com/discordjs/discord.js
- Simpel Git: github.com/steveukx/git-js
- Simple OAuth2: github.com/lelylan/simple-oauth2
- onedrive-api: github.com/dkatavic/onedrive-api
- express: github.com/expressjs/express
- dotenv: github.com/motdotla/dotenv