DiscordPHP-BridgeBot Documentation

ModerationActions
in package
implements ProvidesActions uses UsesTwitch

FinalYes

Moderation, chat settings and the broadcast controls.

Everything here acts as the bot's own account in its capacity as a moderator, so moderator_id is always the bot's user id — Twitch requires the moderator to be the authenticated user, and a token cannot moderate on someone else's behalf.

These are the commands with real consequences, so the permission rungs are set deliberately rather than uniformly: timing someone out is a moderator's job, but handing out the moderator badge, raiding, and running an ad break are the broadcaster's.

Tags
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Interfaces

ProvidesActions
A connector that brings commands of its own.

Constants

MAX_TIMEOUT  : mixed = 1209600
Twitch caps a timeout at fourteen days.

Methods

actions()  : array<int, Action>
Every command this connector defines.
announce()  : PromiseInterface<string|int, string>
attributed()  : string
An announcement's text, saying who sent it and from where when that was not Twitch.
ban()  : PromiseInterface<string|int, string>
clear()  : PromiseInterface<string|int, string>
commercial()  : PromiseInterface<string|int, string>
emoteonly()  : PromiseInterface<string|int, string>
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.
followersonly()  : PromiseInterface<string|int, string>
isOff()  : bool
mod()  : PromiseInterface<string|int, string>
moderatorId()  : string
The bot's own user id.
onUser()  : PromiseInterface<string|int, string>
Resolves the first argument to a Twitch user, then runs `$then`.
raid()  : PromiseInterface<string|int, string>
reason()  : string
The reason for a moderation action, from whichever form supplied it.
settings()  : PromiseInterface<string|int, mixed>
shoutout()  : PromiseInterface<string|int, string>
slow()  : PromiseInterface<string|int, string>
subonly()  : PromiseInterface<string|int, string>
timeout()  : PromiseInterface<string|int, string>
twitch()  : TwitchConnector
unban()  : PromiseInterface<string|int, string>
unmod()  : PromiseInterface<string|int, string>
unraid()  : PromiseInterface<string|int, string>
unvip()  : PromiseInterface<string|int, string>
vip()  : PromiseInterface<string|int, string>

Constants

MAX_TIMEOUT

Twitch caps a timeout at fourteen days.

private mixed MAX_TIMEOUT = 1209600

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>

attributed()

An announcement's text, saying who sent it and from where when that was not Twitch.

private static attributed(Context $context, string $text) : string

Twitch shows every announcement as the host's. Typed in Twitch chat, the command that made it is right above it; typed in Discord or Telegram, nothing would say it came from someone else, so it says so the way relayed chat does. The name is defused the same way too (F2).

Parameters
$context : Context
$text : string
Return values
string

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

isOff()

private isOff(string $value) : bool
Parameters
$value : string
Return values
bool

moderatorId()

The bot's own user id.

private moderatorId(Context $context) : string

Twitch requires moderator_id to be the authenticated user, so this is never the person who typed the command — a distinction worth keeping in mind when reading the audit log, where every action is attributed to the bot account.

Parameters
$context : Context
Return values
string

onUser()

Resolves the first argument to a Twitch user, then runs `$then`.

private onUser(Context $context, Arguments $arguments, callable(string, array<string, mixed>): PromiseInterface $then) : PromiseInterface<string|int, string>

Everything here names a person, and naming the wrong one bans the wrong person, so an unresolvable login stops the command rather than being passed on to Helix to interpret.

Parameters
$context : Context
$arguments : Arguments
$then : callable(string, array<string, mixed>): PromiseInterface
Return values
PromiseInterface<string|int, string>

reason()

The reason for a moderation action, from whichever form supplied it.

private reason(Arguments $arguments, int $from) : string

The named value wins. A slash command omits an unsupplied optional entirely, so /timeout user:bob reason:spam — no seconds — leaves a gap that stops positional recording at bob; reading positionally alone would silently drop the reason and log the ban as unexplained.

Parameters
$arguments : Arguments
$from : int
Return values
string

settings()

private settings(Context $context, array<string, mixed> $fields) : PromiseInterface<string|int, mixed>
Parameters
$context : Context
$fields : array<string, mixed>
Return values
PromiseInterface<string|int, mixed>
On this page

Search results