Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

109 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 中文

Free_Game_DiscordBot

Before Start

git clone https://github.com/KelenHappy/Free_Game_DiscordBot.git
cd Free_Game_DiscordBot
go mod tidy

Run

go run .

Routine

go build -o dcbot .
sudo micro /etc/systemd/system/dcbot.service
[Unit]
Description=Discord Bot Job

[Service]
Type=oneshot
WorkingDirectory=/path/to/your/Free_Game_DiscordBot
ExecStart=/path/to/your/Free_Game_DiscordBot/dcbot

Replace /path/to/your/Free_Game_DiscordBot with your actual project path. WorkingDirectory lets the program find .env, and ExecStart points to the built binary.

sudo micro /etc/systemd/system/dcbot.timer
[Unit]
Description=Run dcbot every hour

[Timer]
OnCalendar=hourly
Persistent=true

[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable --now dcbot.timer

Check status and logs:

systemctl status dcbot.timer
systemctl list-timers dcbot.timer
journalctl -u dcbot.service

Modification

  1. Copy .env.example to .env and fill in your BOT_TOKEN, CHANNEL_ID, FIREBASE_DB_URL.
  2. Go to Firebase Project Settings -> Service Accounts -> Go -> Generate New Private Key.
  3. Rename the JSON file to serviceAccountKey.json.

These instructions guide you through the process of setting up a Discord bot locally, including steps for Discord and Firebase setup, as well as the installation of necessary Go packages. The final section provides commands to start the bot with the specified token.


Discord免費遊戲機器人

開始之前

安裝(本地部署)

git clone https://github.com/KelenHappy/Free_Game_DiscordBot.git
cd Free_Game_DiscordBot
go mod tidy

Run

go run .

Routine

go build -o dcbot .
sudo micro /etc/systemd/system/dcbot.service
[Unit]
Description=Discord Bot Job

[Service]
Type=oneshot
WorkingDirectory=/path/to/your/Free_Game_DiscordBot
ExecStart=/path/to/your/Free_Game_DiscordBot/dcbot

/path/to/your/Free_Game_DiscordBot 替換成你實際的專案路徑。WorkingDirectory 讓程式找得到 .envExecStart 是執行檔的位置。

sudo micro /etc/systemd/system/dcbot.timer
[Unit]
Description=Run dcbot every hour

[Timer]
OnCalendar=hourly
Persistent=true

[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable --now dcbot.timer

確認狀態與執行紀錄:

systemctl status dcbot.timer
systemctl list-timers dcbot.timer
journalctl -u dcbot.service

修改

  1. 複製 .env.example.env,填入你的 BOT_TOKENCHANNEL_IDFIREBASE_DB_URL
  2. Firebase 專案設定 -> 服務帳戶 -> Go -> 產生新的密鑰。
  3. 重新命名 JSON 檔案,改成 serviceAccountKey.json

這些說明將引導您完成本地設置 Discord 機器人的過程,包括 Discord 和 Firebase 的設置步驟,以及在虛擬環境中安裝所需的 Go 套件。最後一節提供了用指定令牌啟動機器人的命令。

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages