From 6591dd7c74be514b70a34ddfb19dfe59251189ce Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Wed, 5 Jul 2017 11:43:36 +0200 Subject: [PATCH] Bot will now show in the console when it joins or leaves a server --- src/NadekoBot/NadekoBot.cs | 14 ++++++++++++++ src/NadekoBot/Services/IBotCredentials.cs | 1 + src/NadekoBot/Services/Impl/BotCredentials.cs | 4 ++++ .../Services/Utility/PatreonRewardsService.cs | 2 +- src/NadekoBot/credentials_example.json | 1 + 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/NadekoBot.cs b/src/NadekoBot/NadekoBot.cs index 5560437f..b91b0004 100644 --- a/src/NadekoBot/NadekoBot.cs +++ b/src/NadekoBot/NadekoBot.cs @@ -317,9 +317,23 @@ namespace NadekoBot Client.Ready += SetClientReady; await clientReady.Task.ConfigureAwait(false); Client.Ready -= SetClientReady; + Client.JoinedGuild += Client_JoinedGuild; + Client.LeftGuild += Client_LeftGuild; _log.Info("Shard {0} logged in.", ShardId); } + private Task Client_LeftGuild(SocketGuild arg) + { + _log.Info("Left server: {0} [{1}]", arg?.Name, arg?.Id); + return Task.CompletedTask; + } + + private Task Client_JoinedGuild(SocketGuild arg) + { + _log.Info("Joined server: {0} [{1}]", arg?.Name, arg?.Id); + return Task.CompletedTask; + } + public async Task RunAsync(params string[] args) { if(ShardId == 0) diff --git a/src/NadekoBot/Services/IBotCredentials.cs b/src/NadekoBot/Services/IBotCredentials.cs index e0c271b5..9ed5ca1b 100644 --- a/src/NadekoBot/Services/IBotCredentials.cs +++ b/src/NadekoBot/Services/IBotCredentials.cs @@ -22,6 +22,7 @@ namespace NadekoBot.Services int TotalShards { get; } string ShardRunCommand { get; } string ShardRunArguments { get; } + string PatreonCampaignId { get; } } public class DBConfig diff --git a/src/NadekoBot/Services/Impl/BotCredentials.cs b/src/NadekoBot/Services/Impl/BotCredentials.cs index 3d47a207..3c69a3ec 100644 --- a/src/NadekoBot/Services/Impl/BotCredentials.cs +++ b/src/NadekoBot/Services/Impl/BotCredentials.cs @@ -36,6 +36,8 @@ namespace NadekoBot.Services.Impl public string ShardRunArguments { get; } public int ShardRunPort { get; } + public string PatreonCampaignId { get; } + public BotCredentials() { _log = LogManager.GetCurrentClassLogger(); @@ -64,6 +66,7 @@ namespace NadekoBot.Services.Impl MashapeKey = data[nameof(MashapeKey)]; OsuApiKey = data[nameof(OsuApiKey)]; PatreonAccessToken = data[nameof(PatreonAccessToken)]; + PatreonCampaignId = data[nameof(PatreonCampaignId)] ?? "334038"; ShardRunCommand = data[nameof(ShardRunCommand)]; ShardRunArguments = data[nameof(ShardRunArguments)]; if (string.IsNullOrWhiteSpace(ShardRunCommand)) @@ -121,6 +124,7 @@ namespace NadekoBot.Services.Impl public DBConfig Db { get; set; } = new DBConfig("sqlite", "Filename=./data/NadekoBot.db"); public int TotalShards { get; set; } = 1; public string PatreonAccessToken { get; set; } = ""; + public string PatreonCampaignId { get; set; } = "334038"; public string ShardRunCommand { get; set; } = ""; public string ShardRunArguments { get; set; } = ""; diff --git a/src/NadekoBot/Services/Utility/PatreonRewardsService.cs b/src/NadekoBot/Services/Utility/PatreonRewardsService.cs index 3eef3d72..7c08f747 100644 --- a/src/NadekoBot/Services/Utility/PatreonRewardsService.cs +++ b/src/NadekoBot/Services/Utility/PatreonRewardsService.cs @@ -64,7 +64,7 @@ namespace NadekoBot.Services.Utility { Links = new PatreonDataLinks() { - next = "https://api.patreon.com/oauth2/api/campaigns/334038/pledges" + next = $"https://api.patreon.com/oauth2/api/campaigns/{_creds.PatreonCampaignId}/pledges" } }; do diff --git a/src/NadekoBot/credentials_example.json b/src/NadekoBot/credentials_example.json index 8f977d87..9745558d 100644 --- a/src/NadekoBot/credentials_example.json +++ b/src/NadekoBot/credentials_example.json @@ -16,6 +16,7 @@ }, "TotalShards": 1, "PatreonAccessToken": "", + "PatreonCampaignId": "334038", "ShardRunCommand": "", "ShardRunArguments": "", "ShardRunPort": null