Raised This Month: $51 Target: $400
 12% 

[ANY] Discord Webhook API include


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sarrus
Member
Join Date: May 2020
Location: France
Old 09-27-2021 , 18:31   [ANY] Discord Webhook API include
Reply With Quote #1

Discord Webhook API



Description

An include featuring a well documented, complete wrapper of the Discord Webhook API written in SourcePawn using methodmaps and the RIPExt extension.

This include's aim is to make it easy for SourceMod developpers to send embeded WebHook messages to Discord servers, with minimal dependencies.

Contrary to other includes, discordWebhookAPI:
- Does not required a separate plugin to run alongside of it.
- Does not rely on SteamWorks or SM-Jansson.
- Is well documented.
- Provides a comprehensive documentation.
- Uses methodmaps in order to provide support for the Transitional Syntax.

Requirements

- RIPExt extension (included in the repo.)

How to use the include

1. Download the latest release and drop every file in your [code single]include/[/code] folder.
2. Add [code single]#include <discordWebhookAPI>[/code] to the top of your file.
3. Create your a basic WebHook message using the snippet below.
4. Get a Discord Webhook for your channel by following the tutorial here.
5. See a full working example here.

Code:
public Action SendDiscordWebhook(int client, int args)
{
	Webhook webhook = new Webhook("This is the content of the webhook.");
	webhook.Execute("https://discordapp.com/api/webhooks/6758765876/769876789009/", OnWebHookExecuted);
	return Plugin_Continue;
}

public void OnWebHookExecuted(HTTPResponse response, DataPack pack)
{
	if (response.Status == HTTPStatus_NoContent)
	{
		PrintToServer("Webhook sent successfully!");
	}
}
Example



SOURCE | LATEST RELEASE
__________________
Discord Coding Server | Steam Profile | Community Website | Github Profile

Taking paid requests (add me on Discord)

Last edited by Sarrus; 10-15-2021 at 14:20. Reason: Fix badges
Sarrus is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 09-27-2021 , 19:44   Re: [ANY] Discord Webhook API include
Reply With Quote #2

Thank you! This is both awesome and useful.
Maxximou5 is offline
Reply



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:24.


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