Giter Club home page Giter Club logo

rbxts-webhooks's Introduction

Webhooks Downloads Badge Github Issues Badge NPM Version

A small package containing a layer of abstraction around Discord webhooks

Example:

import { Webhook } from '@rbxts/webhooks';

// First parameter is the webhook URL, the second parameter
// Second parameter specifies whether or not you want to automatically resend the request if it gets ratelimited. The request is automatically rescheduled to be send according to the retry_after property sent back by Discord.

(async () => {
    const webhook = new Webhook('https://discord.com/api/webhooks/807274115975118918/9Dh9svbtXdT3yUGZH1dBS6m9ez3aRcWVS0-H_KFWq51emW0ET_LrL3M3R8l-KMXvq8nw', true);
    
    try {
        await webhook.send({
            username: 'Hello',
            avatar_url: 'https://i.imgur.com/47hzofe',
            content: 'This is a plain webhook message',
            embeds: [
                {
                    title: 'My Embed Title',
                    description: 'My Embed Description',
                    url: 'https://github.com/oonqt/rbxts-webhooks',
                    image: {
                        url: 'https://www.roblox.com/bust-thumbnail/image?userId=345234&width=420&height=420&format=png',
                        height: 256,
                        width: 256
                    },
                    thumbnail: {
                        url: 'https://www.roblox.com/bust-thumbnail/image?userId=38486&width=420&height=420&format=png',
                        height: 256,
                        width: 256
                    },
                    timestamp: DateTime.now().ToIsoDate(), // Must be a valid ISO8601 timestamp.
                    color: 0xdb020d,
                    author: {
                        name: 'A Roblox Player',
                        url: 'https://www.roblox.com',
                        icon_url: 'https://www.roblox.com/bust-thumbnail/image?userId=48&width=420&height=420&format=png'
                    },
                    footer: {
                        text: 'Hello!',
                        icon_url: 'https://www.roblox.com/bust-thumbnail/image?userId=345234&width=420&height=420&format=png'
                    },
                    fields: [
                        {
                            name: 'Some field',
                            value: 'Yes'
                        },
                        {
                            name: 'Some inline field',
                            value: 'Yes',
                            inline: true
                        }
                    ]
                }
            ]
        });

        print('Successfully sent webhook!');
    } catch (err) {
        warn(`Failed to execute webhook: ${err}`);
    }
})

rbxts-webhooks's People

Contributors

oonqt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.