.shardid guildid added, .ropl fixed

This commit is contained in:
Kwoth 2017-02-05 06:36:07 +01:00
parent 58f23ff40b
commit 1e5b7df47f
3 changed files with 21 additions and 8 deletions

@ -1 +1 @@
Subproject commit 0fd1e70a22612ff9fa697dace96f22780080b01f Subproject commit 9ce5c4757efc6cb6bb8959e851abcdcbe03217be

View File

@ -25,6 +25,11 @@ namespace NadekoBot.Modules.Administration
public static bool RotatingStatuses { get; private set; } = false; public static bool RotatingStatuses { get; private set; } = false;
private static Timer _t { get; } private static Timer _t { get; }
private class TimerState
{
public int Index { get; set; } = 0;
}
static PlayingRotateCommands() static PlayingRotateCommands()
{ {
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
@ -34,21 +39,21 @@ namespace NadekoBot.Modules.Administration
_t = new Timer(async (_) => _t = new Timer(async (objState) =>
{ {
var index = 0;
try try
{ {
var state = (TimerState)objState;
if (!RotatingStatuses) if (!RotatingStatuses)
return; return;
else else
{ {
if (index >= RotatingStatusMessages.Count) if (state.Index >= RotatingStatusMessages.Count)
index = 0; state.Index = 0;
if (!RotatingStatusMessages.Any()) if (!RotatingStatusMessages.Any())
return; return;
var status = RotatingStatusMessages[index++].Status; var status = RotatingStatusMessages[state.Index++].Status;
if (string.IsNullOrWhiteSpace(status)) if (string.IsNullOrWhiteSpace(status))
return; return;
PlayingPlaceholders.ForEach(e => status = status.Replace(e.Key, e.Value())); PlayingPlaceholders.ForEach(e => status = status.Replace(e.Key, e.Value()));
@ -68,7 +73,7 @@ namespace NadekoBot.Modules.Administration
{ {
_log.Warn("Rotating playing status errored.\n" + ex); _log.Warn("Rotating playing status errored.\n" + ex);
} }
}, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1)); }, new TimerState(), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));
} }
public static Dictionary<string, Func<string>> PlayingPlaceholders { get; } = public static Dictionary<string, Func<string>> PlayingPlaceholders { get; } =

View File

@ -301,6 +301,14 @@ namespace NadekoBot.Modules.Utility
.ConfigureAwait(false); .ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases]
public async Task ShardId(ulong guildid)
{
var shardId = NadekoBot.Client.GetShardIdFor(guildid);
await Context.Channel.SendConfirmAsync($"ShardId for **{guildid}** with {NadekoBot.Client.Shards.Count} total shards", shardId.ToString()).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task Stats() public async Task Stats()
{ {