Skip to main content

A framework that makes discord bot programming easy

Reason this release was yanked:

This version is less verbose

Project description

██████╗ ██╗  ██╗ ██████╗ ███╗   ██╗██╗  ██╗██████╗     ██████╗  ██████╗ ████████╗
██╔══██╗██║  ██║██╔═══██╗████╗  ██║██║ ██╔╝██╔══██╗    ██╔══██╗██╔═══██╗╚══██╔══╝
██████╔╝███████║██║   ██║██╔██╗ ██║█████╔╝ ██║  ██║    ██████╔╝██║   ██║   ██║   
██╔═══╝ ██╔══██║██║   ██║██║╚██╗██║██╔═██╗ ██║  ██║    ██╔══██╗██║   ██║   ██║   
██║     ██║  ██║╚██████╔╝██║ ╚████║██║  ██╗██████╔╝    ██████╔╝╚██████╔╝   ██║   
╚═╝     ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═══╝╚═╝  ╚═╝╚═════╝     ╚═════╝  ╚═════╝    ╚═╝   
---------------------------------------------------------------
A framework that makes discord bot programming easy

License: MIT

Installation and setup

Run this command in your terminal, it will download the framework along with the discord and asyncio libraries.

pip3 install phonkd_bot

Create a file named config.json in the same directory as your script. Copy and paste your bot token (from discord.com/developers) into the file. The prefix field is optional.

{
    "prefix": "/",
    "token": "YOUR BOT TOKEN HERE"
}

Creating a Discord Bot

  1. Go to discord.com/developers/applications
  2. Click New Application
  3. Give the bot a name, agree to the terms, then click Create
  4. (optional) give the bot a profile picture, tags, and or a description, then click Save Changes
  5. Go to the Bot page on the side panel
  6. (optional) give the bot a username
  7. Click Reset Token, Yes, do it! and Copy, save the token somewhere safe
  8. Allow Presence Intent, Server Members Intent, and Message Content Intent
  9. Click Save Changes
  10. Expand OAuth2 on the side panel and go to URL Generator
  11. Check bot, this will reveal Bot Permissions, you will need to check Administrator in this new section
  12. Scroll down, and open the generated url in another tab
  13. Select the server to add the bot to and click Continue
  14. Make sure Administrator is checked and click Authorize
  15. Do the captcha (if one appears) and close the window once you see "Success!" on your screen

Usage Example

Importing the bot

import phonkd_bot

Creating a bot instance

bot = phonkd_bot.DiscordBot()

Responding to messages

  • Adding the phonkd_bot.message type hint to the message parameter allows your code editor to autocomplete attributes of the discord Message object, see their documentation for more information.
  • The function passed into call_on_message will be called when a the bot receives a message. The return value is what the bot will respond with.
  • The framework will pass a discord.Message object as a paramater to the function provided to call_on_message.
def on_message(message: phonkd_bot.message):
    return "Hello!"

bot.call_on_message(on_message)

Activating the bot

bot.start()

Logging Information

The DiscordBot class has a sub class called logger. The logger class has multiple methods that will help you debug or catch errors in your script. These methods are:

  • logger.info
  • logger.warning
  • logger.error
  • logger.critical

Here is an example script.

import phonkd_bot

bot = DiscordBot()

bot.logger.info("info message")
bot.logger.warning("warning message")
bot.logger.error("error message")
bot.logger.critical("critical error message")

This is the result.

image of terminal containing logged information

Example Discord Bot Script

import phonkd_bot

bot = phonkd_bot.DiscordBot()

def on_message(message: phonkd_bot.message):
    return "Hello!"

bot.call_on_message(on_message)
bot.start()

This is the result.

image of discord bot saying hello

Meta

Gmail - phonkibusiness@gmail.com

Github - https://github.com/RealPhonki

Find me on the Python Discord Server - https://discord.com/invite/python

Discord Tags - Phonki#0090, slamsandwich19

Code distributed under the MIT license. See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phonkd_bot-1.0.0.tar.gz (11.0 kB view hashes)

Uploaded Source

Built Distribution

phonkd_bot-1.0.0-py3-none-any.whl (10.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page