mirror of
https://github.com/boticord/boticordpy.git
synced 2024-09-23 03:42:01 +03:00
some new examples
This commit is contained in:
parent
d618cbdcba
commit
71863f05d5
6 changed files with 129 additions and 8 deletions
34
README.md
34
README.md
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
### Примеры
|
### Примеры
|
||||||
|
|
||||||
Публикуем статистику нашего бота в Boticord.
|
#### Без Когов
|
||||||
|
Публикуем статистику при запуске бота.
|
||||||
|
|
||||||
```Python
|
```Python
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
@ -33,3 +34,34 @@ async def on_ready():
|
||||||
|
|
||||||
bot.run("your-bot-token")
|
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))
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: boticordpy
|
Name: boticordpy
|
||||||
Version: 1.3.6
|
Version: 1.3.7
|
||||||
Summary: Simple Python Module for boticord api
|
Summary: Simple Python Module for boticord api
|
||||||
Home-page: https://github.com/grey-cat-1908/boticordpy
|
Home-page: https://github.com/grey-cat-1908/boticordpy
|
||||||
Author: KerdokuCat
|
Author: KerdokuCat
|
||||||
|
@ -29,7 +29,8 @@ License-File: LICENSE.txt
|
||||||
|
|
||||||
### Примеры
|
### Примеры
|
||||||
|
|
||||||
Публикуем статистику нашего бота в Boticord.
|
#### Без Когов
|
||||||
|
Публикуем статистику при запуске бота.
|
||||||
|
|
||||||
```Python
|
```Python
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
@ -49,4 +50,35 @@ async def on_ready():
|
||||||
bot.run("your-bot-token")
|
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))
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ copyright = '2021, Grey Cat'
|
||||||
author = 'Grey Cat'
|
author = 'Grey Cat'
|
||||||
|
|
||||||
# The full version, including alpha/beta/rc tags
|
# The full version, including alpha/beta/rc tags
|
||||||
release = '1.3.6'
|
release = '1.3.7'
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
|
|
|
@ -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")
|
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
23
examples/example_cog.py
Normal 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))
|
2
setup.py
2
setup.py
|
@ -12,7 +12,7 @@ README = (HERE / "README.md").read_text(encoding="utf8")
|
||||||
setup(
|
setup(
|
||||||
name="boticordpy",
|
name="boticordpy",
|
||||||
packages = ['boticordpy', 'boticordpy.modules'],
|
packages = ['boticordpy', 'boticordpy.modules'],
|
||||||
version="1.3.6",
|
version="1.3.7",
|
||||||
description="Simple Python Module for boticord api",
|
description="Simple Python Module for boticord api",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|
Loading…
Reference in a new issue