Git Product home page Git Product logo

discord.hook's Introduction

discord.hook

A module for Discord Webhooks written in JavaScript.

NPM

Installing

npm i --save discord.hook

Webhook Class

const Hook = require('discord.hook');
const client = new Hook.Client('webhook-url');

Sending Message

const Hook = require('discord.hook');
const client = new Hook.Client('webhook-url');

let message = "Hello, I'm a webhook."

client.sendMessage(message);

Sending Embed

const Hook = require('discord.hook');
const client = new Hook.Client('webhook-url');

const Embed = new Hook.CreateEmbed()
    .setAuthor('Text', 'Icon URL')
    .setTitle('Text')
    .setURL('URL here')
    .setDescription('Write your description.')
    .addField('A Field', 'Not Inline')
    .addField('Another Field', 'Not Inline')
    .addBlankField(/* This is a blank field. */)
    .addField('This is another field.', 'But inline', true)
    .addField('This is another inline field', 'hmm', true)
    .addField('You can add 25 fields like this.', 'ok?', true)
    .setThumbnail('Thumbnail Image URL')
    .setImage('Image URL')
    .setFooter('This is footer text.', 'footer icon URL')
    .setTimestamp(/* This is a timestamp of this message */)
    .setColor(123456) // This is a color

client.sendEmbed(Embed.embed, username, avatar); // here we send embed

Sending Embed And Message

const Hook = require('discord.hook');
const client = new Hook.Client('webhook-url');

const message = "Hello, this is a webhook";

const Embed = new Hook.CreateEmbed()
    .setAuthor('Text', 'Icon URL')
    .setTitle('Text')
    .setURL('URL here')
    .setDescription('Write your description.')
    .addField('A Field', 'Not Inline')
    .addField('Another Field', 'Not Inline')
    .addBlankField(/* This is a blank field. */)
    .addField('This is another field.', 'But inline', true)
    .addField('This is another inline field', 'hmm', true)
    .addField('You can add 25 fields like this.', 'ok?', true)
    .setThumbnail('Thumbnail Image URL')
    .setImage('Image URL')
    .setFooter('This is footer text.', 'footer icon URL')
    .setTimestamp(/* This is a timestamp of this message */)
    .setColor(123456) // This is a color

client.sendMessageEmbed(message, Embed.embed, username, avatar); // here we send embed with message

Client Options

client.sendMessage(message, 'username to display while sending message', 'avatar URL to display while sending message');

client.sendMessageEmbed(message, embed.embed, 'username to display while sending message', 'avatar URL to display while sending message');

client.sendEmbed(embed.embed, 'username to display while sending message', 'avatar URL to display while sending message');

Links

Discord | GitHub

discord.hook's People

Contributors

twlite avatar

Watchers

James Cloos 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.