as you can see by the pictures i want to know how hard it is to make a github webhook bot like there one as the one with green you can add a description etc and it’s all custom and it’s a actual discord bot, however my one is obviously just a standard webhook, if i could have any help and increase my knowledge on this that’d be great, thank you!
#Github Commit Embed bot
726 messages · Page 1 of 1 (latest)
on the github i want to be able to change the embed to the left as i can have a description + custom name + a different hex color on the left and it stands out more
but still putting my commits out as usual
any helps appreciated
in the Webhooks page of settings in your repo, you can specify a webhook url
github sends a POST request to the specified url
which you can then format however you want
@cobalt beacon Hey, I got interested in this and thought I would give it a go, I think I managed to do it. Have you got anywhere?
could you send me a picture of what yours looks like please?
Are you using express?
no
what are you using then
Did you not get anything done on it lol
im ngl i gave up tryna find stuff as im very new to js and this is basically the only thing i need done with it tbh
i mainly use Lua
Fair lol, I'm in a good mood so I can guide you if you want
thanks :), also could i have a look to see what yours is like ?
are you using vs code? it'll be in the terminal
yeah
this may get a bit difficult if you couldn't do that part lol
show
if you get any errors just show them lol
alright lemme make a new file
you're also probably gonna wanna install https://ngrok.com/download
To install run: npm install discord.js
• Documentation: learn more
• Guide: learn more
no no
oh
did you host your github pushs with through developer portal?
yah
and then come to this part
and download the exe file
nvm is node version manager
it's great for installing node
I have my own vps for that
open up cmd
ya
alot of stuff came up
already done
cool
yeah
now just make a new folder and drop that into vs code
drag what into vsc?
it returned 9.6.7
okay
const express = require("express");
const app = express();
app.use(express.json());
app.post('/github', async (req, res) => {
console.log('emitted!');
console.log(req.body);
});
Paste that
in index.js
make a file called that ofc lmao
and make sure this is downloaded
it's installed?
this is in index.js
lol
at the bottom use
app.listen(80, () => console.log('listening at port 80'))
yh
ok
in terminal yeah?
yh
do node index.js
yh
drag index.js out of help
you can then delete that folder
you should have opened it like inside the main folder
will look like that then
what is that from though?
what is what from
oh they're mine
I use them ofr other stuff lol
yeah
make a new folder called like
my project
drag and drop index.js into that folder
new window of vs code, close the other one
in any specific folder
then drag and drop that folder
it doesn't matter where it is just make sure index.js is in a foldeer
then drag then folder into vs code
but a new window
show me the left hand side again
may i have installed something wrong?
that makes no sense
this works for me just fine
make a new folder called project again
a new empty folder
yeah
yeah
why do you have that at the top
const express = require("express");
const app = express();
app.use(express.json());
app.post('/github', async (req, res) => {
console.log('emitted!');
console.log(req.body);
});
app.listen(80, () => console.log('listening'))
?
whats that
what did you do
lemme redo this rq
there?
idk what its on about
maybe i try a different folder name?
then npm i express lol
it doesnt let me type
ctrl c lol
hmnm
Yh hold on
ok
Yh try
Did you not install it
haha
do i really need all this just for this bot?
if so i would of never been able to do it
you'll use ngrok to get a https link for your post requests
ohhh
so once this works
i can drag it onto my vps
as that will be where it will be
for it all
you could have said it would've made this easier
no
windows
its a fivem server
set what up
nvm
how does your github bot look btw
I haven't sorted it out fully yet
does it have description and stuff?
have you tried it out
It's easy now
liike in discord
I've got what I need
to see how it looks
I can just make it how I want
well most of it is just a basic webhook
the bottom part is just the description
and then its got a footer
and obviously the color on left
so what do i do from now
idk why ngrok refuses to install
OH
I did see lol
Just you got that part working but I can’t get the rest
I don’t think I’d be able to help much more
what actaully am i missing?
can i not just use discord instead?
jesus christ
I got it working
but it's not good code
you're gonna wanna
npm i ngrok
in vs code
const express = require("express");
const app = express();
const ngrok = require('ngrok');
let url;
(async function() {
url = await ngrok.connect(80);
console.log(url)
})();
app.use(express.json());
app.post('/github', async (req, res) => {
res.send(200)
console.log('emitted!');
console.log(req.body);
});
app.post('/', () => {
console.log('post')
})
app.get('/', () => {
console.log('gi')
})
app.listen(80, () => console.log('listening on port 80'))
This is the new code
so this instead of whats in index.js?
yh
node index.js
you copy that link
got to github
repository settings
webhooks
add the webhook
but put /github at the end
then update
you 100% copied this?
yeah
no idea then
heres what it is
const express = require("express");
const app = express();
const ngrok = require('ngrok');
let url;
(async function() {
url = await ngrok.connect(80);
console.log(url)
})();
app.use(express.json());
app.post('/github', async (req, res) => {
res.send(200)
console.log('emitted!');
console.log(req.body);
});
app.post('/', () => {
console.log('post')
})
app.get('/', () => {
console.log('gi')
})
app.listen(80, () => console.log('listening on port 80'))```
will this work for sending to discord
?
imma head to sleep
if you get any further
please let me know as ive been looking to maek this for a few days now
thanks
did you manage to get any further?
Yes, I managed to get a webhook to send data. But for you, I don’t know how to integrate the ngrok link with the express server
yeah cause for me i need it to send it to a discord channel
See if yoy can Google/YouTube how to ngrok and express together
I can’t really help you further as I don’t have the knowledge on that part
Something like that yh
Would be easier if yoy had your own website or something but I have no idea how to fully set that stuff up
why? is ngrok not really too good for discord or something?
Well without an account and probably a subscription it’s gonna end in 2 hours as each session is 2 hours long
im asking a person who done it
and he said wtf is ngrok
so there must be some other way to do without ngrok
he linked me this https://github.com/ipz1337/github-webhook/blob/main/server.js
however im not going to sit here and say i know how to do that though
as i did try this and didnt really get far to be honest
The issue I have is the link, the webhook url yoy give to github to send the post request
As I said, I just use my webhook
Website*
yeah
yeah that nice
i just need one like that of course
then i can sort out the embed
like what i want is basically just a basic github commit
just has the big description box underneath
by the wya would that github webhook bot do the whole channel as
every repository he has in that channel which is around 8 has that bot
or would he of manually added all the webhooks
@sullen idol you got any ideas?
huh
ngrok has a "confirmation page"
when github tries sending to ththje page you specified, it goes to the confirmation page instead, so you dont get the request
i need it to go discord
what
you don’t receive what GitHub sends because it goes to the ngrok confirmation page
e
that
is waht o want it to look like
i need it in discord
what stuff?
this
Run it, get the url pop that into github
put at the end of the url /github
run a test, see if the console.log emits
e
let me find where i stored this
And?
so what did i need to do furthur from here?
should i try this with a tester repository
run it
Sounds like an issue with ur system
upload it there yh
alright gimme a moment
make a new file dont just copy and paste?
or will copy and paste be fine
What?
make a new index.js and copy the writing in
or
copy and paste from my pc into my vps
yeah ikik
alright
now its saying listening
from node .
so now do node index.js
or do i just need to do one of them
it should also log a url
yes it has
copy it
done
paste that url but put /github at the end, should be something like
... .io/github
application json yeah?
json
send me everything yeah
yh
done added
now what do i do from here
Go to here, webhooks -> click that webhook -> recent deliveries
Or, check ur console.log
it should have logged something
if not
go here, click the first one then it should say redeliver
ur console.log?
it is
where then
did that url change?
you need to keep it running
this is the issue you'll have with ngrok
idk how else to do it
Use pm2, or leave a cmd tab open
did you redeliver, change /github at the end?
who?
did you redeliver?
yes
dd anything log in the terminal
yes
so if that works how isnt the github webhook working
i asked the guy who had it
and he said this to me
app.get() handles get requests
used js listened to a port and on github webhook post the payload to the port then got the info put in embed and put it in the channel
app.post() handles post
yes but you need a url
thats how he told me to do this
it's not as easy as just
"put port"!
"put stuff"
"done"!!
thats what i was thinking
yeah
open cmd as admin
done
then cd into that folder
type dir
dir means directory
yeah
cd ./Desktop
A
- File paths explained in detail: learn more
.refers to the current directory..refers to the parent directory- Node path module: learn more
cd ./Users/Barns
cd ./Desktop
yah
cd ./new project
node index.js
copy new url, paste into github, add /github at the end
It also works just fine for me
you would have got a tonne of info
yep
const event = req.headers['x-github-event']; that's the event
you can read what each event does, and what it sends
inside of the app.post
however I think ngrok only works for 2hours on the free version
I'm not too sure
like that?
btw the person who made his
said this
i used js and github
barnsy — Today at 19:39
so nothing else at all?
Bentheborg — Today at 19:39
nope
app.post('/github', async (req, res) => {
res.send(200)
const event = req.headers['x-github-event'];
if(event == 'commit') {
web.send(stuff)
}
})
web you can use djs if you want
app.post('/github', async (req, res) => {
res.send(200)
console.log('emitted!');
console.log(req.body);
});
app.post('/', () => {
console.log('post')
})```
which one does it go in sorry?
no
got it
event is also called "push" for a new commit
yeah
/gtihub one yes
ya
that handles everything coming from the github
hi
const web = new WebhookClient({
url: <that url>
})
web.send()
hello
leaking dms now not good
wys
oh yeah because i dont understand how youve done it without all of this stuff tbh
whats ur issue with it
again, as I told you before, I'm using my website. I don't really know other ways to do it
I know this is a way
well im trying to get the github webhooks like how you and a few others have it
and @burnt vale is helping
few others 😱
however gwapes has a website where his goes to
arma, cmg
im guessing you helped cnr with his tho
not sure 
if you aren't gonna help then why are you even here?
sheesh sorry
pretty sure tho he asked me for help first
so 👍🏿
Well off you pop then
its alr ill take it to dms and get it sorted for him
Good luck
dont need it im the one who has done it
Good for you ig?