← Public packages
@noah/mega-radio
MEGA Radio (the WAKE album) for members of the MEGA.dev Discord: sign in with Kody, verify with Discord, listen with repeat.
Files
import { GUILD_ID, GUILD_INVITE, GUILD_NAME, HOSTED_URL, MEMBERSHIP_DAYS, SIGNUP_URL } from './config.ts'
import { expiresAt, getMembership, isActive } from './membership.ts'
import { currentVisitor } from './visitor.ts'
/**
* Your MEGA Radio access: whether your last Discord check (made in the app with "Check with Discord")
* still counts. Read-only.
*
* @returns `{ member, checkValidDays, lastCheck, guild, links }`
*/
export default async function status() {
const links = { app: `${HOSTED_URL}/`, signUp: SIGNUP_URL, discordInvite: GUILD_INVITE }
const guild = { id: GUILD_ID, name: GUILD_NAME }
const v = await currentVisitor()
if (!v) return { signedIn: false, member: false, checkValidDays: MEMBERSHIP_DAYS, guild, links }
const m = await getMembership(v.userId)
return {
signedIn: true,
username: v.username,
member: isActive(m),
checkValidDays: MEMBERSHIP_DAYS,
lastCheck: m ? { member: m.member, discordName: m.discordName, checkedAt: m.checkedAt, expiresAt: expiresAt(m) } : null,
guild,
links,
}
}