Skip to content
ForgeCastDocs

Tips, services, Discord

Tips from Ko-fi, Streamlabs and StreamElements, the streamer's Spotify and Google, and their Discord server.

Functions

donations.on(event, handler)

Hear tips from outside YouTube (Event.Tip; donations.on("tip", fn)). They also arrive in the app's event feed as support, so events.on("superchat") hears them too.

  • event: string
  • handler: fun(t: Tip)

Returns integer id

donations.on("tip", function(t)
  if t.amount then goals.add("support", money.convert(t.amount.value, t.amount.currency)) end
end)

donations.off(id)

Stop a handler made with donations.on.

  • id: integer

Returns boolean found

donations.recent(n)

The latest tips, newest first (10 by default, up to 50).

  • n: integer, optional

Returns Tip[]

oauth.connect(provider, opts, callback)

Ask to use a service the streamer connects in ForgeCast: "spotify" or "google" (scopes: "sheets", "calendar.readonly", "drive.file"). The streamer says yes once; callback({ provider, account }) or callback(nil, why). Call it when the plugin starts.

Name

Type

Returns integer id

oauth.connect("spotify", { scopes = { "user-read-currently-playing" } }, function(ok)
  if not ok then return end
  oauth.request("spotify", { url = "https://api.spotify.com/v1/me/player/currently-playing" }, function(r)
    if r.json then overlay.set("song", r.json.item.name) end
  end)
end)

oauth.status(provider, callback)

Whether a service is connected: { connected, account, scopes } (account only once the streamer allowed this plugin to use it).

  • provider: string
  • callback: fun(status: { connected: boolean, account: string?, scopes: string[] }?, error?: string)

Returns integer id

oauth.request(provider, req, callback)

A request to that service's API (https://api.spotify.com; Google: https://sheets.googleapis.com, and Calendar and Drive on https://www.googleapis.com), signed in as the streamer. Only after oauth.connect said yes; the plugin never sees the token.

Name

Type

Returns integer id

discord.send(channel, message, callback)

Post in the streamer's Discord server through ForgeCast's bot (added in Connections). It never pings @everyone, roles or people. Up to 10 messages a minute; an embed's title is up to 256 characters, its description 4096, its image https.

Name

Type

Returns integer id

stream.on(Event.StreamStart, function(s) discord.send("announcements", "We're live: " .. (s.title or "come say hi")) end)

discord.channels(callback)

The server's text channels the bot can post in: { guild = { id, name }, channels = { { id, name } } }.

  • callback: fun(result: { guild: { id: string, name: string }?, channels: { id: string, name: string }[] }?, error?: string)

Returns integer id

Types

Open a type to see its fields; type names above link here.

On this page