DiscordPHP-BridgeBot Documentation

ChannelActions
in package
implements ProvidesActions uses UsesTwitch

FinalYes

Reading and editing the channel: title, category, tags, and the rest of what `PATCH /channels` accepts.

Each of these reads with no argument and writes with one, which is the shape chat commands have had since long before Helix and is worth matching: !title asks, !title Back in ten tells.

All writes go through the bot's own token, so the bot account must hold channel:manage:broadcast on the channel being edited — it is the broadcaster, or an editor on it. When it is not, Twitch's refusal is translated in explain() rather than surfaced raw, because the raw one ("401 Unauthorized") sends people looking in entirely the wrong place.

Tags
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Interfaces

ProvidesActions
A connector that brings commands of its own.

Constants

TITLE_LIMIT  : mixed = 140
Twitch truncates a title past 140 characters.

Methods

actions()  : array<int, Action>
Every command this connector defines.
channel()  : PromiseInterface<string|int, string>
current()  : PromiseInterface<string|int, object>
The channel this action acts on.
explain()  : Throwable
Turns Twitch's refusal into something actionable.
explained()  : callable(Context, Arguments): mixed
Wraps a handler so a Helix refusal reaches whoever typed the command as a sentence, rather than as "that did not work".
explainTwitch()  : Throwable
What Twitch's refusal means to the person who asked.
game()  : PromiseInterface<string|int, string>
modify()  : PromiseInterface<string|int, null>
requireWrite()  : void
Editing a channel is gated to the broadcaster, on both platforms, which on Discord means the server owner or an Administrator.
tags()  : PromiseInterface<string|int, string>
title()  : PromiseInterface<string|int, string>
twitch()  : TwitchConnector

Constants

TITLE_LIMIT

Twitch truncates a title past 140 characters.

private mixed TITLE_LIMIT = 140

Methods

actions()

Every command this connector defines.

public actions() : array<int, Action>

Each one's qualifier must be the connector's own Connector::name(); ActionRegistry refuses anything else, because a connector claiming another's qualifier is how two packages end up silently shadowing each other's commands.

Return values
array<int, Action>

current()

The channel this action acts on.

private current(Context $context) : PromiseInterface<string|int, object>
Parameters
$context : Context
Return values
PromiseInterface<string|int, object>

explain()

Turns Twitch's refusal into something actionable.

private explain(Throwable $e, Context $context) : Throwable

A 401 here almost never means the token is bad — the same token just read the channel successfully. It means the bot account is not the broadcaster and is not an editor on that channel, which is a completely different fix from the one "unauthorized" suggests.

Parameters
$e : Throwable
$context : Context
Return values
Throwable

explainTwitch()

What Twitch's refusal means to the person who asked.

private static explainTwitch(Throwable $e) : Throwable

A 4xx from Helix carries a message written for people — "The user specified in the user_id field is already banned." — and nothing secret, so it is passed on. Anything else (a 5xx, a dropped connection) is left for the adapter to log and summarise.

Parameters
$e : Throwable
Return values
Throwable

modify()

private modify(Context $context, array<string, mixed> $fields) : PromiseInterface<string|int, null>
Parameters
$context : Context
$fields : array<string, mixed>
Return values
PromiseInterface<string|int, null>

requireWrite()

Editing a channel is gated to the broadcaster, on both platforms, which on Discord means the server owner or an Administrator.

private requireWrite(Context $context) : void
Parameters
$context : Context
On this page

Search results