2024-08-26

·Visit Project

LanyardJS

Provides an API to fetch user data and their activities from Discord, including Spotify integration

Table of Contents

Introduction

This project provides an API to fetch user data and their activities from Discord, including Spotify integration.

Project Tree

📦 
├─ .gitignore
├─ LICENSE
├─ README.md
├─ package.json
└─ src
   ├─ api
   │  ├─ controllers
   │  │  └─ userController.js
   │  ├─ middlewware
   │  │  └─ errorMiddleware.js
   │  └─ routes
   │     └─ userRoutes.js
   ├─ bot
   │  ├─ commands
   │  │  └─ userdata.js
   │  └─ events
   │     ├─ messageCreate.js
   │     └─ ready.js
   ├─ config
   │  ├─ botConfig.js
   │  └─ serverConfig.js
   ├─ index.js
   ├─ services
   │  └─ userService.js
   └─ utils
      └─ dateUtils.js

API Endpoints

Fetch User Data

Endpoint: GET /api/v1/user/:userid

Description: Fetch detailed user data from Discord for a specified user ID.

URL Parameters:

  • userid (required): The ID of the Discord user you want to retrieve data for.

Example Response:

{
  "data": {
    "spotify": {
      "track_id": "spotify_track_id",
      "timestamps": {
        "start": 1609459200000,
        "end": 1609462800000
      },
      "album": "Album Name",
      "album_art_url": "https://i.scdn.co/image/spotify_image_id",
      "artist": "Artist Name",
      "song": "Song Title"
    },
    "discord_user": {
      "id": "user_id",
      "username": "username",
      "avatar": "avatar_url",
      "discriminator": "discriminator",
      "bot": false,
      "clan": null,
      "global_name": "username",
      "avatar_decoration_data": null,
      "display_name": "username",
      "public_flags": 0
    },
    "activities": [
      {
        "id": "activity_id",
        "name": "Activity Name",
        "type": 0,
        "timestamps": {
          "start": 1609459200000
        },
        "created_at": 1609459200000,
        "details": "Activity Details",
        "state": "Activity State",
        "assets": {
          "large_text": "Large Text",
          "large_image": "large_image_id"
        },
        "party": {
          "id": "party_id"
        }
      }
    ],
    "discord_status": "online",
    "active_on_discord_web": true,
    "active_on_discord_desktop": false,
    "active_on_discord_mobile": true,
    "listening_to_spotify": true
  },
  "success": true
}

Discord Commands

The bot responds to the following command in a Discord channel:

  • !userdata @user - Fetches and displays the user data of the mentioned user in JSON format.
  • !who @user - Displays the user's lanyardjs link in an embed.

#Tags

api
lanyard
lanyardjs

Contact

Need more project details, have any doubts in mind, or interested in working together? Reach out to me directly at krushnavyas066@gmail.com. I'd be happy to connect and talk!

← All Projects