Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wumpcord/rest

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wumpcord/rest

🥀 Standalone package for Discord's REST and CDN made for Wumpcord

  • 1.2.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

@wumpcord/rest

🥀 Standalone package for Discord's REST and CDN for Wumpcord

Usage

import { RestClient, CDN, DiscordRestError, DiscordAPIError } from '@wumpcord/rest';
import { readFileSync } from 'fs';

// CDN
CDN.getDefaultAvatar('5820'); //=> 'https://cdn.discordapp.com/embed/avatars/0.png'
CDN.getUserAvatar('280158289667555328', 'f788c8a8993bc702824700eda5623795'); //=> 'https://cdn.discordapp.com/avatars/280158289667555328/...'

// Rest
const rest = new RestClient('bot token');
rest.dispatch({
  endpoint: '/channels/:id/messages',
  method: 'POST',
  query: {
    id: '794102278004932648'
  },
  data: {
    content: 'Hello, world!'
  },
  file: {
    file: readFileSync('./path/to/some/file.png'),
    name: 'file.png'
  }
}).then(message => {
  // `message` => https://discord.com/developers/docs/resources/channel#message-object
}).catch((error) => {
  // uh oh! we received a error, what do we do???

  // Maybe it's a REST error?
  if (error instanceof DiscordRestError) {
    // `error` => DiscordRestError
  }

  // Maybe it's an API error?
  if (error instanceof DiscordAPIError) {
    // `error` => DiscordAPIError
  }

  // I guess it's none of those 3, how can it happen?
  console.error(error);
});

FAQs

Package last updated on 26 May 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc