soooo imma tryin to do something like when someone gets a reward on patreon it’ll send it back to the player on garry’s mod server and by research I found out something called “webhooks” so I searched about it… failing… So I am asking how/where I can use webhooks. I know they can be used on discord but I am not sure about patreon.

You could create a timer, that checks which player has gotten a reward. I’m not sure how patreon works
because i don’t use it, but you can use their API and https://wiki.garrysmod.com/page/http/Post

Oh thank you… (https://wiki.garrysmod.com/page/http/Post) I am sure that I am going to figure out what to do next :stuck_out_tongue:

[editline]17th August 2017[/editline]

nope I made something wrong lol

http.Post( "https://discordapp.com/api/webhooks/347802373512757248/BnbdZC8wPBBozsWmCfVAVbAcen5rQwhtbETergwZY5vsWHAYoZ3PM2-lcZjxFZ6emHl9", {
    "name" = "lol",
    "channel_id" = "336896150500278272",
	"token" = "BnbdZC8wPBBozsWmCfVAVbAcen5rQwhtbETergwZY5vsWHAYoZ3PM2-lcZjxFZ6emHl9",
    "avatar" = null,
    "id" = "347802373512757248",
    "user" = {
        "username" = "test",
        "discriminator" = "7479",
        "id" = "190320984123768832",
        "avatar" = "b004ec1740a63ca06ae2e14c5cee11f3"
	function( result )
	if result then print( "Done!" ) end
end, function( failed )
	print( failed )
end )

[ERROR] lua/test.lua:2: '}' expected (to close '{' at line 1) near '='
  1. unknown - lua/test.lua:0

I know it’s an formatting error but idk where

ya can take da security stuff if ya want it’s an test server

btw it’s on discord not patreon checking if it’s working

Table keys shouldn’t have quotes. If you need to use quotes (because the key contains some character not allowed in an identifier), surround the key with square brackets.


“null” is not a thing in lua. The value for nothingness is “nil”. Note that both of these will actually remove the key from the table, and I’m not sure if that will cause any kind of problem.

I don’t think the last post makes it very clear - if you don’t want to use square brackets and the key is a string then you can do this sort of thing:

local tbl = {
    something = "value"

[editline]18th August 2017[/editline]

So your code would be:

http.Post( "https://discordapp.com/api/webhooks/347802373512757248/BnbdZC8wPBBozsWmCfVAVbAcen5rQwhtbETergwZY5vsWHAYoZ3PM2-lcZjxFZ6emHl9", {
	name = "lol",
	channel_id = "336896150500278272",
	token = "BnbdZC8wPBBozsWmCfVAVbAcen5rQwhtbETergwZY5vsWHAYoZ3PM2-lcZjxFZ6emHl9",
	id = "347802373512757248",
	user = {
		username = "test",
		discriminator = "7479",
		id = "190320984123768832",
		avatar = "b004ec1740a63ca06ae2e14c5cee11f3"
}, function( result )
	if result then print( "Done!" ) end
end, function( failed )
	print( failed )
end )

^ Untested though

yep works now. Prints Done! but it doesn’t print anything on discord :confused: like “Webhooks are a low-effort way to post messages to channels in Discord…”

Why would the print command do anything in Discord? It was made for Garry’s Mod before Discord even existed.
You have to use another sort of request to post something to Discord.

EDIT: For the person who rated me dumb, I thought he wanted the “Done!” message that he printed to appear in Discord as well, and I was trying to say you couldn’t use the print function alone to make that happen because that doesn’t make sense.

Patreon for gmod servers…
That’s a new one

This is all you should need for your bot to work:

	{ content = "Done!" }

[editline]19th August 2017[/editline]

See other parameters here.

[editline]19th August 2017[/editline]

Sorry, I think I sent some stuff to your webhook by accident when I was playing around

Whats wrong about grabbing lots of shitty workshop add-ons into your server, ask someone to code a system for you and then ask money for it to players

Oh wait

Wait, this is for Patreon? You could’ve told me that before I tried to do it for Discord. Why on earth are you using Discord’s API to do something with patreon?

As I said I was doing this to get used to webhooks and btw I was just looking through discord and saw this message and saw the same nick on the “What are you working on” thread and I was about to pm you. Then I went to this thread and saw it. oh and btw on discord there are multiple webhooks… functions? like delete webhook, get webhook and on the discord api it was saying to use “GET/webhooks/{webhook.id}” and I was a little confused should I put this in the url?

Sorry about my stupid misunderstanding

If it’s for Patreon though then I don’t see the point in doing anything related to Discord. I’m sure they have a different API.
Also, for the multiple Webhook functions on Discord, the reason for them is simple:

GET is to get the full URL of the Webhook for when you want to send a POST request (I think).
The delete one is just if you want to remove the Webhook.
Then there’s a few others that do the same kind of things.

None of these have anything to do with the actual message being sent, just the Webhook itself.
As I said, there’s probably not much point researching these if you want to use Patreon.

[editline]19th August 2017[/editline]

If you really want to know the GET url thing, instead of

You’re meant to do launch a

http.Fetch (GET) request with

As the URL, but with

Replaced with the actual Webhook id).

However, this requires you know the Webhook ID already, so it’s pretty pointless.