Giter Site home page Giter Site logo

10mohi6 / discord-webhook-python Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 0.0 1.78 MB

discordwebhook is a python library for discord webhook with discord rest api on Python 3.6 and above.

License: MIT License

Python 99.67% Dockerfile 0.33%
discord webhook api python

discord-webhook-python's Introduction

discordwebhook

PyPI License: MIT codecov Build Status PyPI - Python Version Downloads

discordwebhook is a python library for discord webhook with discord rest api on Python 3.6 and above.

Installation

$ pip install discordwebhook

Usage

basic

from discordwebhook import Discord

discord = Discord(url="<your webhook url>")
discord.post(content="Hello, world.")

basic.png

basic, username and avatar_url

from discordwebhook import Discord

discord = Discord(url="<your webhook url>")
discord.post(
    content="Hello, world.",
    username="10mohi6",
    avatar_url="https://avatars2.githubusercontent.com/u/38859131?s=460&amp;v=4"
)

basic-username.png

basic embed

from discordwebhook import Discord

discord = Discord(url="<your webhook url>")
discord.post(
    embeds=[{"title": "Embed Title", "description": "Embed description"}],
)

basic-embed.png

advanced embed

from discordwebhook import Discord

discord = Discord(url="<your webhook url>")
discord.post(
    embeds=[
        {
            "author": {
                "name": "Embed Name",
                "url": "https://github.com/10mohi6/discord-webhook-python",
                "icon_url": "https://picsum.photos/24/24",
            },
            "title": "Embed Title",
            "description": "Embed description",
            "fields": [
                {"name": "Field Name 1", "value": "Value 1", "inline": True},
                {"name": "Field Name 2", "value": "Value 2", "inline": True},
                {"name": "Field Name 3", "value": "Field Value 3"},
            ],
            "thumbnail": {"url": "https://picsum.photos/80/60"},
            "image": {"url": "https://picsum.photos/400/300"},
            "footer": {
                "text": "Embed Footer",
                "icon_url": "https://picsum.photos/20/20",
            },
        }
    ],
)

advanced-embed.png

send file

from discordwebhook import Discord

discord = Discord(url="<your webhook url>")
discord.post(
    file={
        "file1": open("tests/file1.jpg", "rb"),
        "file2": open("tests/file2.jpg", "rb"),
    },
)

send-file.png

Getting started

For help getting started with discord webhook, view our online documentation.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

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.