Huge changes to make shards run in separate processes
This commit is contained in:
@@ -140,7 +140,7 @@ namespace NadekoBot.Modules.Administration
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
|
||||
await Context.Channel.SendPaginatedConfirmAsync((DiscordShardedClient)Context.Client, page, (curPage) =>
|
||||
await Context.Channel.SendPaginatedConfirmAsync((DiscordSocketClient)Context.Client, page, (curPage) =>
|
||||
{
|
||||
return new EmbedBuilder()
|
||||
.WithTitle(GetText("self_assign_list", roleCnt))
|
||||
|
@@ -13,6 +13,7 @@ using NadekoBot.Services;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NadekoBot.Services.Administration;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
@@ -25,10 +26,10 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
private static readonly object _locker = new object();
|
||||
private readonly SelfService _service;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly IImagesService _images;
|
||||
|
||||
public SelfCommands(DbService db, SelfService service, DiscordShardedClient client,
|
||||
public SelfCommands(DbService db, SelfService service, DiscordSocketClient client,
|
||||
IImagesService images)
|
||||
{
|
||||
_db = db;
|
||||
@@ -204,28 +205,29 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[OwnerOnly]
|
||||
public async Task ConnectShard(int shardid)
|
||||
{
|
||||
var shard = _client.GetShard(shardid);
|
||||
//todo 2 shard commands
|
||||
//[NadekoCommand, Usage, Description, Aliases]
|
||||
//[OwnerOnly]
|
||||
//public async Task ConnectShard(int shardid)
|
||||
//{
|
||||
// var shard = _client.GetShard(shardid);
|
||||
|
||||
if (shard == null)
|
||||
{
|
||||
await ReplyErrorLocalized("no_shard_id").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
await ReplyConfirmLocalized("shard_reconnecting", Format.Bold("#" + shardid)).ConfigureAwait(false);
|
||||
await shard.StartAsync().ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("shard_reconnected", Format.Bold("#" + shardid)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Warn(ex);
|
||||
}
|
||||
}
|
||||
// if (shard == null)
|
||||
// {
|
||||
// await ReplyErrorLocalized("no_shard_id").ConfigureAwait(false);
|
||||
// return;
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// await ReplyConfirmLocalized("shard_reconnecting", Format.Bold("#" + shardid)).ConfigureAwait(false);
|
||||
// await shard.StartAsync().ConfigureAwait(false);
|
||||
// await ReplyConfirmLocalized("shard_reconnected", Format.Bold("#" + shardid)).ConfigureAwait(false);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// _log.Warn(ex);
|
||||
// }
|
||||
//}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[OwnerOnly]
|
||||
@@ -417,8 +419,10 @@ namespace NadekoBot.Modules.Administration
|
||||
[OwnerOnly]
|
||||
public async Task ReloadImages()
|
||||
{
|
||||
var time = _images.Reload();
|
||||
await ReplyConfirmLocalized("images_loaded", time.TotalSeconds.ToString("F3")).ConfigureAwait(false);
|
||||
var sw = Stopwatch.StartNew();
|
||||
_images.Reload();
|
||||
sw.Stop();
|
||||
await ReplyConfirmLocalized("images_loaded", sw.Elapsed.TotalSeconds.ToString("F3")).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static UserStatus SettableUserStatusToUserStatus(SettableUserStatus sus)
|
||||
|
@@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Administration
|
||||
.ToArray();
|
||||
var timezonesPerPage = 20;
|
||||
|
||||
await Context.Channel.SendPaginatedConfirmAsync((DiscordShardedClient)Context.Client, page,
|
||||
await Context.Channel.SendPaginatedConfirmAsync((DiscordSocketClient)Context.Client, page,
|
||||
(curPage) => new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("timezones_available"))
|
||||
|
@@ -17,10 +17,10 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly DbService _db;
|
||||
private readonly CustomReactionsService _crs;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public CustomReactions(IBotCredentials creds, DbService db, CustomReactionsService crs,
|
||||
DiscordShardedClient client)
|
||||
DiscordSocketClient client)
|
||||
{
|
||||
_creds = creds;
|
||||
_db = db;
|
||||
|
@@ -22,12 +22,12 @@ namespace NadekoBot.Modules.Gambling
|
||||
{
|
||||
private readonly BotConfig _bc;
|
||||
private readonly CurrencyService _cs;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
|
||||
public static ConcurrentDictionary<ulong, AnimalRace> AnimalRaces { get; } = new ConcurrentDictionary<ulong, AnimalRace>();
|
||||
|
||||
public AnimalRacing(BotConfig bc, CurrencyService cs, DiscordShardedClient client)
|
||||
public AnimalRacing(BotConfig bc, CurrencyService cs, DiscordSocketClient client)
|
||||
{
|
||||
_bc = bc;
|
||||
_cs = cs;
|
||||
@@ -82,14 +82,14 @@ namespace NadekoBot.Modules.Gambling
|
||||
private readonly ITextChannel _raceChannel;
|
||||
private readonly BotConfig _bc;
|
||||
private readonly CurrencyService _cs;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly ILocalization _localization;
|
||||
private readonly NadekoStrings _strings;
|
||||
|
||||
public bool Started { get; private set; }
|
||||
|
||||
public AnimalRace(ulong serverId, ITextChannel channel, string prefix, BotConfig bc,
|
||||
CurrencyService cs, DiscordShardedClient client, ILocalization localization,
|
||||
CurrencyService cs, DiscordSocketClient client, ILocalization localization,
|
||||
NadekoStrings strings)
|
||||
{
|
||||
_prefix = prefix;
|
||||
|
@@ -34,11 +34,11 @@ namespace NadekoBot.Modules.Gambling
|
||||
.ToArray();
|
||||
|
||||
private string _secretCode = string.Empty;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly BotConfig _bc;
|
||||
private readonly CurrencyService _cs;
|
||||
|
||||
public CurrencyEvents(DiscordShardedClient client, BotConfig bc, CurrencyService cs)
|
||||
public CurrencyEvents(DiscordSocketClient client, BotConfig bc, CurrencyService cs)
|
||||
{
|
||||
_client = client;
|
||||
_bc = bc;
|
||||
@@ -151,7 +151,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
{
|
||||
private readonly ConcurrentHashSet<ulong> _flowerReactionAwardedUsers = new ConcurrentHashSet<ulong>();
|
||||
private readonly Logger _log;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly CurrencyService _cs;
|
||||
|
||||
private IUserMessage StartingMessage { get; set; }
|
||||
@@ -159,7 +159,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
private CancellationTokenSource Source { get; }
|
||||
private CancellationToken CancelToken { get; }
|
||||
|
||||
public FlowerReactionEvent(DiscordShardedClient client, CurrencyService cs)
|
||||
public FlowerReactionEvent(DiscordSocketClient client, CurrencyService cs)
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
_client = client;
|
||||
|
@@ -22,7 +22,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
private readonly BotConfig _bc;
|
||||
private readonly DbService _db;
|
||||
private readonly CurrencyService _cs;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public enum Role
|
||||
{
|
||||
@@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
List
|
||||
}
|
||||
|
||||
public FlowerShop(BotConfig bc, DbService db, CurrencyService cs, DiscordShardedClient client)
|
||||
public FlowerShop(BotConfig bc, DbService db, CurrencyService cs, DiscordSocketClient client)
|
||||
{
|
||||
_db = db;
|
||||
_bc = bc;
|
||||
|
@@ -20,12 +20,12 @@ namespace NadekoBot.Modules.Games
|
||||
[Group]
|
||||
public class Acropobia : NadekoSubmodule
|
||||
{
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
//channelId, game
|
||||
public static ConcurrentDictionary<ulong, AcrophobiaGame> AcrophobiaGames { get; } = new ConcurrentDictionary<ulong, AcrophobiaGame>();
|
||||
|
||||
public Acropobia(DiscordShardedClient client)
|
||||
public Acropobia(DiscordSocketClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
@@ -86,10 +86,10 @@ namespace NadekoBot.Modules.Games
|
||||
//text, votes
|
||||
private readonly ConcurrentDictionary<string, int> _votes = new ConcurrentDictionary<string, int>();
|
||||
private readonly Logger _log;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly NadekoStrings _strings;
|
||||
|
||||
public AcrophobiaGame(DiscordShardedClient client, NadekoStrings strings, ITextChannel channel, int time)
|
||||
public AcrophobiaGame(DiscordSocketClient client, NadekoStrings strings, ITextChannel channel, int time)
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
_client = client;
|
||||
|
@@ -56,7 +56,7 @@ namespace NadekoBot.Modules.Games.Hangman
|
||||
public class HangmanGame: IDisposable
|
||||
{
|
||||
private readonly Logger _log;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public IMessageChannel GameChannel { get; }
|
||||
public HashSet<char> Guesses { get; } = new HashSet<char>();
|
||||
@@ -82,7 +82,7 @@ namespace NadekoBot.Modules.Games.Hangman
|
||||
|
||||
public event Action<HangmanGame> OnEnded;
|
||||
|
||||
public HangmanGame(DiscordShardedClient client, IMessageChannel channel, string type)
|
||||
public HangmanGame(DiscordSocketClient client, IMessageChannel channel, string type)
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
_client = client;
|
||||
|
@@ -15,9 +15,9 @@ namespace NadekoBot.Modules.Games
|
||||
[Group]
|
||||
public class HangmanCommands : NadekoSubmodule
|
||||
{
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public HangmanCommands(DiscordShardedClient client)
|
||||
public HangmanCommands(DiscordSocketClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
@@ -20,13 +20,13 @@ namespace NadekoBot.Modules.Games.Models
|
||||
public bool IsActive { get; private set; }
|
||||
private readonly Stopwatch sw;
|
||||
private readonly List<ulong> finishedUserIds;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly GamesService _games;
|
||||
private readonly string _prefix;
|
||||
|
||||
private Logger _log { get; }
|
||||
|
||||
public TypingGame(GamesService games, DiscordShardedClient client, ITextChannel channel, string prefix) //kek@prefix
|
||||
public TypingGame(GamesService games, DiscordSocketClient client, ITextChannel channel, string prefix) //kek@prefix
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
_games = games;
|
||||
|
@@ -13,10 +13,10 @@ namespace NadekoBot.Modules.Games
|
||||
[Group]
|
||||
public class PollCommands : NadekoSubmodule
|
||||
{
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly PollService _polls;
|
||||
|
||||
public PollCommands(DiscordShardedClient client, PollService polls)
|
||||
public PollCommands(DiscordSocketClient client, PollService polls)
|
||||
{
|
||||
_client = client;
|
||||
_polls = polls;
|
||||
|
@@ -20,9 +20,9 @@ namespace NadekoBot.Modules.Games
|
||||
{
|
||||
public static ConcurrentDictionary<ulong, TypingGame> RunningContests = new ConcurrentDictionary<ulong, TypingGame>();
|
||||
private readonly GamesService _games;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public SpeedTypingCommands(DiscordShardedClient client, GamesService games)
|
||||
public SpeedTypingCommands(DiscordSocketClient client, GamesService games)
|
||||
{
|
||||
_games = games;
|
||||
_client = client;
|
||||
|
@@ -21,9 +21,9 @@ namespace NadekoBot.Modules.Games
|
||||
private static readonly Dictionary<ulong, TicTacToe> _games = new Dictionary<ulong, TicTacToe>();
|
||||
|
||||
private readonly SemaphoreSlim _sem = new SemaphoreSlim(1, 1);
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public TicTacToeCommands(DiscordShardedClient client)
|
||||
public TicTacToeCommands(DiscordSocketClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
@@ -87,9 +87,9 @@ namespace NadekoBot.Modules.Games
|
||||
private IUserMessage _previousMessage;
|
||||
private Timer _timeoutTimer;
|
||||
private readonly NadekoStrings _strings;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public TicTacToe(NadekoStrings strings, DiscordShardedClient client, ITextChannel channel, IGuildUser firstUser)
|
||||
public TicTacToe(NadekoStrings strings, DiscordSocketClient client, ITextChannel channel, IGuildUser firstUser)
|
||||
{
|
||||
_channel = channel;
|
||||
_strings = strings;
|
||||
|
@@ -20,7 +20,7 @@ namespace NadekoBot.Modules.Games.Trivia
|
||||
private readonly SemaphoreSlim _guessLock = new SemaphoreSlim(1, 1);
|
||||
private readonly Logger _log;
|
||||
private readonly NadekoStrings _strings;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly BotConfig _bc;
|
||||
private readonly CurrencyService _cs;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Games.Trivia
|
||||
|
||||
public int WinRequirement { get; }
|
||||
|
||||
public TriviaGame(NadekoStrings strings, DiscordShardedClient client, BotConfig bc,
|
||||
public TriviaGame(NadekoStrings strings, DiscordSocketClient client, BotConfig bc,
|
||||
CurrencyService cs, IGuild guild, ITextChannel channel,
|
||||
bool showHints, int winReq, bool isPokemon)
|
||||
{
|
||||
|
@@ -18,12 +18,12 @@ namespace NadekoBot.Modules.Games
|
||||
public class TriviaCommands : NadekoSubmodule
|
||||
{
|
||||
private readonly CurrencyService _cs;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly BotConfig _bc;
|
||||
|
||||
public static ConcurrentDictionary<ulong, TriviaGame> RunningTrivias { get; } = new ConcurrentDictionary<ulong, TriviaGame>();
|
||||
|
||||
public TriviaCommands(DiscordShardedClient client, BotConfig bc, CurrencyService cs)
|
||||
public TriviaCommands(DiscordSocketClient client, BotConfig bc, CurrencyService cs)
|
||||
{
|
||||
_cs = cs;
|
||||
_client = client;
|
||||
|
@@ -22,12 +22,12 @@ namespace NadekoBot.Modules.Music
|
||||
public class Music : NadekoTopLevelModule
|
||||
{
|
||||
private static MusicService _music;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly IGoogleApiService _google;
|
||||
private readonly DbService _db;
|
||||
|
||||
public Music(DiscordShardedClient client, IBotCredentials creds, IGoogleApiService google,
|
||||
public Music(DiscordSocketClient client, IBotCredentials creds, IGoogleApiService google,
|
||||
DbService db, MusicService music)
|
||||
{
|
||||
_client = client;
|
||||
|
@@ -86,13 +86,12 @@ namespace NadekoBot.Modules
|
||||
var text = GetText(textKey, replacements);
|
||||
return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + text);
|
||||
}
|
||||
|
||||
// todo maybe make this generic and use
|
||||
// TypeConverter typeConverter = TypeDescriptor.GetConverter(propType);
|
||||
|
||||
// TypeConverter typeConverter = TypeDescriptor.GetConverter(propType); ?
|
||||
public async Task<string> GetUserInputAsync(ulong userId, ulong channelId)
|
||||
{
|
||||
var userInputTask = new TaskCompletionSource<string>();
|
||||
var dsc = (DiscordShardedClient)Context.Client;
|
||||
var dsc = (DiscordSocketClient)Context.Client;
|
||||
try
|
||||
{
|
||||
dsc.MessageReceived += MessageReceived;
|
||||
|
@@ -195,7 +195,7 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
var fws = fwHash.ToArray();
|
||||
|
||||
await channel.SendPaginatedConfirmAsync((DiscordShardedClient)Context.Client,
|
||||
await channel.SendPaginatedConfirmAsync((DiscordSocketClient)Context.Client,
|
||||
page,
|
||||
(curPage) =>
|
||||
new EmbedBuilder()
|
||||
|
@@ -21,9 +21,9 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
private readonly CommandMapService _service;
|
||||
private readonly DbService _db;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public CommandMapCommands(CommandMapService service, DbService db, DiscordShardedClient client)
|
||||
public CommandMapCommands(CommandMapService service, DbService db, DiscordSocketClient client)
|
||||
{
|
||||
_service = service;
|
||||
_db = db;
|
||||
|
@@ -16,10 +16,10 @@ namespace NadekoBot.Modules.Utility
|
||||
[Group]
|
||||
public class InfoCommands : NadekoSubmodule
|
||||
{
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly IStatsService _stats;
|
||||
|
||||
public InfoCommands(DiscordShardedClient client, IStatsService stats, CommandHandler ch)
|
||||
public InfoCommands(DiscordSocketClient client, IStatsService stats, CommandHandler ch)
|
||||
{
|
||||
_client = client;
|
||||
_stats = stats;
|
||||
|
@@ -22,10 +22,10 @@ namespace NadekoBot.Modules.Utility
|
||||
public class RepeatCommands : NadekoSubmodule
|
||||
{
|
||||
private readonly MessageRepeaterService _service;
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly DbService _db;
|
||||
|
||||
public RepeatCommands(MessageRepeaterService service, DiscordShardedClient client, DbService db)
|
||||
public RepeatCommands(MessageRepeaterService service, DiscordSocketClient client, DbService db)
|
||||
{
|
||||
_service = service;
|
||||
_client = client;
|
||||
|
@@ -24,15 +24,17 @@ namespace NadekoBot.Modules.Utility
|
||||
public partial class Utility : NadekoTopLevelModule
|
||||
{
|
||||
private static ConcurrentDictionary<ulong, Timer> _rotatingRoleColors = new ConcurrentDictionary<ulong, Timer>();
|
||||
private readonly DiscordShardedClient _client;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly IStatsService _stats;
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly NadekoBot _bot;
|
||||
|
||||
public Utility(DiscordShardedClient client, IStatsService stats, IBotCredentials creds)
|
||||
public Utility(NadekoBot bot, DiscordSocketClient client, IStatsService stats, IBotCredentials creds)
|
||||
{
|
||||
_client = client;
|
||||
_stats = stats;
|
||||
_creds = creds;
|
||||
_bot = bot;
|
||||
}
|
||||
|
||||
//[NadekoCommand, Usage, Description, Aliases]
|
||||
@@ -352,56 +354,56 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} https://discord.gg/{invite.Code}");
|
||||
}
|
||||
//todo 2 shard commands
|
||||
//[NadekoCommand, Usage, Description, Aliases]
|
||||
//public async Task ShardStats(int page = 1)
|
||||
//{
|
||||
// if (--page < 0)
|
||||
// return;
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task ShardStats(int page = 1)
|
||||
{
|
||||
if (--page < 0)
|
||||
return;
|
||||
// var status = string.Join(", ", _client.Shards.GroupBy(x => x.ConnectionState)
|
||||
// .Select(x => $"{x.Count()} {x.Key}")
|
||||
// .ToArray());
|
||||
|
||||
var status = string.Join(", ", _client.Shards.GroupBy(x => x.ConnectionState)
|
||||
.Select(x => $"{x.Count()} {x.Key}")
|
||||
.ToArray());
|
||||
|
||||
var allShardStrings = _client.Shards
|
||||
.Select(x =>
|
||||
GetText("shard_stats_txt", x.ShardId.ToString(),
|
||||
Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.Count.ToString())))
|
||||
.ToArray();
|
||||
// var allShardStrings = _client.Shards
|
||||
// .Select(x =>
|
||||
// GetText("shard_stats_txt", x.ShardId.ToString(),
|
||||
// Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.Count.ToString())))
|
||||
// .ToArray();
|
||||
|
||||
|
||||
|
||||
await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) =>
|
||||
{
|
||||
// await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) =>
|
||||
// {
|
||||
|
||||
var str = string.Join("\n", allShardStrings.Skip(25 * curPage).Take(25));
|
||||
// var str = string.Join("\n", allShardStrings.Skip(25 * curPage).Take(25));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(str))
|
||||
str = GetText("no_shards_on_page");
|
||||
// if (string.IsNullOrWhiteSpace(str))
|
||||
// str = GetText("no_shards_on_page");
|
||||
|
||||
return new EmbedBuilder()
|
||||
.WithAuthor(a => a.WithName(GetText("shard_stats")))
|
||||
.WithTitle(status)
|
||||
.WithOkColor()
|
||||
.WithDescription(str);
|
||||
}, allShardStrings.Length / 25);
|
||||
}
|
||||
// return new EmbedBuilder()
|
||||
// .WithAuthor(a => a.WithName(GetText("shard_stats")))
|
||||
// .WithTitle(status)
|
||||
// .WithOkColor()
|
||||
// .WithDescription(str);
|
||||
// }, allShardStrings.Length / 25);
|
||||
//}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task ShardId(IGuild guild)
|
||||
{
|
||||
var shardId = _client.GetShardIdFor(guild);
|
||||
//[NadekoCommand, Usage, Description, Aliases]
|
||||
//public async Task ShardId(IGuild guild)
|
||||
//{
|
||||
// var shardId = _client.GetShardIdFor(guild);
|
||||
|
||||
await Context.Channel.SendConfirmAsync(shardId.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
// await Context.Channel.SendConfirmAsync(shardId.ToString()).ConfigureAwait(false);
|
||||
//}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task Stats()
|
||||
{
|
||||
var shardId = Context.Guild != null
|
||||
? _client.GetShardIdFor(Context.Guild)
|
||||
: 0;
|
||||
|
||||
//var shardId = Context.Guild != null
|
||||
// ? _client.GetShardIdFor(Context.Guild)
|
||||
// : 0;
|
||||
|
||||
await Context.Channel.EmbedAsync(
|
||||
new EmbedBuilder().WithOkColor()
|
||||
.WithAuthor(eab => eab.WithName($"NadekoBot v{StatsService.BotVersion}")
|
||||
@@ -409,7 +411,7 @@ namespace NadekoBot.Modules.Utility
|
||||
.WithIconUrl("https://cdn.discordapp.com/avatars/116275390695079945/b21045e778ef21c96d175400e779f0fb.jpg"))
|
||||
.AddField(efb => efb.WithName(GetText("author")).WithValue(_stats.Author).WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(GetText("botid")).WithValue(_client.CurrentUser.Id.ToString()).WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(GetText("shard")).WithValue($"#{shardId} / {_client.Shards.Count}").WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(GetText("shard")).WithValue($"#{_bot.ShardId} / {_creds.TotalShards}").WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(GetText("commands_ran")).WithValue(_stats.CommandsRan.ToString()).WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(GetText("messages")).WithValue($"{_stats.MessageCounter} ({_stats.MessagesPerSecond:F2}/sec)").WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(GetText("memory")).WithValue($"{_stats.Heap} MB").WithIsInline(true))
|
||||
|
Reference in New Issue
Block a user