.stats now show music stats, filter commands cleaned up

This commit is contained in:
Kwoth 2016-12-24 08:30:20 +01:00
parent 937f775db4
commit 82704166ab
2 changed files with 27 additions and 69 deletions

View File

@ -2,6 +2,7 @@
using Discord.Commands;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Services;
using System.Collections.Concurrent;
using System.Linq;
@ -77,12 +78,12 @@ namespace NadekoBot.Modules.Permissions
if (enabled)
{
InviteFilteringServers.Add(channel.Guild.Id);
await channel.SendMessageAsync("✅ `Invite filtering enabled on this server.`").ConfigureAwait(false);
await channel.SendConfirmAsync("Invite filtering enabled on this server.").ConfigureAwait(false);
}
else
{
InviteFilteringServers.TryRemove(channel.Guild.Id);
await channel.SendMessageAsync(" `Invite filtering disabled on this server.`").ConfigureAwait(false);
await channel.SendConfirmAsync("Invite filtering disabled on this server.").ConfigureAwait(false);
}
}
@ -110,12 +111,12 @@ namespace NadekoBot.Modules.Permissions
if (removed == 0)
{
InviteFilteringChannels.Add(channel.Id);
await channel.SendMessageAsync("✅ `Invite filtering enabled on this channel.`").ConfigureAwait(false);
await channel.SendConfirmAsync("Invite filtering enabled on this channel.").ConfigureAwait(false);
}
else
{
InviteFilteringChannels.TryRemove(channel.Id);
await channel.SendMessageAsync(" `Invite filtering disabled on this channel.`").ConfigureAwait(false);
await channel.SendConfirmAsync("Invite filtering disabled on this channel.").ConfigureAwait(false);
}
}
@ -136,12 +137,12 @@ namespace NadekoBot.Modules.Permissions
if (enabled)
{
WordFilteringServers.Add(channel.Guild.Id);
await channel.SendMessageAsync("✅ `Word filtering enabled on this server.`").ConfigureAwait(false);
await channel.SendConfirmAsync("Word filtering enabled on this server.").ConfigureAwait(false);
}
else
{
WordFilteringServers.TryRemove(channel.Guild.Id);
await channel.SendMessageAsync(" `Word filtering disabled on this server.`").ConfigureAwait(false);
await channel.SendConfirmAsync("Word filtering disabled on this server.").ConfigureAwait(false);
}
}
@ -169,12 +170,12 @@ namespace NadekoBot.Modules.Permissions
if (removed == 0)
{
WordFilteringChannels.Add(channel.Id);
await channel.SendMessageAsync("✅ `Word filtering enabled on this channel.`").ConfigureAwait(false);
await channel.SendConfirmAsync("Word filtering enabled on this channel.").ConfigureAwait(false);
}
else
{
WordFilteringChannels.TryRemove(channel.Id);
await channel.SendMessageAsync(" `Word filtering disabled on this channel.`").ConfigureAwait(false);
await channel.SendConfirmAsync("Word filtering disabled on this channel.").ConfigureAwait(false);
}
}
@ -207,13 +208,13 @@ namespace NadekoBot.Modules.Permissions
if (removed == 0)
{
filteredWords.Add(word);
await channel.SendMessageAsync($"✅ Word `{word}` successfully added to the list of filtered words.")
await channel.SendConfirmAsync($"Word `{word}` successfully added to the list of filtered words.")
.ConfigureAwait(false);
}
else
{
filteredWords.TryRemove(word);
await channel.SendMessageAsync($" Word `{word}` removed from the list of filtered words.")
await channel.SendConfirmAsync($"Word `{word}` removed from the list of filtered words.")
.ConfigureAwait(false);
}
}
@ -227,7 +228,7 @@ namespace NadekoBot.Modules.Permissions
ConcurrentHashSet<string> filteredWords;
ServerFilteredWords.TryGetValue(channel.Guild.Id, out filteredWords);
await channel.SendMessageAsync($" `List of banned words:`\n" + string.Join(",\n", filteredWords))
await channel.SendConfirmAsync($"List of filtered words", string.Join("\n", filteredWords))
.ConfigureAwait(false);
}
}

View File

@ -207,64 +207,21 @@ namespace NadekoBot.Modules.Utility
var stats = NadekoBot.Stats;
await channel.EmbedAsync(
new Embed()
{
Author = new EmbedAuthor()
{
Name = $"NadekoBot v{StatsService.BotVersion}",
Url = "http://nadekobot.readthedocs.io/en/latest/",
IconUrl = "https://cdn.discordapp.com/avatars/116275390695079945/b21045e778ef21c96d175400e779f0fb.jpg"
},
Fields = new[] {
new EmbedField() {
Name = Format.Bold("Author"),
Value = stats.Author,
Inline = true
},
new EmbedField() {
Name = Format.Bold("Library"),
Value = stats.Library,
Inline = true
},
new EmbedField() {
Name = Format.Bold("Bot ID"),
Value = NadekoBot.Client.GetCurrentUser().Id.ToString(),
Inline = true
},
new EmbedField() {
Name = Format.Bold("Commands Ran"),
Value = stats.CommandsRan.ToString(),
Inline = true
},
new EmbedField() {
Name = Format.Bold("Messages"),
Value = $"{stats.MessageCounter} ({stats.MessagesPerSecond:F2}/sec)",
Inline = true
},
new EmbedField() {
Name = Format.Bold("Memory"),
Value = $"{stats.Heap} MB",
Inline = true
},
new EmbedField() {
Name = Format.Bold("Owner ID(s)"),
Value = stats.OwnerIds,
Inline = true
},
new EmbedField() {
Name = Format.Bold("Uptime"),
Value = stats.GetUptimeString("\n"),
Inline = true
},
new EmbedField() {
Name = Format.Bold("Presence"),
Value = $"{NadekoBot.Client.GetGuilds().Count} Servers\n{stats.TextChannels} Text Channels\n{stats.VoiceChannels} Voice Channels",
Inline = true
},
},
Color = 0x00bbd6
});
new EmbedBuilder().WithOkColor()
.WithAuthor(eab => eab.WithName($"NadekoBot v{StatsService.BotVersion}")
.WithUrl("http://nadekobot.readthedocs.io/en/latest/")
.WithIconUrl("https://cdn.discordapp.com/avatars/116275390695079945/b21045e778ef21c96d175400e779f0fb.jpg"))
.AddField(efb => efb.WithName(Format.Bold("Author")).WithValue(stats.Author).WithIsInline(true))
.AddField(efb => efb.WithName(Format.Bold("Library")).WithValue(stats.Library).WithIsInline(true))
.AddField(efb => efb.WithName(Format.Bold("Bot ID")).WithValue(NadekoBot.Client.GetCurrentUser().Id.ToString()).WithIsInline(true))
.AddField(efb => efb.WithName(Format.Bold("Commands Ran")).WithValue(stats.CommandsRan.ToString()).WithIsInline(true))
.AddField(efb => efb.WithName(Format.Bold("Messages")).WithValue($"{stats.MessageCounter} ({stats.MessagesPerSecond:F2}/sec)").WithIsInline(true))
.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))
.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."))
.Build());
}
private Regex emojiFinder { get; } = new Regex(@"<:(?<name>.+?):(?<id>\d*)>", RegexOptions.Compiled);