Skip to content

H0rn0chse/OneDriveGitBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OneDriveGitBot

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.

Commands

The commands need to start with !gj. Due to concurrency issues only one command can run at once.

addAlert (DM only)

Adds you to the alert notification list. As soon an error is triggered all channels in the list are notified.

addDebug (channel only)

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.

checkToken (DM only)

Uses the microsoft token by fetching the (toplevel) folders and files of the OneDrive folder.

removeAlert (DM only)

Removes you from the alert notification list. see addAlert

removeDebug (channel only)

Removes you from the debug notification list. see addDebug

setToken <refresh_token> (DM only)

Sets and refreshes the microsoft token with a refresh_token.

sync (channel only)

Fetches the current stat of the OneDrive folder and pushes new files into the git repository.

Bot Setup

The bot is configured via the config and the local .env. You can find here an example of the required names: .env.example.

Discord

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.

Microsoft

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>.

Git

Please ensure you use ssh on your system. You might need to change some parts in case you want to use http/ OAuth instead.

Libraries