some new examples

This commit is contained in:
Victor Kotlin 2021-09-11 16:10:17 +03:00
parent d618cbdcba
commit 71863f05d5
6 changed files with 129 additions and 8 deletions

View file

@ -14,7 +14,8 @@
### Примеры
Публикуем статистику нашего бота в Boticord.
#### Без Когов
Публикуем статистику при запуске бота.
```Python
from discord.ext import commands
@ -33,3 +34,34 @@ async def on_ready():
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.postStats(stats)
def setup(bot):
bot.add_cog(BoticordCog(bot))
```

View file

@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: boticordpy
Version: 1.3.6
Version: 1.3.7
Summary: Simple Python Module for boticord api
Home-page: https://github.com/grey-cat-1908/boticordpy
Author: KerdokuCat
@ -29,7 +29,8 @@ License-File: LICENSE.txt
### Примеры
Публикуем статистику нашего бота в Boticord.
#### Без Когов
Публикуем статистику при запуске бота.
```Python
from discord.ext import commands
@ -49,4 +50,35 @@ async def on_ready():
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.postStats(stats)
def setup(bot):
bot.add_cog(BoticordCog(bot))
```

View file

@ -22,7 +22,7 @@ copyright = '2021, Grey Cat'
author = 'Grey Cat'
# The full version, including alpha/beta/rc tags
release = '1.3.6'
release = '1.3.7'
# -- General configuration ---------------------------------------------------

View file

@ -24,10 +24,12 @@ Or just clone the repo: https://github.com/grey-cat-1908/boticordpy
Post Bot Stats
Examples
-------------------------
Let's post our bot's stats to Boticord.
**Without Using Cogs System**
Post bot stats when bot is ready.
::
@ -48,3 +50,35 @@ Let's post our bot's stats to Boticord.
bot.run("your-bot-token")
..
**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))
..

23
examples/example_cog.py Normal file
View file

@ -0,0 +1,23 @@
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))

View file

@ -12,7 +12,7 @@ README = (HERE / "README.md").read_text(encoding="utf8")
setup(
name="boticordpy",
packages = ['boticordpy', 'boticordpy.modules'],
version="1.3.6",
version="1.3.7",
description="Simple Python Module for boticord api",
long_description=README,
long_description_content_type="text/markdown",