Discord Bot generates embeds for Google Drive links, including private files.
-
Generate embeds with links, filenames, and last edited time in Discord for Google Drive links.
-
Support private (access restricted) files and folders.
-
Support multiple Google Drive links in a single message.
-
Support editing and deleting messages. The embeds will be updated accordingly.
-
Clone this repository and make sure you installed the prerequisite.
-
Run the following commands:
bun i
cp .env.example .env
-
Create a Google Cloud project
-
Go to Google Cloud Console and create a new project. (Click
Select a project
in the top left corner and clickNew Project
.) -
Go to the Google Drive API in API library and enable it.
-
Move to the Service Accounts and create a new service account. You may skip all optional steps.
-
Move to the Keys tab and create a new key. (Click
Add Key
and selectCreate new key
.) Select JSON as the key type and download the key file. -
Copy the
client_email
in the key file and paste it to.env
asGOOGLE_SERVICE_ACCOUNT_EMAIL
. -
Copy the
private_key
in the key file and paste it to.env
asGOOGLE_SERVICE_ACCOUNT_KEY
. Leave the\n
as it is, including the key's last\n
.
-
-
Share Google Drive folders/files to the service account
-
Go to the Google Drive folder/file you want to share.
-
Click the
Share
button in the context menu or the top right corner. -
Paste the
GOOGLE_SERVICE_ACCOUNT_EMAIL
in theAdd people and groups
field and clickDone
. -
Repeat the above steps for all folders/files you want to share. For convenience, I recommend sharing entire folders instead of individual files.
-
-
Create a Discord bot
-
Go to Discord Developer Portal and create a new application.
-
Move to the Bot tab and reset the token.
Copy and paste it to
.env
asDISCORD_BOT_TOKEN
.-
Enable
Message Content Intent
in the Bot tab. -
Disable the
Public Bot
option to prevent your bot from being added to other servers.
-
-
Invite the bot to your server
-
Open Discord and enable Developer Mode in
User Settings > App Settings > Advanced
. -
Go to the server you want to add the bot to.
-
Right-click the server icon and
Copy Server ID
. Paste it to.env
asDISCORD_GUILD_ID
. -
Run the following command to generate an invite link for the bot. It exits with an error, but it's okay.
bun start
- Follow the link and add the bot to the server.
-
Important
Do not include the "
at the beginning and the end of the values in .env
.
bun start
If you want to run it persistently, use the following command instead.
It requires screen to be installed. (Which is usually installed by default.)
*Make sure to detach (Ctrl+A, D) before closing the terminal, or it will be terminated.
bun start:screen
MIT