Raised This Month: $98 Target: $400
 24% 

[gRIP] Structure of Discord Webhook


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 06-07-2023 , 16:13   [gRIP] Structure of Discord Webhook
Reply With Quote #1

See how it should look https://gist.github.com/Birdie0/78ee...f412ab5f1cdcf9

Code:
#include <amxmodx> #include <grip> new const url[] = "https://webhook.site/" new GripJSONValue:object new GripJSONValue:embeds, GripJSONValue:embeds_array new GripJSONValue:author new GripJSONValue:thumbnail new GripJSONValue:image new GripJSONValue:footer new GripJSONValue:fields1, GripJSONValue:fields_array new GripJSONValue:fields2 new GripJSONValue:fields3 new GripJSONValue:fields4 new GripRequestOptions:options new GripBody:body public plugin_init(){     object       = grip_json_init_object()     embeds       = grip_json_init_object()     embeds_array = grip_json_init_array()     author       = grip_json_init_object()     thumbnail    = grip_json_init_object()     image        = grip_json_init_object()     footer       = grip_json_init_object()     fields_array = grip_json_init_array()     fields1      = grip_json_init_object()     fields2      = grip_json_init_object()     fields3      = grip_json_init_object()     fields4      = grip_json_init_object()     options = grip_create_default_options()     grip_options_add_header(options, "Content-Type", "application/json")     grip_options_add_header(options, "User-Agent", "big") } public plugin_end(){     grip_destroy_json_value(object)     grip_destroy_json_value(embeds)     grip_destroy_json_value(embeds_array)     grip_destroy_json_value(author)     grip_destroy_json_value(thumbnail)     grip_destroy_json_value(image)     grip_destroy_json_value(footer)     grip_destroy_json_value(fields_array)     grip_destroy_json_value(fields1)     grip_destroy_json_value(fields2)     grip_destroy_json_value(fields3)     grip_destroy_json_value(fields4) } public OnConfigsExecuted(){     grip_json_object_set_string(object, "username", "Webhook")     grip_json_object_set_string(object, "avatar_url", "https://picsum.photos/100")     grip_json_object_set_string(object, "content", "Text message. Up to 2000 characters.")     grip_json_object_set_value(object, "embeds", embeds_array)         grip_json_object_set_value(embeds, "author", author)             grip_json_object_set_string(author, "name", "Birdie")             grip_json_object_set_string(author, "url", "https://www.reddit.com/r/cats/")             grip_json_object_set_string(author, "icon_url", "https://i.imgur.com/R66g1Pe.jpg")                 grip_json_object_set_string(embeds, "title", "Title")         grip_json_object_set_string(embeds, "url", "https://google.com/")         grip_json_object_set_string(embeds, "description", "Text message. You can use Markdown here. *Italic* **bold** __underline__ ~~strikeout~~ [hyperlink](<a href="https://google.com" target="_blank" rel="nofollow noopener">https://google.com</a>) `code`")         grip_json_object_set_number(embeds, "color", 15258703)         grip_json_object_set_value(embeds, "thumbnail", thumbnail)             grip_json_object_set_string(thumbnail, "url", "https://picsum.photos/200")         grip_json_object_set_value(embeds, "image", image)             grip_json_object_set_string(image, "url", "https://picsum.photos/800")         grip_json_object_set_value(embeds, "footer", footer)             grip_json_object_set_string(footer, "text", "Woah! So cool! :smirk:")             grip_json_object_set_string(footer, "icon_url", "https://i.imgur.com/fKL31aD.jpg")                 grip_json_object_set_value(embeds, "fields", fields_array)             grip_json_array_append_value(fields_array, fields1)                 grip_json_object_set_string(fields1, "name", "Text")                 grip_json_object_set_string(fields1, "value", "More text")                 grip_json_object_set_bool(fields1, "inline", true)             grip_json_array_append_value(fields_array, fields2)                 grip_json_object_set_string(fields2, "name", "Even more text")                 grip_json_object_set_string(fields2, "value", "Yup")                 grip_json_object_set_bool(fields2, "inline", true)             grip_json_array_append_value(fields_array, fields3)                 grip_json_object_set_string(fields3, "name", "Use `^"inline^": true` parameter, if you want to display fields in the same line.")                 grip_json_object_set_string(fields3, "value", "okay...")             grip_json_array_append_value(fields_array, fields4)                 grip_json_object_set_string(fields4, "name", "Thanks!")                 grip_json_object_set_string(fields4, "value", "You're welcome :wink:")     grip_json_array_append_value(embeds_array, embeds)     body = grip_body_from_json(object, true)     grip_request(url, body, GripRequestTypePost, "Grip_Return", options)     grip_json_object_clear(object)     grip_json_object_clear(embeds)     grip_json_array_clear(embeds_array)     grip_json_object_clear(author)     grip_json_object_clear(thumbnail)     grip_json_object_clear(image)     grip_json_object_clear(footer)     grip_json_object_clear(fields1)     grip_json_object_clear(fields2)     grip_json_object_clear(fields3)     grip_json_object_clear(fields4)     grip_destroy_body(body) } public Grip_Return(){     new GripResponseState:responseState = grip_get_response_state()     if (responseState != GripResponseStateSuccessful){         log_amx("ERROR: gRIP Response State Failed: Result (%d)", responseState)     }     else {         new GripHTTPStatus:responseStatus = grip_get_response_status_code()         if (responseStatus != GripHTTPStatusOk){             log_amx("ERROR: gRIP Response Status Failed: Result (%d)", responseStatus)         }         else {             new data[256]             grip_get_response_body_string(data, charsmax(data))             if (data[0])                 server_print("Response:^n%s", data)         }     } }
__________________
bigdaddy424 is offline
IC3k1ng
Member
Join Date: Mar 2023
Location: Argentina
Old 07-01-2023 , 17:11   Re: [gRIP] Structure of Discord Webhook
Reply With Quote #2

Very good guide. I will star it.
__________________

Owner of:

PROP HUNT: 45.235.99.2:27053
IC3k1ng is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:36.


Powered by vBulletin®
Copyright ©2000 - 2023, vBulletin Solutions, Inc.
Theme made by Freecode