boticordpy/examples/autopost.py

32 lines
870 B
Python
Raw Normal View History

2022-09-10 15:00:26 +03:00
# You can use any library to interact with the Discord API.
# This example uses discord.py.
# You can install it with `pip install discord.py`.
2022-02-17 19:14:39 +03:00
from discord.ext import commands
from boticordpy import BoticordClient
bot = commands.Bot(command_prefix="!")
2022-09-10 15:00:26 +03:00
# Function that will return the current bot's stats.
2022-02-17 19:14:39 +03:00
async def get_stats():
2023-08-06 09:28:27 +03:00
return {"servers": len(bot.guilds), "shards": None, "members": len(bot.users)}
2022-02-17 19:14:39 +03:00
2022-09-10 15:00:26 +03:00
# Function that will be called if stats are posted successfully.
2022-02-17 19:14:39 +03:00
async def on_success_posting():
2023-06-05 13:11:25 +03:00
print("wow stats posting works")
2022-02-17 19:14:39 +03:00
2022-09-10 15:00:26 +03:00
2023-06-05 13:11:25 +03:00
boticord_client = BoticordClient(
"your_boticord_api_token", version=3
) # <--- BotiCord API token
2022-02-17 19:14:39 +03:00
autopost = (
boticord_client.autopost()
.init_stats(get_stats)
.on_success(on_success_posting)
2023-06-05 13:11:25 +03:00
.start("id_of_your_bot") # <--- ID of your bot
2022-02-17 19:14:39 +03:00
)
2023-06-05 13:11:25 +03:00
bot.run("bot token") # <--- Discord bot's token