You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -20,172 +20,172 @@ Read more about the `Execute C# Code` sub-action
20
20
21
21
1. Basic understanding of writing C# code
22
22
23
-
Since all of this *has* to be implemented in a C# code module, basic understanding of writing C# code and using common libraries is required. I will only give the most basic example, you will likely need to adapt it to your usecase.
23
+
Since all of this *has* to be implemented in a C# code module, basic understanding of writing C# code and using common libraries is required. I will only give the most basic example, you will likely need to adapt it to your use case.
24
24
25
25
2. Understanding on how to use C# in sub-actions
26
26
27
-
Be it a single use `Execute C# Code` block for a single instance of needing to send a request, or a more persistent C# module with different actions triggering different `Execute C# Method` sub-actions - you need to know how use this feature in your normal action flow.
27
+
Be it a single use `Execute C# Code` block for a single instance of needing to send a request, or a more persistent C# module with different actions triggering different `Execute C# Method` sub-actions - you need to know how use this feature in your normal action flow.
28
28
29
-
The following tutorial will only focus on the magic happening inside of the C# code module.
29
+
The following tutorial will only focus on the magic happening inside of the C# code module.
While people using the HTTPClient in a `using` statement or creating a new one within the executed function may be a common occurence, it is heavily discouraged to do so. [Read More](https://extensions.streamer.bot/t/httpclient-and-you/1369)
67
+
::
68
68
69
69
2. Setup the sending of your payload
70
70
71
-
Wearegoingtosenda `%userName%` and `%userId%` pair (fromcommontriggers) as `PUT` requesttoourfictionalloggingwebsite.
71
+
We are going to send a `%userName%` and `%userId%` pair (from common triggers) as `PUT` request to our fictional logging website.
72
72
73
-
```cs [SendPUTpayloadinExecutemethod]
74
-
publicboolExecute() {
75
-
// Get the arguments - or abort if it does not exist
Tousedifferentrequesttypes, simplyusethemethods `GetAsync()`, `PutAsync()`, `PostAsync()` or `DeleteAsync()`.
101
+
To use different request types, simply use the methods `GetAsync()`, `PutAsync()`, `PostAsync()` or `DeleteAsync()`.
102
102
103
103
3. The PATCH request
104
104
105
-
Specificallythebuilt-inhandlingfor the `PATCH` request type may not be available in the .net versions used by StreamerBot. In this case, you need a workaround.
105
+
Specifically the built-in handling for the `PATCH` request type may not be available in the .net versions used by StreamerBot. In this case, you need a workaround.
106
106
107
-
```cs [PATCH workaround]
108
-
// ...
107
+
```cs [PATCH workaround]
108
+
// ...
109
109
110
-
// Finally, send the request
111
-
var request = new HttpRequestMessage(newHttpMethod("PATCH"), "https://my-logging-server.com"){
Ifyouneedtoadditionallyincludespecificheaders-likesubmittinganauthorizationtokenfor the Twitch API or Discord API - make sure to clear and set the headers on each call you make.
121
+
If you need to additionally include specific headers - like submitting an authorization token for the Twitch API or Discord API - make sure to clear and set the headers on each call you make.
122
122
123
-
You can also send individual headers with each request itself, but that requires you to always use the `SendAsync` method and building your own `HttpRequestMessage`.
123
+
You can also send individual headers with each request itself, but that requires you to always use the `SendAsync` method and building your own `HttpRequestMessage`.
124
124
125
-
If your code only does a static request whose headers never change, resetting the headers is **not strictly necessary**. But it's good practice to not forget later when you need it.
125
+
If your code only does a static request whose headers never change, resetting the headers is **not strictly necessary**. But it's good practice to not forget later when you need it.
126
126
127
-
```cs [Header management]
128
-
public bool Execute() {
129
-
// Making a call to the Twitch API to get all currently live streams
130
-
stringtoken=CPH.TwitchOAuthToken;
131
-
stringclientId=CPH.TwitchClientId;
127
+
```cs [Header management]
128
+
publicboolExecute() {
129
+
// Making a call to the Twitch API to get all currently live streams
0 commit comments