This is a Python script for a basic Discord bot that responds to specific commands or messages. The bot will respond to messages with certain keywords or commands, such as "hello" or "!roll". It also includes PyJokes package to add some humor to its responses.
- Clone this repository to your local machine Open your terminal or command prompt and run the following command:
git clone https://github.com/kmgrime/pybot_discord.git
- Install the necessary Python packages Navigate to the project directory and run:
pip install -r requirements.txt
- Create a New Discord Bot and Obtain its Token Follow the steps here to create a bot and obtain its token.
- Replace the TOKEN Variable
Open bot.py in a text editor, find the
TOKEN
variable, and replace it with your bot's token.
- Starting the Bot Run the following command in your terminal or command prompt: The bot will now be online and actively listening for messages in the Discord server to which it has been added.
python bot.py
- Available Commands
!roll
: Generates a random number between 1 and 100.!help
: Displays the available commands.!joke
: Returns a random joke using the PyJokes package.hello
: Responds with "Hello there!".
- Message Logging The bot logs messages it receives, displaying the author's username, message content, and the channel it was sent in.
Docker Building and Running the Image
- Build the image:
docker build -t discordpybot:0.0.1 .
- List the images to fetch image ID
docker image list
- Build and run the image in a container
docker run 'imageID'
- Verify if the container is up and running
docker ps
If you have any suggestions for improvements or new features, feel free to open an issue or submit a pull request.
This bot uses the following Python packages:
discord.py
: For creating the bot and interacting with the Discord API.pyjokes
: For generating random jokes to include in the bot's responses.
This project is licensed under the MIT License.