Skip to main content

A wrapper for discord.py with advanced functionality

Project description

This is an extention of Rapptz’ discord.py to help make it even easier to make new bots, and simpler to make complex ones.

Current version of the code should be stable, but use at your own risk.

The documentation will be built up over time hopefully.

Examples

Simple Example

To create a bot that will greet new members when they join and greet anyone that types !greet you can do the following:

import discordbot
import asyncio

bot = discordbot.DiscordBot()

@bot.event
async def on_member_join(member):
    await bot.send_message(member.server, "Welcome {0.mention}, would you like to introduce yourself?".format(member))

@bot.command(pass_context=True)
async def greet(ctx):
    """Greets the user.

    This is additional help text that will only show up if
    help is called on the command itself as opposed to the
    normal short help which shows up in the main help.
    """
    await bot.responses.say("Hi there, {0.mention}, how are you?".format(ctx.message.author))

bot.run()

This should be accompanied by a settings.json file like this:

{
  "meta": {
    "owner": "YOUR_ID",
    "prefix": "!",
    "description": "Optional description of the bot."
  },
  "credentials": {
    "token": "YOUR_TOKEN_HERE",
    "client_id": "YOUR_CLIENT_ID"
  }
}

Features

Built-in Cogs

Administrative and Meta cogs are built-in.

Commands Extension

This bakes the commands extension directly in by default.

Flexible Settings

The bot can be fully set up through python with no JSON or vice versa.

Through JSON

Your bot.py could be as minimal as this:

import asyncio
import discordbot

bot = discordbot.DiscordBot()

if __name__ == '__main__':
    bot.load_cogs()
    bot.run()

As long as you have a JSON file like this:

{
  "meta": {
    "owner": "YOUR_ID",
    "prefix": "ANY_PREFIX",
    "description": "Optional description of the bot."
  },
  "credentials": {
    "token": "YOUR_TOKEN_HERE",
    "client_id": "YOUR_CLIENT_ID"
  },
  "cogs": ["cog_folder.cog_name", "cog_folder.another_cog"]
}

Through Python

This is very similar to how it is done for discord.py

New Help

Embed Formatter

The new help formatter is prettier and done using embeds.

Smarter Searching

The searching and matching has been adjusted to better match what the user is looking for including being case insensitive.

Helper Classes

Embeds

This includes a simpler and easy to follow embed builder.

Colors

This allows a preset of colors for things like success, failure, or the Discord blurple. Also has utility functions for generating Color objects from RGB values.

Messages

This allows responses and other messages to be sent using automatically built embeds to make the messages look nicer. This also some utility functions like a toggle which uses the success and failure colors.

Utilities

The utilities include setting constants, asynchronous web requests, string similarity ratios, word counts, and markdown escaping—this is especially useful for those funky usernames.

Logs

In a separate folder the bot will generate 3 logs, one for errors (hopefully empty), one for stats which gives more specifics and can help track down pesky bugs and the last one which rounds out additional info like where your bot is being added and kicked from. This can be overridden of course.

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

discordbot.py-0.2.3a2.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

discordbot.py-0.2.3a2-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file discordbot.py-0.2.3a2.tar.gz.

File metadata

File hashes

Hashes for discordbot.py-0.2.3a2.tar.gz
Algorithm Hash digest
SHA256 9137b6dac398eb51a107a6c6665474d04cfb90d11d20de4d13575631ac9781bf
MD5 1d65edd1594ed9f7ccb7167f5365cd6d
BLAKE2b-256 d8430c3e0d254ab892126f544c13905244bb09e54ff86ae897bbf1ce5350a45d

See more details on using hashes here.

Provenance

File details

Details for the file discordbot.py-0.2.3a2-py3-none-any.whl.

File metadata

File hashes

Hashes for discordbot.py-0.2.3a2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a836fc30264d9c45bcc6f568c08c039a62f51e44ad1560b6f0b16086966b508
MD5 ec30347edb2ed5968c3f4ecb35495537
BLAKE2b-256 c1954b883d36830043d37173777f9e64ae18b6a26facabaffdd585cca82a6104

See more details on using hashes here.

Provenance

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