Giter VIP home page Giter VIP logo

discord.sh's Introduction

Hi there, I'm Sheldon - aka fieu ๐Ÿ‘‹

I'm a web developer (PHP & Laravel)

  • ๐ŸŒฑ I'm trying to expand my knowledge of Go
  • ๐Ÿฅ… 2023 Goals: Contribute more to Open Source projects
  • โšก Fun fact: I love to skateboard!

Languages and Tools:

Go HTML5 CSS3 Sass JavaScript PHP Laravel React Node.js



Notable Projects:

  • discord.sh - Write-only command-line Discord webhook integration written in 100% Bash script ๐Ÿ˜Ž
  • disphord - PHP port of fieu/discord.sh
  • pcmd - Run multiple commands in parallel with clean stdout/stderr output
  • phust - Send RCON commands to your Rust game server via the command-line โ›

Shows a black logo in light color mode and a white one in dark color mode.

discord.sh's People

Contributors

chaoticweg avatar dayne avatar dependabot[bot] avatar dozn avatar fieu avatar keevan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord.sh's Issues

date: illegal option on FreeBSD

Hi,

I use discord.sh on FreeBSD, everything if fine except when --timestamp is called.

The FreeBSD date program does not understand the --iso-8601 argument and returns this to the console:

# date -u --iso-8601=seconds
date: illegal option -- -
usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]]
            [-I[date | hours | minutes | seconds]]
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]

Quick fix for FreeBSD's users

Get the line:

get_ts() { date -u --iso-8601=seconds; };

Replace with this:

get_ts() { date -u -Iseconds; };

Best regards,
al.

Sending a bash string as description results in invalid JSON error

So when I have a message like:
message="${user} is not following the rules as set in ${rules}"

and then sending it like:
discord.sh --webhook-url https://blabla.com/xyz --title "Hello world" --description "${message}"

I then get:

error! {
  "code": 50109,
  "message": "The request body contains invalid JSON."
}

in case embeds: timestamp not shown

not sure why, but this command does not show the timestamp:

./discord.sh \ --webhook-url="$WEBHOOK" \ --username "System Status" \ --description "Here are your system stats!" \ --field "Hostname;localhost;false" \ --field "CPU;95%" \ --field "Disk Usage;120/512GB" --timestamp

