List Status#
yuyo.list_status provides an easy way to update a Bot's stats on bot lists.
By default this will track the count per-shard, meaning that this'll have to be running on each shard cluster instance to properly keep track of the count. This will also be relying on the GUILDS intent being declared unless a custom counting strategy is passed.
Usage#
manager = list_status.ServiceManager.from_gateway_bot(bot)
manager.add_service(list_status.TopGGService("TOKEN"))
TopGGService is used to set https://top.gg as one of the targets for updating the bot's guild count.
Top.GG API tokens are found in the "webhooks" tab while editing the bot's entry.
manager = list_status.ServiceManager.from_gateway_bot(bot)
manager.add_service(list_status.DiscordBotListService("TOKEN"))
DiscordBotListService is used to set https://discordbotlist.com as one of the targets for updating the bot's guild count.
manager = list_status.ServiceManager.from_gateway_bot(bot)
manager.add_service(list_status.BotsGGService("TOKEN"))
BotsGGService is used to set https://discord.bots.gg as one of the targets for updating the bot's guild count.
Bots.gg API tokens are found at https://discord.bots.gg/docs (when logged in).
Custom service#
manager = list_status.ServiceManager.from_gateway_bot(bot)
@manager.with_service()
async def service(client: list_status.AbstractManager, /) -> None:
count = await client.counter.count()
if isinstance(count, int):
... # This is a global count of how many guilds the bot is in.
else:
# This is a mapping of shard IDs to guild counts.
count # type: collections.abc.Mapping[int, int]
Services are simply asynchronous callbacks which call AbstractManager.counter.count
to get the most recent count(s) then pass it on.
AbstractManager.counter.count
may raise CountUnknownError to indicate an unknown state and will return either int to indicate a global guild count or Mapping[int, int]
to give per-shard guild counts.
Counting Strategies#
Sake counting#
cache # type: sake.abc.GuildCache
counter = list_status.SakeStrategy(cache)
manager = list_status.ServiceManager.from_gateway_bot(bot, strategy=counter)
The Sake strategy lets this be used with an asynchronous Redis guild cache. This strategy will only be keeping track of a global guild count (rather than per-shard like the default counters) and therefore you should only ever need to have one instance of this running with Sake.