πŸš€ Lanyard API plugin for Vue to easily track your Discord status. Supports REST and WebSocket methods.

Overview

πŸš€ Vue Lanyard Plugin

A Vue (2) plugin to track your Discord status using Lanyard API.

Vue Lanyard plugin image

Lanyard is a service that makes it super easy to export your live Discord presence to an API endpoint and to a WebSocket for you to use wherever you want. This plugin creates a connection between Lanyard and your Vue app as a plugin and lets you access the $lanyard anywhere in your app!

✨ This plugin supports both REST and WebSocket methods.

πŸ”§ Install

You'll need Node.js and an existing Vue app to use this plugin (you can find an example vue-cli app in example/).

  • Download the module via NPM, Yarn or your package manager.
    • For NPM: npm install @eggsydev/vue-lanyard
    • For Yarn: yarn add @eggsydev/vue-lanyard

πŸ€“ Setup

After you download the plugin, you have to import it into your app with Vue.use(). This will let you access the $lanyard method anywhere in your app!

import Vue from "vue";
import VueLanyard from "@eggsydev/vue-lanyard";

Vue.use(VueLanyard);

// Rest of your Vue app configuration

And then you will have the access to $lanyard method in your app.

export default {
  // Call it on `mounted`
  async mounted() {
    const response = await this.$lanyard({
      userId: "162969778699501569",
    });

    // Do whatever you want with Lanyard response object
  },
};

Lanyard method allows you to choose between WebSocket and REST connection. In both cases, the userId option is required. You can also have multiple IDs in array format.

/*
  This will actually return multiple Lanyard objects in a single array.

  Note:
    I suggest you to use WebSocket connections when listening to
    multiple users because this mode basically sends a different
    request for each user at the same time.
*/

this.$lanyard({
  userId: ["162969778699501569", "94490510688792576"],
});

If you want to use the WebSocket way and get changes in real-time, you can follow this example.

/*
  Listening to WebSocket is a bit different but it's nothing
  different than listening to a 
*/

const socket = await this.$lanyard({
  userId: "162969778699501569",
  socket: true,
});

// Set a listener for "message" event
socket.addEventListener("message", ({ data }) => {
  const { d: status } = JSON.parse(data);

  // Do whatever you want with `status`
});

⚠ When using WebSocket, if you're using Vue Router, it won't close the socket connection even after you change the page, and if you return to the same page where you are connecting to socket, it will create another connection which will cause conflicts and unnecessary socket connections. You can use Vue's beforeDestroy hook to disconnect from the socket previous socket before leaving the page, check example/src/components/Lanyard/WebSocket.vue for more details.

πŸ€” When to use WebSocket?

WebSockets are amazing, but do you actually need them? That depends on what you want to achieve. If you want to achieve these, you might want to go with WebSocket.

  • You want real-time updates.
  • You want to get presence data of multiple users but don't want separate requests for each user.
  • You want something better and more performant than sending requests with setInterval.

If you only want to fetch data when the page loads and don't want to update it until another page refresh, you can go with REST (normal) method. It's up to you!

🌟 Nuxt.js

You can use this plugin the way you use Vue plugins (for client-side) in Nuxt.js!

// plugins/VueLanyard.js
import Vue from "vue";
import VueLanyard from "@eggsydev/vue-lanyard";

Vue.use(VueLanyard);

And reference that file in your nuxt.config.

// nuxt.config.js
export default {
  plugins: [
    {
      src: "@/plugins/VueLanyard",
      mode: "client",
    },
  ],
};

✍ TypeScript

This plugin comes with type support. You can import types from @eggsydev/vue-lanyard/@types and use them in your script.

πŸŽ‰ Thanks

  • Phineas - Creator of Lanyard API
  • Documents I followed online to create this plugin
You might also like...
Learn how to use Contentful by keeping track of your favorite albums per month. Built using Nuxt.js and Contentful.
Learn how to use Contentful by keeping track of your favorite albums per month. Built using Nuxt.js and Contentful.