Need usage guidelines webpage

  • Add a gh-pages branch with usage information, etc
  • Set it as the website for this repo (should end up being https://chaoticweg.cc/discord.sh)

Create thread message

It is possible to create thread discussion ? Ex: I use your script to create a message of the day and post the message with a cron job. It is possible to create a thread message linked to this message of the day?

fatal: curl failed with code 3

Just tested your discord script and am getting an error code on curl.

This happens when using your example simple text.

Any suggestions?
Using your latest release.

Data Input factor on shell script

/opt/vc/bin/vcgencmd measure_temp >> /tmp/temp.log

tmp = /opt/vc/bin/vcgencmd measure_temp

./data/discord.sh-1.5/discord.sh --webhook-url="" --text tmp

Not able to send the temperature of the device -- tried tmp, "tmp", "$tmp" still not working please help

bash should be added as a dependency, for now

https://github.com/ChaoticWeg/discord.sh/blob/2f2c0f4c14b48474a6a360eb401c040016cfbedb/README.md?plain=1#L32-L36

I've tried running this on sh and there were a few bash specific things that stopped this from getting very far, namely

discord.sh: line 6: shopt: not found
discord.sh: line 7: shopt: not found
discord.sh: line 31: syntax error: bad substitution

There's probably many more that it hasn't reached yet but it might be easier to set the requirements to include bash.

curl runs even without username or text

When build_message bails out due to lack of username or text, send_message fails to recognize this and still attempts to run curl. This is likely caused by incorrect detection of the exit code in the command substitution used to capture the output of build_message.

Modify a webhook

Is it possible to add an option to modify/delete a Webhook by giving its id to an argument ?

Problems with --color

When trying to use --color with either hex or decimal I get the following error on. Is there a required argument when using --color?

My test argument
error! {
"embeds": [
"0"
]
}
attempted to send: {
"wait": true,
"content": "My test argument",
"avatar_url": "https://i.imgur.com/12jyR5Q.png",
"embeds": [
{
"": "",
"color": 16711682,
"timestamp": "2022-04-07T21:25:51+00:00",
"author": {
"": ""
},
"thumbnail": {},
"image": {
"": ""
},
"footer": {
"": ""
}
}
]
}

Any way for debugging?

Hello,

I am always recieving this error:
parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 6, column 25

and I would like to know how I can debug that or if there is a way to enable debug output

shopt: lastpipe: invalid shell option name

Getting the following error on macos

discord.sh-1.3/discord.sh: line 6: shopt: lastpipe: invalid shell option name

with an invocation something like this:

discord.sh-1.3/discord.sh --webhook-url $webhook --title "title text" --text "$tags cat $filename"

[Suggestion] Minified version

Make a version with single-line, minified code. This will allow you to make a function in your script instead of calling a separate script.

Unable to add extra JSON values when attaching file

cURL doesn't correctly package and send the JSON payload when attaching a file.

Input

./discord.sh --file foo.txt \
    --username "FileBot" \
    --text "Here's a file!"

Expected

  • Content-Type: multipart/form-data
  • Username: FileBot
  • Text: Here's a file!
  • Attached file: foo.txt

Actual

  • Content-Type: multipart/form-data
  • Attached file: foo.txt

The url-encoded JSON passed to cURL gets lost in transit somehow.

Include version number as comment in header

I think it would be a good idea to include the version number in the header in a comment.

A possible use-case would be that you have set up the script some time ago and now don't know which version it was or when it was done. This would then be helpful in case you want to update (which basically amounts to just downloading from the github releases but to know which version you had run is still important in case there are some breaking changes etc).

Another option might be to rename the release file to discord-X.Y.Z.sh.
Or introduce a --version CLI flag? (But the version can also be shown in the --help message.)

Unescaped control characters fire an error in jq

Control characters in the inclusive range U+0000 to U+001F are invalid JSON per section 7 of RFC 7159, and jq handles this by firing off a slightly difficult-to-debug error (in our use case). Because of this, passing any unescaped control characters including CR, LF, and tabs causes discord.sh to fail to send the message (specifically, Discord rejects the message with "cannot send an empty message" since jq bails out).

As of now, this will not be fixed. It will be up to the end user to escape desired control characters using sed and/or tr.

Reasons:

  • Escaping and/or removing control characters inside discord.sh requires us to add dependencies, specifically sed and/or tr. This breaks the goal of maximum portability.

Sources:

Workaround examples:

Do you have an example of a workaround you came up with? Comment it here.

text under the --image ?

Hello, would there be a way to put text below the image when we use the --image argument? Or even place the text of the --description argument below the image?

Problems to use discord.sh behind a proxy squid version 3.5

I cant send anything using this script behind a proxy squid with version superior than 3.1 (probably)
To solve, i have to remove, this header from curl comand:

-H 'Expect: application/json'

There are the problem:
curl -H 'Content-Type: application/json' -H 'Expect: application/json' -X POST https://discord.com/api/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -d '{ "wait": true, "content": "gohorse" }'
curl: (56) Received HTTP code 417 from proxy after CONNECT

There are the solution:
curl -H 'Content-Type: application/json' -X POST https://discord.com/api/webhooks/844929124527243264/VER83fwol8pWU9Yyp9z6CnDvzz09gOix1aWDvX5UhiHYcISKkYt__52RdTTgZV3TgJay -d '{ "wait": true, "content": "gohorse" }'
No error after that.

Seems had a explanation (or workarround) in squid doc, but it's no more supported by newer versions of squid:
http://www.squid-cache.org/Doc/config/ignore_expect_100/

I hope it's help someone.

thx

Custom text + content of file?

Hello, i am trying to send a custom text + the content of a file:

./discord.sh --webhook-url "$WEBHOOK_URL" --text "$(cat filename | jq -Rs . | cut -c 2- | rev | cut -c 2- | rev)" this sends the content of a file

and i want to send it like this:

./discord.sh --webhook-url "$WEBHOOK_URL" --text " customtxtHere ``` $(cat filename | jq -Rs . | cut -c 2- | rev | cut -c 2- | rev) (now this quote x3 `)"

i want to add the ` so it is in a nicer format when printing it in discord.

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.