A simple, fully asynchronous wrapper for the Discord Labs API.
Project description
dlabs.py
A fully asynchronous wrapper for the Discord Labs API.
Installation
Installing dlabs.py
is easy, just run pip install dlabs.py
!
Usage
Currently, as of Nov 10th 2020 the API provides 2 routes - this package makes use of them, and as soon as new ones are added, the wrapper will be updated simultaneously.
Below are some simple example cogs using the API wrapper to automatically post stats to Discord Labs posting manually, and fetching bots! (note that bot
is expected to be your instance of discord.py's commands.Bot
or commands.AutoShardedBot
)
import dlabs
from discord.ext import commands
class DiscordLabs(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.discord_labs = dlabs.Client(bot, token="YOUR DISCORD LABS TOKEN", autopost=True)
def setup(bot):
bot.add_cog(DiscordLabs(bot))
And that's it! It's that easy to automatically post stats with dlabs.py
. However, if you don't want to autopost the statistics and call the function manually, there's a way too, here's an example -
import dlabs
from discord.ext import commands
class DiscordLabs(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.discord_labs = dlabs.Client(bot, token="YOUR DISCORD LABS TOKEN")
@commands.command()
async def post_dlabs_stats(self, ctx):
await self.discord_labs.post_stats()
await ctx.send("Posted the stats to Discord Labs!")
def setup(bot):
bot.add_cog(DiscordLabs(bot))
Now, there's one more thing you can do, and that is fetching Bot information straight from Discord Labs. Here's an example on how you could do that:
import dlabs
from discord.ext import commands
from discord import Embed
class DiscordLabs(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.discord_labs = dlabs.Client() # Doesn't require authorization!
@commands.command()
async def coolbot(self, ctx, id):
cool_bot = await self.discord_labs.get_bot(id)
embed = Embed(
color=0xefefef,
title=f"{cool_bot.name} is a cool bot!",
description=f"It's got {cool_bot.uptime} uptime!"
)
embed.set_thumbnail(url=cool_bot.avatar_url)
await ctx.send(embed=embed)
def setup(bot):
bot.add_cog(DiscordLabs(bot))
Contributing
This package is opensource so anyone with adequate python experience can contribute to this project!
Report Issues
If you find any error/bug/mistake with the package or in the code feel free to create an issue and report it here.
Fix/Edit Content
If you want to contribute to this package, fork the repository, make your changes and then simply create a Pull Request!
Contact
If you want to contact me -
Mail - wulf.developer@gmail.com
Discord - wulf#9716
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
File details
Details for the file dlabs.py-0.0.1.tar.gz
.
File metadata
- Download URL: dlabs.py-0.0.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87d3593da15b69c3faf88b48e22718b8b0231fcfda16327eb25c0e3375a6cf4a |
|
MD5 | a52a6d125d95e87518cd61420bb93593 |
|
BLAKE2b-256 | 959d57107cdd7131b2c9e29ab6bfdaef94b20deaa5a7943be4c21342c9bdce41 |
File details
Details for the file dlabs.py-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: dlabs.py-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d7cca116d41eb5a23ea9715d1cc08d0158bbc45907a0e160bdf20c11d6748e6 |
|
MD5 | 50540ca68b669bd5a93672d79f38f87d |
|
BLAKE2b-256 | 8a9acc64dccc541bd7191a8fd5491d51f32514ba6821a34fd86b337de9260a1f |