Learn how to use Contentful by keeping track of your favorite albums per month. Built using Nuxt.js and Contentful.

Track your customers feedback to build better products with LogChimp
Track your customers feedback to build better products with LogChimp

LogChimp Track user feedback to build better products Docs · Contribute · Twitter · Discord 🧐 About LogChimp is self-hosted platform for products mak

An offline-first SPA using Vue.js, the WordPress REST API and Progressive Web Apps
An offline-first SPA using Vue.js, the WordPress REST API and Progressive Web Apps

vue-wordpress-pwa An offline-first SPA using Vue.js, the WordPress REST API and Progressive Web Apps Live version: https://www.fullstackweekly.com/ De

Project Restobar : A project created with help of Vue.js and REST API's how a user can signUp , login by making an account.

restobar Project setup npm install Compiles and hot-reloads for development npm run serve Compiles and minifies for production npm run build Lints

Browse and test a REST API described with the OpenAPI 3.0 Specification

OpenAPI 3 viewer This service is designed to easily browse and test a REST API described with the OpenAPI 3.0 Specification (fka Swagger Specification

A Status Page built on Cloudflare Worker and Pages (Vue + Tailwind)

Statuside A Status Page built on Cloudflare Worker and Pages (Vue + Tailwind). Inspired by Cachet, Statusfy, and Atlassian Statuspage. ⚠️ This is stil

A Completed todolist app built in Vue, have advanced filter feature , like filter by status, date, and have search , sort features

todo-app Project setup npm install Compiles and hot-reloads for development npm run serve Compiles and minifies for production npm run build Lints

Desktop app for miners on the Helium network. Small taskbar tool to follow status, activity and earnings for the chosen devices.

Helium-Flick is a desktop application for Helium hotspot owners, in the shape of a small taskbar tool, which allows you to follow the status, activity and earnings for the devices of your list. The purpose of this application is to keep track of all your hotspots, directly at the corner of your screen.

Vue js Axios example - Get/Post/Put/Delete request with Rest API - JSON data
Vue js Axios example - Get/Post/Put/Delete request with Rest API - JSON data

Vue Axios example with Rest API Vue Client with Axios to make CRUD requests to Rest API in that: Vue Axios GET request: get all Tutorials, get Tutoria

Comments
  • chore(deps): bump url-parse from 1.5.3 to 1.5.8 in /example

    chore(deps): bump url-parse from 1.5.3 to 1.5.8 in /example

    Bumps url-parse from 1.5.3 to 1.5.8.

    Commits
    • bb0104d 1.5.8
    • d5c6479 [fix] Handle the case where the port is specified but empty
    • 4f2ae67 [security] Add credits for CVE-2022-0639
    • 8b3f5f2 1.5.7
    • ef45a13 [fix] Readd the empty userinfo to url.href (#226)
    • 88df234 [doc] Add soft deprecation notice
    • 78e9f2f [security] Fix nits
    • e6fa434 [security] Add credits for incorrect handling of userinfo vulnerability
    • 4c9fa23 1.5.6
    • 7b0b8a6 Merge pull request #223 from unshiftio/fix/at-sign-handling-in-userinfo
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(v1.1.3)
  • v1.1.3(Nov 24, 2021)

    • refactor: add KV interface 7ca11f8
    • Merge pull request #3 from iamtuhana/patch-1 b2bdf96
    • types(lanyard): fixes & improvements f425405
    • chore(deps): upgrade example dependencies b89e4d1

    https://github.com/eggsy/vue-lanyard/compare/v1.1.2...v1.1.3

    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(May 27, 2021)

    • refactor: improve types 8cffb38
    • fix: typo on websocket example (@RedS-DEV) e66ec95
    • docs: add license 6154d79
    • fix: create a seperate interface for error (@barbarbar338) 207281e
    • style: format (@barbarbar338) af12f38
    • fix: add error prop to LanyardResponse type (@barbarbar338) aa2424f
    • fix: center image df94bbd

    https://github.com/eggsy/vue-lanyard/compare/v1.1.1...v1.1.2

    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(May 9, 2021)

  • v1.1.0(May 9, 2021)

    • feat: move function to functions directory a0fe77f
    • chore: remove types from src/ dc27a3e
    • chore: move function outside of the index file ab03b42
    • chore: use separate file for constants ff0c294
    • refactor: fix and improve types 6213dbf
    • docs: add nuxt.js and typescript notice 77efa8c
    • chore: change types directory 5251cf8
    • feat: add lanyard response types bb34a71
    • chore: use constant for websocket uri 632e1e4

    https://github.com/eggsy/vue-lanyard/compare/v1.0.6...v1.1.0

    Source code(tar.gz)
    Source code(zip)
  • v1.0.6(May 9, 2021)

    • fix: emojis not supported on npm f3ec8ba
    • fix: wrong username 073912a
    • feat: create funding.yml 9e396cb
    • style: rename module name 3f892b6

    https://github.com/eggsy/vue-lanyard/compare/v1.0.5...v1.0.6

    Source code(tar.gz)
    Source code(zip)
  • v1.0.5(May 9, 2021)

Owner
EGGSY
A Turkish full-stack JavaScript developer and an ELT student.
EGGSY
Rest-api-client - Easily accessible REST API client available on your favorite browser

REST API Client Website: https://l23de.github.io/rest-api-client/ Inspirations t

Lester Huang 0 Jan 1, 2022
REST Countries API with color theme switcher is one of the Frontend Mentor challenges. It uses Composition API for Vue.js 3 and pulls data from the REST Countries API.

REST Countries API REST Countries API with color theme switcher is one of the Frontend Mentor challenges. It uses Composition API for Vue.js 3 and pul

Gizem Korkmaz 7 Sep 5, 2022
A DDL Countdown tools for a SUFE SIMEr to track down CS conference in tenure track list

A DDL ⏳ Countdown tools ?? for a SUFE SIMEr to track down CS conference in tenure track lists, which can retrieve conference through CCF and TierLevel rank ?? .

null 0 Apr 1, 2022
Connect and play with Supabase REST API / Graphql easily

Connect and play with Supabase REST API / Graphql easily

zernonia 36 Nov 29, 2022
Rick-and-morty-vue - App web de Rick And Morty utilizando Vue 3 - Composition API, Vuex, API Rest

Rick And Morty utilizando Vue 3 - Composition API, Vuex, API Rest Project setup npm install Compiles and hot-reloads for development npm run serve C

Luis TimanΓ‘ 0 Jan 1, 2022
App that performs CRUD operations in which users can track projects, tasks under projects, total duration of each project and task. Project is being build with Nuxt js 3, Axios, Pinia, Bootstrap 5 and Vue composition API

Nuxt 3 Minimal Starter Look at the nuxt 3 documentation to learn more. Setup Make sure to install the dependencies: # yarn yarn install # npm npm ins

Sergio Terrero 2 Nov 1, 2022
A websocket based remote event system

vue-remote A websocket based remote event system for Vue.js. Works with Vue 2.0, untested with Vue 1.0. Installation 1.) Install package via NPM npm i

Justin MacArthur 22 Oct 22, 2022
native websocket with vuex integration

vue-native-websocket-es5 Β· Fork of https://github.com/nathantsoi/vue-native-websocket#readme but without using ES6 Proxy native websocket implementati

null 1 Oct 21, 2022
native websocket with vuex integration

vue-native-websocket native websocket implementation for Vuejs 2 and Vuex Install yarn add vue-native-websocket # or npm install vue-native-websocke

James Leskovar 1 May 10, 2018
A Laravel Nova tool to manage and keep track of each one of your logs files.

A Laravel Nova tool to manage and keep track of each one of your logs files.

Artem Stepanenko 15 Dec 4, 2022