(Japanese version is available here)
This project is a Node.js application that logs into GeoGuessr, creates a daily challenge, and posts the challenge details to a specified Discord channel. The project uses TypeScript for development and discord.js
for interacting with the Discord API.
- Node.js
- npm
- A Discord bot token and a Discord channel ID
- A GeoGuessr account
-
Clone the repository:
git clone https://github.com/sh-mug/daily-geoguessr-bot.git cd daily-geoguessr-bot
-
Install the dependencies:
npm install
-
Please copy
.env.example
to the root directory of the project to create a.env
file and set the following environment variables.:[email protected] GEOGUESSR_PASSWORD=your-geoguessr-password DISCORD_TOKEN=your-discord-bot-token DISCORD_CHANNEL_ID=your-discord-channel-id
-
Compile the TypeScript code:
npx tsc
In standalone mode, scheduled tasks are automatically executed without any settings. To run in standalone mode, execute the following:
npm run standalone
In this mode, the following schedules are used:
challenge
runs every day at midnight (00:00) and creates a new GeoGuessr challenge.highscores
runs every day at 11 PM (23:00) and posts the highscores of the previous day's challenge to Discord.
In server mode, you can access the endpoints exposed by the Express server to manually execute tasks. To run in server mode, execute the following:
npm start
In this mode, the following endpoints are available:
GET /challenge
- Triggerschallenge
.GET /highscores
- Triggershighscores
.
If you prefer to use crontab
to schedule tasks instead of running the application in standalone mode, you can set up crontab
entries as follows:
-
Open the crontab editor:
crontab -e
-
Add the following entries to schedule
challenge
andhighscores
:0 0 * * * curl http://localhost:25000/challenge 0 23 * * * curl http://localhost:25000/highscores
The challenge settings randomly select maps from config.json
. By default, the maps are:
The game mode changes based on the day of the week:
- Monday, Wednesday, Friday: The game mode is set to
Move
. - Tuesday, Thursday, Saturday: The game mode is set to
NM
(No Moving). - Sunday: The game mode is set to
NMPZ
(No Moving, Panning, or Zooming).
This functionality is implemented to provide varied gameplay experiences depending on the day.
src/
geoguessr-api/
login.ts
- Handles logging into GeoGuessr and managing cookies.challenge.ts
- Handles creating a new GeoGuessr challenge.highscores.ts
- Handles fetching the highscores of a GeoGuessr challenge.
discord/
discordPoster.ts
- Handles posting messages to Discord.
server.ts
- The entry point of the application.
GEOGUESSR_EMAIL
: Your GeoGuessr account email.GEOGUESSR_PASSWORD
: Your GeoGuessr account password.DISCORD_TOKEN
: Your Discord bot token.DISCORD_CHANNEL_ID
: The ID of the Discord channel where the message will be posted.
- Ensure that your bot has the necessary permissions to post messages in the specified Discord channel.
- Be cautious with your credentials and avoid committing the
.env
file to version control. - Save the GeoGuessr cookie to
cookie.txt
during the initial login. The cookie is valid for one year. When it expires, manually deletecookie.txt
. - If the challenge is not played when the results are retrieved, it will be automatically played. This is based on the GeoGuessr API specifications.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
For any questions or support, please open an issue in the GitHub repository.