rtlcopymemory / Challonge-CSharp-API

C# API Library for Challonge.com
1 stars 0 forks source link

Setup #1

Open GaLzZy opened 4 years ago

GaLzZy commented 4 years ago

Hi, could you help me set this up cause it looks really good and I wanna use it for a Discord Bot i'm making :)

Thanks !

rtlcopymemory commented 4 years ago

Oh, hi I haven't really ever finished this since University and Work kinda got in the way (and I'm ngl, I got lazy) hence why it's not fully tested nor documented. So it's possible that something might not 100% work.

Anyways, the intended way to use this is to first create an instance of the API with:

private Api api = new Api();

then set your Challonge credentials with:

api.setCredentials(username, token);

Then use a dictionary to set the parameters for the POST request following the names from the Official API. For example as shown here: https://github.com/StackWolfed/Challonge-CSharp-API/blob/master/API%20test/UnitTest1.cs#L64

To make a query to the Tournaments endpoint to create a tournament you create a Dictionary:

Dictionary<string, string> param = new Dictionary<string, string>();

Set the two parameters (tournament[name] and tournament[url]) taken from here :

param.Add("tournament[name]", "TEST API");
param.Add("tournament[url]", url);

then you get the result by doing this:

Task<JObject> TaskQuery = Task.Run(() => Tournaments.Create(api, param));
TaskQuery.Wait();
JObject result = TaskQuery.Result;

I wanted to eventually simplify this but as I said I got lazy and overwhelmed with other stuff