From 8b766655ac5bcf37621988541360dfb7dc42c4a2 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 23 Jan 2017 03:17:50 +0100 Subject: [PATCH] %shardid% %shardcount% and %shardguilds% added to .ropl --- Discord.Net | 2 +- .../Commands/PlayingRotateCommands.cs | 21 +++++++++++++++++-- .../Resources/CommandStrings.Designer.cs | 4 ++-- src/NadekoBot/Resources/CommandStrings.resx | 5 +++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Discord.Net b/Discord.Net index 58766448..7c0cce6d 160000 --- a/Discord.Net +++ b/Discord.Net @@ -1 +1 @@ -Subproject commit 58766448d79ac9adec228f341f258aa262a3f278 +Subproject commit 7c0cce6d35b04d883cf5ec2d775b051e4bc8739f diff --git a/src/NadekoBot/Modules/Administration/Commands/PlayingRotateCommands.cs b/src/NadekoBot/Modules/Administration/Commands/PlayingRotateCommands.cs index b70c033b..3f70f908 100644 --- a/src/NadekoBot/Modules/Administration/Commands/PlayingRotateCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/PlayingRotateCommands.cs @@ -1,5 +1,6 @@ using Discord; using Discord.Commands; +using Discord.WebSocket; using NadekoBot.Attributes; using NadekoBot.Extensions; using NadekoBot.Services; @@ -50,7 +51,16 @@ namespace NadekoBot.Modules.Administration if (string.IsNullOrWhiteSpace(status)) continue; PlayingPlaceholders.ForEach(e => status = status.Replace(e.Key, e.Value())); - await NadekoBot.Client.SetGameAsync(status).ConfigureAwait(false); + var shards = NadekoBot.Client.Shards; + for (int i = 0; i < shards.Count; i++) + { + ShardSpecificPlaceholders.ForEach(e => status = status.Replace(e.Key, e.Value(shards.ElementAt(i)))); + try { await shards.ElementAt(i).SetGameAsync(status).ConfigureAwait(false); } + catch (Exception ex) + { + _log.Warn(ex); + } + } } } catch (Exception ex) @@ -82,7 +92,14 @@ namespace NadekoBot.Modules.Administration } }, { "%queued%", () => Music.Music.MusicPlayers.Sum(kvp => kvp.Value.Playlist.Count).ToString()}, - { "%time%", () => DateTime.Now.ToString("hh:mm " + TimeZoneInfo.Local.StandardName.GetInitials()) } + { "%time%", () => DateTime.Now.ToString("hh:mm " + TimeZoneInfo.Local.StandardName.GetInitials()) }, + { "%shardcount%", () => NadekoBot.Client.Shards.Count.ToString() }, + }; + + public static Dictionary> ShardSpecificPlaceholders { get; } = + new Dictionary> { + { "%shardid%", (client) => client.ShardId.ToString()}, + { "%shardguilds%", (client) => client.Guilds.Count.ToString()}, }; [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index f8097764..8a56ca9e 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -5118,7 +5118,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Spend a unit of currency to plant it in this channel. (If bot is restarted or crashes, the currency will be lost). + /// Looks up a localized string similar to Spend an amount of currency to plant it in this channel. Default is 1. (If bot is restarted or crashes, the currency will be lost). /// public static string plant_desc { get { @@ -5127,7 +5127,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}plant`. + /// Looks up a localized string similar to `{0}plant` or `{0}plant 5`. /// public static string plant_usage { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index c9fcc6a8..20d3b78e 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -1372,10 +1372,11 @@ plant - Spend a unit of currency to plant it in this channel. (If bot is restarted or crashes, the currency will be lost) + Spend an amount of currency to plant it in this channel. Default is 1. (If bot is restarted or crashes, the currency will be lost) - `{0}plant` + `{0}plant` or `{0}plant 5` + gencurrency gc