Initial commit for rich embed change for message output. Started on .stats command.

This commit is contained in:
fkndean 2016-11-29 08:47:06 -05:00
parent 2774c5d81c
commit 6c534f4233
2 changed files with 68 additions and 4 deletions

View File

@ -157,8 +157,32 @@ namespace NadekoBot.Modules.Utility
public async Task Stats(IUserMessage umsg)
{
var channel = umsg.Channel;
var desc = await NadekoBot.Stats.Print();
var servers = await NadekoBot.Stats.PrintServers();
var version = await NadekoBot.Stats.PrintVersion();
var uptime = await NadekoBot.Stats.PrintUptime();
var statistics = await NadekoBot.Stats.PrintStatistics();
var botid = await NadekoBot.Stats.PrintBotID();
var owners = await NadekoBot.Stats.PrintOwners();
DateTimeOffset date = date.ToLocalTime();
await channel.SendMessageAsync(await NadekoBot.Stats.Print());
var embed = new EmbedBuilder()
.WithAuthor(eau => eau.WithName("Author: [Kwoth#2560] | Library: [Discord.NET]")
.WithIconUrl("http://i.imgur.com/y0n6Lu4.jpg"))
.WithUrl("https://github.com/kwoth/nadekobot")
.WithTitle("Bot Information")
.WithDescription(servers)
.AddField(fb => fb.WithIndex(1).WithName("**Bot Version**").WithValue(version).WithIsInline(true))
.AddField(fb => fb.WithIndex(1).WithName("**Bot ID**").WithValue(botid).WithIsInline(true))
.AddField(fb => fb.WithIndex(1).WithName("**Uptime**").WithValue(uptime).WithIsInline(true))
.AddField(fb => fb.WithIndex(1).WithName("**Statistics**").WithValue(statistics).WithIsInline(true))
.WithColor(0xee42f4)
.AddField(fb => fb.WithIndex(1).WithName("**Owners**").WithValue(owners).WithIsInline(false))
.WithThumbnail(tn => tn.Url = "https://avatars.githubusercontent.com/u/2537696?v=3")
.WithImage(tn => tn.Url = "https://lh3.googleusercontent.com/-TDLUR4j7q20/V8u0E7CDUyI/AAAAAAAAAbQ/1pmQ256Cbdg324gU_ecvqdPMsmIBST-gwCJoC/w895-h504/rol%2B1-A.png")
.WithFooter(fb => fb.WithIconUrl("https://media0.giphy.com/media/JIu5iDNbCeLsI/200_s.gif").WithText("Nadeko"))
.WithTimestamp(DateTime.Now);
await channel.SendMessageAsync("-", embed: embed);
}
private Regex emojiFinder { get; } = new Regex(@"<:(?<name>.+?):(?<id>\d*)>", RegexOptions.Compiled);

View File

@ -61,15 +61,55 @@ namespace NadekoBot.Services.Impl
public async Task<string> Print()
{
var curUser = await client.GetCurrentUserAsync();
return $@"```css
return $@"
Author: [Kwoth#2560] | Library: [Discord.Net]
Bot Version: [{BotVersion}]
Bot ID: {curUser.Id}
Owner ID(s): {string.Join(", ", NadekoBot.Credentials.OwnerIds)}
Uptime: {GetUptimeString()}
Servers: {client.GetGuilds().Count} | TextChannels: {client.GetGuilds().SelectMany(g => g.GetChannels().Where(c => c is ITextChannel)).Count()} | VoiceChannels: {client.GetGuilds().SelectMany(g => g.GetChannels().Where(c => c is IVoiceChannel)).Count()}
Commands Ran this session: {commandsRan}
Messages: {messageCounter} [{messageCounter / (double)GetUptime().TotalSeconds:F2}/sec] Heap: [{Heap} MB]```";
`Commands Ran this session: {commandsRan}`
`Messages: {messageCounter} ({messageCounter / (double)GetUptime().TotalSeconds:F2}/sec)` `Heap: {Heap} MB`";
}
public async Task<string> PrintVersion()
{
var curUser = await client.GetCurrentUserAsync();
return $@"{BotVersion}";
}
public async Task<string> PrintOwners()
{
var curUser = await client.GetCurrentUserAsync();
return $@"ID(s): {string.Join(", ", NadekoBot.Credentials.OwnerIds)}";
}
public async Task<string> PrintUptime()
{
var curUser = await client.GetCurrentUserAsync();
return $@"{GetUptimeString()}";
}
public async Task<string> PrintBotID()
{
var curUser = await client.GetCurrentUserAsync();
return $@"{curUser.Id}";
}
public async Task<string> PrintServers()
{
var curUser = await client.GetCurrentUserAsync();
return $@"Servers: {client.GetGuilds().Count} | TextChannels: {client.GetGuilds().SelectMany(g => g.GetChannels().Where(c => c is ITextChannel)).Count()} | VoiceChannels: {client.GetGuilds().SelectMany(g => g.GetChannels().Where(c => c is IVoiceChannel)).Count()}";
}
public async Task<string> PrintStatistics()
{
var curUser = await client.GetCurrentUserAsync();
return $@"Commands Ran this session: {commandsRan}
Messages: {messageCounter} ({messageCounter / (double)GetUptime().TotalSeconds:F2}/sec)
Heap: {Heap} MB";
}
public Task Reset()