mirror of
https://github.com/boticord/boticordpy.git
synced 2024-11-11 19:07:29 +03:00
67 lines
1.8 KiB
Markdown
67 lines
1.8 KiB
Markdown
<h1 align="center">Boticordpy</h1>
|
||
|
||
<p align="center">Модуль для работы с <a href="https://boticord.top/">Boticord</a> API</p>
|
||
|
||
<p align="center">
|
||
|
||
<img src="https://img.shields.io/pypi/dm/boticordpy" alt="">
|
||
</p>
|
||
|
||
---
|
||
* [Документация](https://boticordpy.readthedocs.io/)
|
||
* [Исходный код](https://github.com/grey-cat-1908/boticordpy)
|
||
---
|
||
|
||
### Примеры
|
||
|
||
#### Без Когов
|
||
Публикуем статистику при запуске бота.
|
||
|
||
```Python
|
||
from discord.ext import commands
|
||
|
||
from boticordpy import BoticordClient
|
||
|
||
bot = commands.Bot(command_prefix="!")
|
||
boticord = BoticordClient(bot, "your-boticord-token")
|
||
|
||
|
||
@bot.event
|
||
async def on_ready():
|
||
stats = {"servers": len(bot.guilds), "shards": bot.shard_count, "users": len(bot.users)}
|
||
await boticord.Bots.post_stats(stats)
|
||
|
||
|
||
bot.run("your-bot-token")
|
||
```
|
||
|
||
#### С Когами
|
||
|
||
Ког с автоматической публикацией статистики раз в 15 минут + команда для публикации статистики для владельца бота.
|
||
|
||
```python
|
||
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.post_stats(stats)
|
||
|
||
|
||
def setup(bot):
|
||
bot.add_cog(BoticordCog(bot))
|
||
|
||
```
|