Many random things
This commit is contained in:
parent
c39d65dffd
commit
f052bcf5a0
@ -269,8 +269,10 @@ namespace NadekoBot.Modules.Utility
|
||||
.AddField(efb => efb.WithName(Format.Bold("Memory")).WithValue($"{stats.Heap} MB").WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(Format.Bold("Owner ID(s)")).WithValue(stats.OwnerIds).WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(Format.Bold("Uptime")).WithValue(stats.GetUptimeString("\n")).WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(Format.Bold("Presence")).WithValue($"{NadekoBot.Client.GetGuilds().Count} Servers\n{stats.TextChannels} Text Channels\n{stats.VoiceChannels} Voice Channels").WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(Format.Bold("Presence")).WithValue($"{NadekoBot.Client.GetGuildsCount()} Servers\n{stats.TextChannels} Text Channels\n{stats.VoiceChannels} Voice Channels").WithIsInline(true))
|
||||
#if !GLOBAL_NADEKO
|
||||
.WithFooter(efb => efb.WithText($"Playing {Music.Music.MusicPlayers.Where(mp => mp.Value.CurrentSong != null).Count()} songs, {Music.Music.MusicPlayers.Sum(mp => mp.Value.Playlist.Count)} queued."))
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ using static NadekoBot.Modules.Administration.Administration;
|
||||
using NadekoBot.Modules.CustomReactions;
|
||||
using NadekoBot.Modules.Games;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
|
||||
namespace NadekoBot.Services
|
||||
{
|
||||
@ -39,11 +40,19 @@ namespace NadekoBot.Services
|
||||
//userid/msg count
|
||||
public ConcurrentDictionary<ulong, uint> UserMessagesSent { get; } = new ConcurrentDictionary<ulong, uint>();
|
||||
|
||||
public ConcurrentHashSet<ulong> UsersOnShortCooldown { get; } = new ConcurrentHashSet<ulong>();
|
||||
private Timer clearUsersOnShortCooldown { get; }
|
||||
|
||||
public CommandHandler(ShardedDiscordClient client, CommandService commandService)
|
||||
{
|
||||
_client = client;
|
||||
_commandService = commandService;
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
clearUsersOnShortCooldown = new Timer((_) =>
|
||||
{
|
||||
UsersOnShortCooldown.Clear();
|
||||
}, null, 1500, 1500);
|
||||
}
|
||||
public async Task StartHandling()
|
||||
{
|
||||
@ -70,8 +79,11 @@ namespace NadekoBot.Services
|
||||
if (usrMsg == null)
|
||||
return;
|
||||
|
||||
//if (!usrMsg.IsAuthor())
|
||||
// UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (key, old) => ++old);
|
||||
if (!usrMsg.IsAuthor())
|
||||
UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (key, old) => ++old);
|
||||
|
||||
if (!UsersOnShortCooldown.Add(usrMsg.Author.Id))
|
||||
return;
|
||||
|
||||
if (msg.Author.IsBot || !NadekoBot.Ready) //no bots
|
||||
return;
|
||||
|
@ -20,7 +20,12 @@ namespace NadekoBot.Services.Impl
|
||||
public string Library => "Discord.Net";
|
||||
public int MessageCounter { get; private set; } = 0;
|
||||
public int CommandsRan { get; private set; } = 0;
|
||||
public string Heap => Math.Round((double)GC.GetTotalMemory(false) / 1.MiB(), 2).ToString();
|
||||
public string Heap =>
|
||||
#if !GLOBAL_NADEKO
|
||||
Math.Round((double)GC.GetTotalMemory(false) / 1.MiB(), 2).ToString();
|
||||
#else
|
||||
"a lot :)";
|
||||
#endif
|
||||
public double MessagesPerSecond => MessageCounter / (double)GetUptime().TotalSeconds;
|
||||
public int TextChannels => client.GetGuilds().SelectMany(g => g.Channels.Where(c => c is ITextChannel)).Count();
|
||||
public int VoiceChannels => client.GetGuilds().SelectMany(g => g.Channels.Where(c => c is IVoiceChannel)).Count();
|
||||
|
@ -96,6 +96,9 @@ namespace NadekoBot
|
||||
public IReadOnlyCollection<SocketGuild> GetGuilds() =>
|
||||
Clients.SelectMany(c => c.Guilds).ToList();
|
||||
|
||||
public int GetGuildsCount() =>
|
||||
Clients.Sum(c => c.Guilds.Count);
|
||||
|
||||
public SocketGuild GetGuild(ulong id) =>
|
||||
Clients.Select(c => c.GetGuild(id)).FirstOrDefault(g => g != null);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user