Skip to main content

A basic API wrapper for Discords.com

Project description

discords.py

The offical Python API wrapper for Discords.com

Notices

This is the first version with limited coverage of API endpoints, more features, functionality and documentation will be added in the future.

Installation:

pip install discords.py

Features

  • Server count posting
  • Built-in automatic & interval server count posting
  • Built-in voting webhook handler
  • Voting & server posting events

Examples

Automatic server count posting with event

Autoposting posts the servercount whenever a server is joined/removed while abiding with ratelimits

from discord.ext import commands
import discordspy

bot = commands.Bot("!")
discords = discordspy.Client(bot, DISCORDS_TOKEN, post=discordspy.Post.auto())

@bot.event
async def on_discords_server_post(status):
    if status == 200:
        print("Posted the server count:", discords.servers())

bot.run(TOKEN)

Interval server count posting every hour and a half

from discord.ext import commands
import discordspy

bot = commands.Bot("!")
post = discordspy.Post.interval(minutes=30, hours=1)
discords = discordspy.Client(bot, DISCORDS_TOKEN, post=post)

@bot.event
async def on_discords_server_post(status):
    if status == 200:
        print("Posted the server count:", discords.servers())

bot.run(TOKEN)

Webhook voting event

IMPORTANT: Your webhook url must end with /discordswebhook if you wish to use a different path, please specify it using the path argument inside the webhook method path="/customwebhook", by default the port is 8080

from discord.ext import commands
import discordspy

bot = commands.Bot("!")
discords = discordspy.Client(bot, DISCORDS_TOKEN)
discords.webhook(port=2296, auth="password")

@bot.event
async def on_discords_server_post(status):
    if status == 200:
        print("Posted the server count:", discords.servers())

bot.run(TOKEN)

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

discordspy-0.1.1.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distributions

discordspy-0.1.1-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

discordspy-0.1.1-py2.py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 2 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