Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Almost There

Compare
Choose a tag to compare
@b1naryth1ef b1naryth1ef released this 20 Oct 08:48
· 350 commits to master since this release

Version 0.0.6 brings a set of stability features, and the introduction of a new feature set aimed at larger sharded bots.

Auto Sharding

A big motivation behind the original development of disco was to help support larger bots by providing a feature-rich toolset. The biggest tool in that set comes in this release, in the form of auto sharding. Auto sharding allows a bot developer to completely ignore the complexity of sharding, while having a stable and reliable way to roll it out. Auto sharding can be used by simply passing the --shard-auto flag at runtime.

Sharding IPC

The second big tool in our large-bot toolset comes with sharding IPC, an API for inter-shard communication. This API was built to work with auto sharding (and would require a bit of manual code to work outside of that context), and provides a very simple interface.

For example, calling a function on every shard and aggregating the result:

def on_all_shards(bot):
    return 103559217914318848 in bot.client.state.users

bot.shards.all(on_all_shards)
# {0: True, 1: True, 2: True, 3: False ,4: True ,5: True, 6: True, 7: False, 8: True, 9: True}

Or, calling a function on a specific shard:

def on_shard(bot):
    return len(bot.client.state.users)

bot.shards.on(5, on_shard).wait()
# 83552

Functions to be run on the shard should not have closures which bind any non-simple variables (e.g. serialize variables) and the same is true for their return values.

Plugin Context

This release introduces the concept of plugin contexts, which are just dictionaries passed from one instance of a plugin to another (during reload). The Plugin.load function is now called with its only argument being the context dictionary, and the Plugin.unload can now return a dictionary which will be passed to the Plugin.load function when reloading. Contexts are useful for storing plugin local state without using globals, and persist across reloads.

Minor Additions

  • Added the bot gateway endpoint, exposed via APIClient.gateway_bot_get
  • Added typing endpoint, exposed via APIClient.channels_typing(channel_id).
  • Added the oob flag to the command definition, which will not track the command execution greenlet in the plugin object. This is very specifically intended for reloading the current plugin from within a command loaded from the plugin.
  • Added the conditional argument to Plugin.listen and Plugin.listen_packet which allows for a callable conditional (which is checked before the event is passed on to the listener) taking the single event argument and returning a bool (true = event matches, call the event listener)
  • All command/listener execution greenlets are now bound to the plugin instance and will be terminated on unload
  • Added Client.update_presence for updating the users presence
  • Added documentation for all gateway events
  • Added Channel.delete and Channel.close
  • Added Guild.member_count and Guild.presences fields (which where previously missing)
  • Added MessageTable for building ASCII tables in messages

Minor Changes

  • SEND/RECV sentinels are now integers
  • Model.to_dict now has somewhat proper recursion and type conversion
  • Bumped holster to v1.0.8 for conditional predicates and some other various fixes

Fixes

  • Fix APIClient.webhooks_token_delete using an invalid constant
  • Fixed the HTTP client retrying on a 400 response code
  • Fixed role mentions in bot command handling
  • Fixed newlines in command arguments not parsing correctly
  • Fixed subclassed method definitions smashing the base Plugin name space
  • Fixed bug where heartbeater tasks where not killed when the Gateway WS was closed, causing weird error spam and potentially heartbeat spam to discord.
  • Fixed missing guild_id on GuildBanAdd and GuildIntegrationsUpdate
  • Fixed missing fields on GuildEmojisUpdate
  • Fixed incorrect type for TypingStart.timestamp
  • Fixed voice states not being tracked in State.voice_states
  • Fixed exception being thrown when a guild member is not in a guilds members object (on GuildMemberUpdate)
  • Fixed Channel.delete_messages attempting to call bulk delete when it missed the required permissions to do so. It now properly falls back to individual message deletes when it cannot manage messages.
  • Fixed HashMap.filter and HashMap.map being invalid

Roadmap

V0.0.7

Full voice support

V0.0.8

A more complete API implementation for both the REST API and the Gateway API.