Skip to main content

A wrapper for the Discord API that doesn't require you to use asyncio

Project description

Discordbot

This package provides an interface to the RESTful and websocket Discord API so users don't have to worry about rate limits, asyncio, or error handling.

It's as simple as:

import discordbot as discord

bot = discord.Bot("my_api_token")

def on_message(raw_event, message):
	print(message.author, "sent a message in", message.channel, "which said", message.content)
	
	if message.content == "!ping":
		bot.send_message(message.channel, "Pong!")
bot.on_event(discord.event.guild_message_sent, on_message)

bot.run()

discordbot also provides a simple way to add commands to your bot

import discordbot as discord

bot = discord.Bot("my_api_token")

role_moderator = '00000000000000' # the id of the role which is required to use the kick command

def cmd_kick(message, member, reason):
    bot.kick(message.guild, member, reason)
    bot.send_message(message.channel, "Member %s kicked. They are allowed to re-join. Ban them if you do not want this behavior." % member, reply_to = message, reply_ping = False)
bot.register_command("kick", "Temporarily remove someone from the server", cmd_kick, required_role = role_moderator, args = [
    {
        "name": "member",
        "description": "The member to kick",
        "type": "user"
    },
    {
        "name": "reason",
        "description": "Reason for kick",
        "type": "string",
        "default": None
    }
])

bot.command_prefix = "!"

bot.register_default_commands() # (optional) adds !cmds and !ping

bot.run()

for more examples, please see this project on github

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-sync-1.0.8.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

discordbot_sync-1.0.8-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file discordbot-sync-1.0.8.tar.gz.

File metadata

  • Download URL: discordbot-sync-1.0.8.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for discordbot-sync-1.0.8.tar.gz
Algorithm Hash digest
SHA256 9a4f0be7362428afca18d94ff665e4aa8ba94779fa29ba659ce0a821ef41937d
MD5 477a78137dda59b0cbd62aee56bdfb7f
BLAKE2b-256 9ad9c02384e3aabcea94aa3fcdc0a0010adbe33cb5f7a8ac491ba4de28ce1ddc

See more details on using hashes here.

File details

Details for the file discordbot_sync-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: discordbot_sync-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for discordbot_sync-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 075262cb5bf8615db1e3032a8430a6baf00bcf2e232cc8f20b7ce8c68acfdd0d
MD5 c9fd763dfcbb269a5c3036d66a3c5a06
BLAKE2b-256 dcb83e8b9dd31dcd48c8394445bdc6fdf129ddde71e2b1fbb0ff5a2d4541b033

See more details on using hashes here.

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