Socket
Book a DemoInstallSign in
Socket

sk-lanyard

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sk-lanyard

SvelteKit integration with Lanyard, an API to fetch your Discord presence

0.2.7
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

sk-lanyard (SvelteKit + Lanyard)

SvelteKit integration with Lanyard, an API to fetch your Discord presence.

sk-lanyard is fully typed and supports the entire Lanyard API, using both REST and WebSockets.

The useLanyard function returns a reactive store containing presence data.

Demo

<script>
	import { useLanyard } from 'sk-lanyard';
	const presence = useLanyard({ method: 'rest', id: '524722785302609941' });
</script>

<pre>
    <!-- Because presence is a reactive store, use $presence to access the data -->
    <code>{JSON.stringify($presence ?? {}, null, 2)}</code>
</pre>

Usage

import { useLanyard } from 'sk-lanyard';

// Optionally import Lanyard types
import type { LanyardData, LanyardHello } from 'sk-lanyard';

REST

// Use the REST API to fetch a single user
const lanyard = useLanyard({ method: 'rest', id: '524722785302609941' });
// Use an interval of 1000 ms
const lanyard = useLanyard({
	method: 'rest',
	pollInterval: 1000,
	id: '524722785302609941'
});
// Use a custom endpoint
const lanyard = useLanyard({
	method: 'rest',
	restUrl: 'https://lanyard.example.com/rest',
	id: '524722785302609941'
});

WebSockets

// Use the WebSockets API to subscribe to a single user
const lanyard = useLanyard({ method: 'ws', id: '524722785302609941' });
// Subscribe to multiple users
const lanyard = useLanyard({
	method: 'ws',
	ids: ['524722785302609941', '299707523370319883']
});
// Subscribe to all users tracked by Lanyard
const lanyard = useLanyard({ method: 'ws', all: true });
// Use a custom endpoint
const lanyard = useLanyard({
	method: 'ws',
	wsUrl: 'wss://lanyard.example.com/ws',
	id: '524722785302609941'
});

Keywords

typescript

FAQs

Package last updated on 10 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.