A Discord bot that responds to the /gameapi
slash command by retrieving a random link from a local websiteapi.txt
file. This is perfect for game servers or any Discord server where you'd like to deliver random content or pages to users.
- Random Link Selection: Fetches a random URL from a text file and sends it in Discord chat.
- Customizable Links: Easily update the
websiteapi.txt
file to include your own list of URLs. - Slash Commands: Utilizes Discord's modern slash commands for clean and easy interaction.
Follow these steps to set up the bot on your machine:
Go to https://github.com/TheUselessCreator/DiscordGamesAPI and fork it.
Make sure you have Python installed (version 3.8 or higher). Then, install the necessary Python packages:
pip install -r requirements.txt
The required packages include:
discord.py
python-dotenv
In the root directory, create a .env
file to store your Discord bot token:
DISCORD_TOKEN=your-discord-bot-token
Replace your-discord-bot-token
with the token for your Discord bot. You can get this token from the Discord Developer Portal.
In the assets/
folder, create or update the websiteapi.txt
file. Add each URL you want to include on a new line. For example:
https://example.com/page1
https://example.com/page2
https://example.com/page3
Once everything is set up, you can run the bot with:
python main.py
If successful, you should see a message in the terminal that the bot is logged in and ready to respond.
To use the bot in your Discord server:
- Invite the bot to your server using the bot invite link from the Discord Developer Portal.
- In any channel, type
/gameapi
. The bot will respond with a random link from thewebsiteapi.txt
file.
discord-bot/
│
├── assets/
│ └── websiteapi.txt # The file containing the list of URLs (one per line)
├── commands/
│ └── gameapi.py # Cog that defines the /gameapi command
├── .env # Stores your Discord bot token
├── main.py # The entry point of the bot
├── requirements.txt # List of dependencies for the project
└── README.md # Project documentation
https://example1.com
https://example2.com
https://example3.com
Contributions are welcome! If you'd like to add features or fix bugs, feel free to fork the repository and submit a pull request.
- Fork the project
- Create a new branch (
git checkout -b feature-branch
) - Make your changes
- Commit the changes (
git commit -m 'Add new feature'
) - Push the branch (
git push origin feature-branch
) - Open a pull request