jykob / TSBot

Asynchronous framework to build TeamSpeak 3 Server Query bots
https://tsbot.readthedocs.io
MIT License
6 stars 3 forks source link

Breaking: Refactor query builder #23

Closed jykob closed 10 months ago

jykob commented 10 months ago

Make TSQuery objects immutable.

This makes queries stable and allows changing parameters and options easier. Example:

@bot.command("immutable", help_text="Test immutability")
async def immutability(bot: TSBot, ctx: context.TSCtx, message: str) -> None:
    q = query("sendtextmessage")
    server_wide = q.params(msg=f"SERVER WIDE: {message}", targetmode=3)
    channel_wide = q.params(msg=f"Channel wide: {message}", targetmode=2)

    await asyncio.wait([bot.send(server_wide), bot.send(channel_wide)])

This is a breaking change since you need to assing/reassign TSQuery method calls to a variable.