Skip to main content

A simple API wrapper for discordbots.org written in Python

Project description

View on PyPi v0.1.6 Documentation Status

A simple API wrapper for discordbots.org written in Python

Installation

Install via pip (recommended)

pip install dblpy

Install from source

pip install git+https://github.com/DiscordBotList/DBL-Python-Library

Documentation

Documentation can be found here

Working

  • POST server count
  • GET bot info, server count, upvote count, upvote info
  • GET all bots
  • GET user info
  • GET widgets (large and small) including custom ones. See discordbots.org/api/docs for more info.

Not Working / Implemented

  • Searching for bots via the api

Example

import dbl
import discord
from discord.ext import commands

import aiohttp
import asyncio
import logging


class DiscordBotsOrgAPI:
    """Handles interactions with the discordbots.org API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token'  #  set this to your DBL token
        self.dblpy = dbl.Client(self.bot, self.token, loop=bot.loop)
        self.updating = bot.loop.create_task(self.update_stats())

    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
       await self.bot.is_ready()
        while not bot.is_closed:
            logger.info('Attempting to post server count')
            try:
                await self.dblpy.post_server_count()
                logger.info('Posted server count ({})'.format(len(self.bot.guilds)))
            except Exception as e:
                logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)

def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(DiscordBotsOrgAPI(bot))

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
dblpy-0.1.6.tar.gz (10.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page