boticordpy/docs/quickstart.rst

85 lines
1.6 KiB
ReStructuredText
Raw Normal View History

2021-08-24 21:20:10 +03:00
.. currentmodule:: boticordpy
.. quickstart:
Quickstart
==========
Installation
------------
Enter one of these commands to install the library:
::
pip install boticordpy
::
python3 -m pip install boticordpy
Or just clone the repo: https://github.com/grey-cat-1908/boticordpy
2021-09-11 16:10:17 +03:00
Examples
2021-08-24 21:20:10 +03:00
-------------------------
2021-09-11 16:10:17 +03:00
**Without Using Cogs System**
Post bot stats when bot is ready.
2021-08-24 21:20:10 +03:00
::
from discord.ext import commands
from boticordpy import BoticordClient
bot = commands.Bot(command_prefix="!")
boticord = BoticordClient(bot, "your-boticord-token")
@bot.event
2021-09-09 17:40:35 +03:00
async def on_ready():
2021-08-24 21:20:10 +03:00
stats = {"servers": len(bot.guilds), "shards": bot.shard_count, "users": len(bot.users)}
await boticord.Bots.postStats(stats)
bot.run("your-bot-token")
2021-09-11 16:10:17 +03:00
..
**Using Cogs System**
Cog with automatically stats post (every 15 minutes) + bot's owner command that can be used to post stats.
::
from discord.ext import commands
from boticordpy import BoticordClient
class BoticordCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.boticord = BoticordClient(self.bot, "your-boticord-token")
self.boticord.start_loop()
@commands.command(name="boticord-update")
@commands.is_owner()
async def boticord_update(self, ctx):
"""
This commands can be used by owner to post stats to boticord
"""
stats = {"servers": len(self.bot.guilds), "shards": 0, "users": len(self.bot.users)}
await self.boticord.Bots.postStats(stats)
def setup(bot):
bot.add_cog(BoticordCog(bot))
..