server module#
- add_cmd(name: str, *, aliases: list[str] = None, source: str = None, flag: str = None, burst: int = None, rate: float = None, output: str)[source]#
- command(name: str, *aliases: str, flag: str = '', force_argcount: bool = False, burst: int = 1, rate: float = 3.0, twitch: bool = True, discord: bool = True)[source]#
This decorator builds TwitchCommand and DiscordCommand versions of commands while leaving the original functions untouched.
- with_savefile(name: str, *aliases: str, optional_save: bool = False, **kwargs)[source]#
Decorator for commands that require a save.
- class TwitchConn(*args, **kwargs)[source]#
Bases:
AutoBot- load_tokens(path=None)[source]#
-
Method used to load tokens when the
Clientstarts.Note
This method is called by the client during
login()but beforesetup_hook()when theload_tokenskeyword-argument isTruein either,run(),start()orlogin()(Default).You can override this method to implement your own token loading logic into the client, such as from a database.
By default this method loads tokens from a file named “.tio.tokens.json” if it is present; always present if you use the default method of saving tokens.
However, it is preferred you would override this function to load your tokens from a database, as this has far less chance of being corrupted, damaged or lost.
Parameters#
- path: str | None
The path to load tokens from, if this is None and the method has not been overriden, this will default to .tio.tokens.json. Defaults to None.
Examples#
class Client(twitchio.Client): async def load_tokens(self, path: str | None = None) -> None: # Code to fetch all tokens from the database here... ... for row in tokens: await self.add_token(row["token"], row["refresh"])
- save_tokens(path=None)[source]#
-
Method which saves all the added OAuth tokens currently managed by this Client.
Note
This method is called by the client when it is gracefully closed and the
save_tokenskeyword-argument isTruein either,run(),start()orlogin()(Default).Note
By default this method saves to a JSON file named “.tio.tokens.json”.
You can override this method to implement your own custom logic, such as saving tokens to a database, however it is preferred to use
add_token()to ensure the tokens are handled as they are added.Parameters#
- path: str | None
The path of the file to save to. Defaults to .tio.tokens.json.
- class DiscordConn(command_prefix: PrefixType[BotT], *, help_command: Optional[HelpCommand] = <default-help-command>, tree_cls: Type[app_commands.CommandTree[Any]] = <class 'discord.app_commands.tree.CommandTree'>, description: Optional[str] = None, allowed_contexts: app_commands.AppCommandContext = ..., allowed_installs: app_commands.AppInstallationType = ..., intents: discord.Intents, **options: Unpack[_BotOptions])[source]#
Bases:
Bot
- async timer_cmd(ctx: Context | Context, action: str, name: str, *args: str)[source]#
Manipulate the timers. Syntax:
- create <name> [interval]
will create a new timer with the name and the given interval, if specified. It has no other effect.
- add <name> <commands>
will add all of the commands (space-separated) to the timer name - it does not start the timer. If it is running, it will seamlessly integrate the new command at the current point in the rotation.
- remove <name> <commands>
will remove all of the commands (space-separated) to the timer name - it does not stop or delete the timer.
- delete <name> completely removes a timer and associated commands.
This cannot be undone.
- auto <name> [interval]
creates a new timer with the given interval, if specified, and exactly one command name. It immediately starts it. This is basically used for single-command sponsored timers and the like. The internal timer name will start with auto_, followed by the command name, and can be edited normally afterwards. It will automatically delete itself when the stream ends.
- status <name>
outputs the commands and interval tied to this timer.
- start <name>
starts the given timer.
- stop <name>
stops the given timer.
- interval <name> <interval>
changes the interval of an existing timer. This will have some weird double-send glitch if editing the interval of a running timer, but is mostly fine otherwise.
- async command_cmd(ctx: Context | Context, action: str, name: str, *args: str)[source]#
Syntax: command <action> <name> [+flag] <output>
- async quote_stuff(ctx: Context | Context, arg: str = 'random', *rest)[source]#
Edit the quote database or pull a specific or random quote.
- async clip_cmd(ctx: Context | Context, arg: str = 'random', *rest: str)[source]#
Add a new clip or find a clip.
- async help_cmd(ctx: Context | Context, name: str = '')[source]#
Find help on the various commands in the bot.
- async now_playing(ctx: Context | Context)[source]#
Return the currently-playing song on Spotify (if any).
- async bluekey(ctx: Context | Context, save: Savefile | Save2)[source]#
Display what was skipped for the Sapphire key.
- async cards_removed(ctx: Context | Context, save: Savefile | Save2)[source]#
Display which cards were removed.
- async neowbonus(ctx: Context | Context, save: Savefile | Save2)[source]#
Display what the Neow bonus was.
- async what_if_box(ctx: Context | Context, save: Savefile | Save2)[source]#
Tell us what the Pandora’s Box gave us.
- async seed_cmd(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the run’s current seed.
- async is_seeded(ctx: Context | Context, save: Savefile | Save2)[source]#
Display whether the current run is seeded.
- async run_playtime(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the current playtime for the run.
- async shop_removal_cost(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the current shop removal cost.
- async shop_prices(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the current shop price ranges.
- async campfire_heal(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the current heal at campfires.
- async nloth_traded(ctx: Context | Context, save: Savefile | Save2)[source]#
Display which relic was traded for N’loth’s Gift.
- async event_likelihood(ctx: Context | Context, save: Savefile | Save2)[source]#
Display current event chances for the various possibilities in ? rooms.
- async rare_card_chances(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the current chance to see rare cards in rewards and shops.
- async relic_info(ctx: Context | Context, save: Savefile | Save2, index: int = 0)[source]#
Display information about the current relics.
- async relics_page2(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the relics on page 2.
- async seen_relic(ctx: Context | Context, save: Savefile | Save2, *item: str)[source]#
Output whether a given relic or card has been seen.
- async skipped_boss_relics(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the boss relics that were taken and skipped.
- async bottled_cards(ctx: Context | Context, save: Savefile | Save2)[source]#
List all bottled cards.
- async dagger_scaling(ctx: Context | Context, save: Savefile | Save2)[source]#
Get the damage value of Ritual Dagger.
- async algo_scaling(ctx: Context | Context, save: Savefile | Save2)[source]#
Get the block value of Genetic Algorithm.
- async modifiers(ctx: Context | Context, save: Savefile | Save2)[source]#
List all custom modifiers for the run.
- async score(ctx: Context | Context, save: Savefile | Save2)[source]#
Display the current score of the run
- async mt_clans(ctx: Context | Context, save: MonsterSave)[source]#
- async mt_mutators(ctx: Context | Context, save: MonsterSave)[source]#
- async mt_challenge(ctx: Context | Context, save: MonsterSave)[source]#
- async mt_artifact(ctx: Context | Context, save: MonsterSave, index: int = 0)[source]#
- async mt_pyre(ctx: Context | Context, save: MonsterSave)[source]#
- async curses(ctx: Context | Context, save: CurrentRun)[source]#
Display the current run’s curses.
- async items(ctx: Context | Context, save: CurrentRun)[source]#
Display the current run’s unequipped items.
- async get_last(ctx: Context | Context, arg1: str = '', arg2: str = '')[source]#
Get the last run/win/loss.
- async wall_card(ctx: Context | Context)[source]#
Fetch the card in the wall for the ladder savefile.
- async set_run_stats_by_date(ctx: Context | Context, date_string: str)[source]#
Update the default range for the run stats by date, this is separate from the all-time stats run cache.
- async calculate_wins_cmd(ctx: Context | Context, date_string: str | None = None)[source]#
Display the cumulative number of wins for an optional date range.
- async calculate_losses_cmd(ctx: Context | Context, date_string: str | None = None)[source]#
Display the cumulative number of losses for an optional date range.
- async calculate_streak_cmd(ctx: Context | Context)[source]#
Display Baalor’s current streak for Ascension 20 Heart kills.
- async calculate_pb_cmd(ctx: Context | Context, date_string: str | None = None)[source]#
Display Baalor’s Personal Best streaks for Ascension 20 Heart kills for an optional date range.
- async architect_total_damage(ctx: Context | Context)[source]#
Return the total damage that The Architect has sustained.
- async calculate_winrate_cmd(ctx: Context | Context, date_string: str | None = None)[source]#
Display the winrate for Baalor’s A20 Heart kills for an optional date range.
- async mastered_stuff(ctx: Context | Context, *card: str)[source]#
Tell us whether a certain card or relic is mastered.