- 😀 Chat using texts
- 👋🏼 Chat with context
- 🥷🏼 Clear context with
/clearcommand - 🚀 Streaming output
- Multimodal support (partial)
- Image input supported
- Get Discord API Key and Client ID via : https://discord.com/developers/applications
- If you do not have a bot, just create one.
- After create, click
Botin the nav. - In
Privileged Gateway Intents, enable following permissions:Presence IntentServer Members IntentMessage Content Intent
- Get Gemini API Key via: https://aistudio.google.com/app/apikey
- Open https://discord.com/developers/applications and select the bot you just created.
- Click
OAuth2in the nav. - In
OAuth2 URL Generator, check the following options:botapplications.commands
- In
Bot Permissions, check the following options:Send MessagesCreate Public ThreadsManage MessagesEmbed LinksAttach FilesRead Message HistoryMention EveryoneUse Slash CommandsView Channels
Integration TypechooseGuild Install- Copy the
Generated URLand open it in your browser, now you can add it into your discord server.
This project is written in TypeScript, before deploy, ensure you have NodeJS (>= v20 is recommended) installed. If you don't have NodeJS, fnm is the NodeJS installer recommended.
git clone https://github.com/delbertbeta/discord-gemini-bot.git
cd discord-gemini-bot
npm iThen replace your key into .env file, reminder to keep these keys safely and DO NOT upload this file to public place.
cp .env.example .envYou can change the language used by the bot user interface by setting the environment variable LANG. This variable has probably already been set by your operating system, but you can give a custom value in the .env file to serve users with different language preferences. Note that the value must begin with one of the filenames of the JSON files under src/i18n.
Although localized prompt is given to the AI model initially, this setting does not guarantee that it will respond with the same language, you can still get responses in any language if you ask the model to do so.
npm run devYou will see this output if everthing is working fine: Bot is ready!.
The Bot only works if your process is running which means if you stop the process then the bot won't give you response.
You can choose one of the methods to deploy the bot.
- Follow the way in Get the code, REMIND to place your
.envfile correctly. - Instead of launching the development server, run following command to build a production ready artifact.
npm run build
- run
npm run startto run your server - To make the bot server as a background service, use
systemd,tmux,screenand etc.- Repo has provided a example
systemdservice filediscord-gemini-bot.service. - Copy the sample
discord-gemini-bot.serviceto/etc/systemd/system/discord-gemini-bot.service. - Modify the parameters in the service file.
- run
sudo systemctl enable discord-gemini-bot --nowto enable and start the service. - use
sudo systemctl status discord-gemini-botto check the health status of the service.
- Repo has provided a example
- Initially create and start container
docker pull delbertbeta/discord-gemini-bot:main
docker run \
-d \
--restart=always \
--name=discord-gemini-bot \
--env=DISCORD_API_KEY=$DISCORD_API_KEY \
--env=DISCORD_CLIENT_ID=$DISCORD_CLIENT_ID \
--env=GEMINI_API_KEY=$GEMINI_API_KEY \
delbertbeta/discord-gemini-bot:main
REPLACE the $DISCORD_API_KEY, $DISCORD_CLIENT_ID, $GEMINI_API_KEY in the command or create these env variables
- Use
docker psanddocker logs discord-gemini-botto check the health status of the service. - Upgrade
docker pull delbertbeta/discord-gemini-bot:main
docker stop discord-gemini-bot
docker rm discord-gemini-bot
docker run \
-d \
--restart=always \
--name=discord-gemini-bot \
--env=DISCORD_API_KEY=$DISCORD_API_KEY \
--env=DISCORD_CLIENT_ID=$DISCORD_CLIENT_ID \
--env=GEMINI_API_KEY=$GEMINI_API_KEY \
delbertbeta/discord-gemini-bot:main
Congrats on making your own Gemini Bot.

