I am very new to html, so i am making somethink very simple, a project that will post a message inside my discord server however i get an error by the endpoint ““message”: “Cannot send an empty message”,
“code”: 50006”.
here is my code:
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333 ;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Change the link color to #111 (black) on hover */
li a:hover {
background-color: #ffffff;
color: black
}
div {
background-color: gray;
}
body {
background-image: url("Backgrounds/3d-cube-background-4k-yo-1210x642.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.btn {
border: none;
border-style = none;
background-color: #00ff95;
padding: 5px 28px;
font-size: 16px;
cursor: pointer;
display: inline-block;
border-radius: 8px;
}
.bxstyle {
border: none;
border-style = none;
background-color: #ffffff;
padding: 5px 28px;
font-size: 16px;
cursor: pointer;
display: inline-block;
border-radius: 10px;
font-color: white;
}
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
</ul>
<title>Test Webiste File</title>
<form action="Discord webhook here" method="post">
<div><font color = "#ffffff"><label for="Box"><font size = "50">Message:</font></label></font>
<input type="text" id="Box" name="Box" class = "bxstyle">
<button class="btn 1"><font color = white>Submit</font></button><br><br>
</form>
</body>
</html>
Techy
November 6, 2020, 10:16pm
2
Hey there @dionsyran2 welcome to the Glitch community! Just to clarify are you trying to get help with making an app to send messages via a webhook, or are you trying to get help designing the site?
1 Like
@Techy want to send the message via the webhook, but the api returns me with this error: {“message”: “Cannot send an empty message”, “code”: 50006}
Techy
November 6, 2020, 10:19pm
4
Can you show us the code? Because what you sent seems like CSS.
1 Like
Also, can you wrap your code in a code block?
They look like this
```
They look like this
```
here is the part of the code that sends the message:
Message:
Submit
For the love of pogging can people wrap their code?
And dude, show us your JavaScript code, so we can help ya.
Techy
November 6, 2020, 10:23pm
8
Can you send the code that’s sending the API request? Not the text you want to send.
1 Like
<form action="Discord webhook here" method="post">
<div><font color = "#ffffff"><label for="Box"><font size = "50">Message:</font></label></font>
<input type="text" id="Box" name="Box" class = "bxstyle">
<button class="btn 1"><font color = white>Submit</font></button><br><br>
</form>
Techy
November 6, 2020, 10:24pm
10
Can you share the entire code so we can help you with debugging it? It would be helpful if you could share the code that sends the API request.
Not everyone knows markdown/have not been a forum so they may not know.
Just saying @aboutdavid .
And @dionsyran2 you need to show us your JavaScript code?
Y’know, the backend?
the code is in html, i haven’t used javascript, should i?
Techy
November 6, 2020, 10:29pm
14
Well, you need code to send the API request to Discord. So you can choose what language you want to use, for example JavaScript, Python.
1 Like
ok here is the entire code:
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333 ;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Change the link color to #111 (black) on hover */
li a:hover {
background-color: #ffffff;
color: black
}
div {
background-color: gray;
}
body {
background-image: url("Backgrounds/3d-cube-background-4k-yo-1210x642.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
.btn {
border: none;
border-style = none;
background-color: #00ff95;
padding: 5px 28px;
font-size: 16px;
cursor: pointer;
display: inline-block;
border-radius: 8px;
}
.bxstyle {
border: none;
border-style = none;
background-color: #ffffff;
padding: 5px 28px;
font-size: 16px;
cursor: pointer;
display: inline-block;
border-radius: 10px;
font-color: white;
}
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
</ul>
<title>Test Webiste File</title>
<form action="" method="post" {content="Test"}>
<div><font color = "#ffffff"><label for="Box"><font size = "50">Message:</font></label></font>
<input type="text" id="Box" name="Box" class = "bxstyle">
<button class="btn 1"><font color = white>Submit</font></button><br><br>
</form>
</body>
</html>
Techy
November 6, 2020, 10:31pm
16
As I mentioned before, your sending the code that’s making/styling the web page. But we need the code that’s sending the API request so we can help you out.
2 Likes
isn’t this sending the request?
Not to Discord, no. I see that form is a ‘post’ form meaning you must have backend code that handles that post data when it comes into the server. Can you show us that? It should also be the one that actually sends the message to the discord API (e.g. with Discord.js)
I have some code that I have found which comes from https://lew.la/webhook/
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<form class='webhook-form'>
<label>
Webhook URL
<input type="text" placeholder="Webhook URL" class="webhook-input" id="webhook-url-input">
</label>
<label>
Username Override (optional)
<input type="text" placeholder="Username Override" class="webhook-input" id="webhook-username-input">
</label>
<label>
Avatar Override (optional)
<input type="text" placeholder="Avatar Override" class="webhook-input" id="webhook-avatar-input">
</label>
<label>
Message to Send
<input type="text" placeholder="Message" class="webhook-input" id="webhook-message-input">
</label>
<div class='new-paste-bottom'>
<input class='send-button' type="submit" value="Send Message">
</div>
</form>
<script>
$(".webhook-form").on('submit', function(){
send_webhook();
return false;
});
function show_success_message() {
$("#success-message").html("Message sent!");
$("#success-message").show();
$("#success-message").delay(5000).fadeOut(500);
}
function show_error_message(data) {
if(data==undefined)
data="Please enter a Discord Webhook URL";
$("#error-message").html("Error: " + data);
$("#error-message").show();
$("#error-message").delay(8000).fadeOut(500);
}
function send_webhook() {
if($("#webhook-url-input").val() == "") {
show_error_message("Please enter a Discord Webhook URL");
return
}
$.ajax({
url: $("#webhook-url-input").val(),
method: 'POST',
data: JSON.stringify({
content: $("#webhook-message-input").val(),
username: $("#webhook-username-input").val(),
avatar_url: $("#webhook-avatar-input").val()
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
statusCode: {
204: function(xhr) {
show_success_message();
},
400: function(data, xhr) {
console.log(data["responseText"]["avatar_url"]);
if (data["responseText"].length <= 100) {
show_error_message(data["responseText"]);
}
else {
show_error_message("Error sending webhook message.")
}
}
}
});
}
</script>
HTML does not have the power to send a message. It won’t work. You’ll have to read up on the Discord.js Docs using Node.js at discord.js.org . It’s really easy to use, from what I saw. You should be able to pick it up immediately, as it’s one of the best and easiest to use with Node.js
Or, do you not know JavaScript?