diff --git a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Command/Result.cs b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Command/Result.cs
index ccbebee..9e775c8 100644
--- a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Command/Result.cs
+++ b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Command/Result.cs
@@ -20,6 +20,14 @@ namespace LaDOSE.DiscordBot.Command
await ctx.RespondAsync("Resultat");
}
+
+ [Command("last")]
+ public async Task LastAsync(CommandContext ctx)
+ {
+ var tournament = await dep.ChallongeService.GetLastTournament();
+ await ctx.RespondAsync($"Dernier tournois: {tournament}");
+
+ }
}
}
}
\ No newline at end of file
diff --git a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Command/Twitch.cs b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Command/Twitch.cs
index 15ec6f2..fa502aa 100644
--- a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Command/Twitch.cs
+++ b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Command/Twitch.cs
@@ -4,7 +4,7 @@ using DSharpPlus.CommandsNext.Attributes;
namespace LaDOSE.DiscordBot.Command
{
- public partial class Result
+ public class Result
{
internal class Twitch
diff --git a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Dependencies.cs b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Dependencies.cs
index 3b55465..20cd3ca 100644
--- a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Dependencies.cs
+++ b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Dependencies.cs
@@ -1,5 +1,6 @@
using System.Threading;
using DSharpPlus.Interactivity;
+using LaDOSE.DiscordBot.Service;
namespace LaDOSE.DiscordBot
{
@@ -7,5 +8,6 @@ namespace LaDOSE.DiscordBot
{
internal InteractivityModule Interactivity { get; set; }
internal CancellationTokenSource Cts { get; set; }
+ public ChallongeService ChallongeService { get; set; }
}
}
\ No newline at end of file
diff --git a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot.csproj b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot.csproj
index 21ef2a8..bcf31fd 100644
--- a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot.csproj
+++ b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot.csproj
@@ -13,6 +13,12 @@
+
+
+ ..\..\Library\ChallongeCSharpDriver.dll
+
+
+
PreserveNewest
diff --git a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Program.cs b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Program.cs
index 1ce8522..d63d37f 100644
--- a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Program.cs
+++ b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Program.cs
@@ -8,6 +8,7 @@ using DSharpPlus.Interactivity;
using DSharpPlus.CommandsNext;
using DSharpPlus.EventArgs;
using LaDOSE.DiscordBot.Command;
+using LaDOSE.DiscordBot.Service;
using Microsoft.Extensions.Configuration;
namespace LaDOSE.DiscordBot
@@ -15,7 +16,6 @@ namespace LaDOSE.DiscordBot
class Program
{
static DiscordClient discord;
- static InteractivityModule _interactivity;
static void Main(string[] args)
{
@@ -29,6 +29,7 @@ namespace LaDOSE.DiscordBot
.AddJsonFile("settings.json", optional: true, reloadOnChange: true).Build();
var discordToken = builder["Discord:Token"].ToString();
+ var challongeToken = builder["Challonge:Token"].ToString();
Console.WriteLine($"LaDOSE.Net Discord Bot");
@@ -40,22 +41,18 @@ namespace LaDOSE.DiscordBot
TokenType = TokenType.Bot
});
- var _interactivity = discord.UseInteractivity(new InteractivityConfiguration()
- {
- PaginationBehaviour = TimeoutBehaviour.Delete,
- PaginationTimeout = TimeSpan.FromSeconds(30),
- Timeout = TimeSpan.FromSeconds(30)
- });
- var _cts = new CancellationTokenSource();
+ var challongeService = new ChallongeService(challongeToken);
+ var cts = new CancellationTokenSource();
DependencyCollection dep = null;
using (var d = new DependencyCollectionBuilder())
{
d.AddInstance(new Dependencies()
{
- Interactivity = _interactivity,
- Cts = _cts
+
+ Cts = cts,
+ ChallongeService = challongeService
});
dep = d.Build();
}
@@ -89,7 +86,7 @@ namespace LaDOSE.DiscordBot
await e.Guild.GetDefaultChannel().SendMessageAsync($"Bonjour {e.Member.DisplayName}!");
};
await discord.ConnectAsync();
- while (!_cts.IsCancellationRequested)
+ while (!cts.IsCancellationRequested)
{
await Task.Delay(200);
}
diff --git a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Service/ChallongeService.cs b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Service/ChallongeService.cs
new file mode 100644
index 0000000..867fd22
--- /dev/null
+++ b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/Service/ChallongeService.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using ChallongeCSharpDriver;
+using ChallongeCSharpDriver.Caller;
+using ChallongeCSharpDriver.Core.Queries;
+using ChallongeCSharpDriver.Core.Results;
+using ChallongeCSharpDriver.Main;
+using ChallongeCSharpDriver.Main.Objects;
+
+namespace LaDOSE.DiscordBot.Service
+{
+ public class ChallongeService
+ {
+ public string ApiKey { get; set; }
+
+
+ public ChallongeService(string apiKey)
+ {
+ this.ApiKey = apiKey;
+
+ }
+
+ public async Task GetLastTournament()
+ {
+ ChallongeConfig config = new ChallongeConfig(this.ApiKey);
+ var caller = new ChallongeHTTPClientAPICaller(config);
+ var tournaments = new Tournaments(caller);
+ List tournamentResultList = await new TournamentsQuery()
+ {
+ state = TournamentState.Ended
+ }
+ .call(caller);
+ List tournamentList = new List();
+ foreach (TournamentResult result in tournamentResultList)
+ {
+ tournamentList.Add(new TournamentObject(result, caller));
+ }
+
+ var startedTournament = tournamentList.Last();
+
+ return startedTournament.ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/settings.json b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/settings.json
index 126d385..2e4eb56 100644
--- a/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/settings.json
+++ b/LaDOSE.DiscordBot/LaDOSE.DiscordBot/LaDOSE.DiscordBot/settings.json
@@ -1,5 +1,8 @@
{
"Discord": {
- "Token" : "APITOKEN Here"
- }
+ "Token": "DISCORD TOKEN"
+ },
+ "Challonge": {
+ "Token": "CHALLONGE API TOKEN"
+ }
}
\ No newline at end of file
diff --git a/LaDOSE.DiscordBot/Library/ChallongeCSharpDriver.dll b/LaDOSE.DiscordBot/Library/ChallongeCSharpDriver.dll
new file mode 100644
index 0000000..ef33388
Binary files /dev/null and b/LaDOSE.DiscordBot/Library/ChallongeCSharpDriver.dll differ