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
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
- Go to discord.com/developers/applications
- Click
New Application
- Give the bot a name, agree to the terms, then click
Create
- (optional) give the bot a profile picture, tags, and or a description, then click
Save Changes
- Go to the
Bot
page on the side panel - (optional) give the bot a username
- Click
Reset Token
,Yes, do it!
andCopy
, save the token somewhere safe - Allow
Presence Intent
,Server Members Intent
, andMessage Content Intent
- Click
Save Changes
- Expand
OAuth2
on the side panel and go toURL Generator
- Check
bot
, this will revealBot Permissions
, you will need to checkAdministrator
in this new section - Scroll down, and open the generated url in another tab
- Select the server to add the bot to and click
Continue
- Make sure
Administrator
is checked and clickAuthorize
- 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 themessage
parameter allows your code editor to autocomplete attributes of the discordMessage
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.
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for phonkd_bot-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ae2313685ace45f10216e419e3f0e90471d5c15e729d1caba6adab35bd16b13 |
|
MD5 | 426335b89530361ff37c2188ac65018e |
|
BLAKE2b-256 | ae9f58b2a84626ad249b36736e32e08960b8f0ea95d3fa99d839f5cf41b819f0 |