mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Merged v4 and working on adding grpc api. INcomplete
This commit is contained in:
@@ -48,4 +48,23 @@ public interface IStatsService
|
||||
/// Gets total amount of private memory currently in use by the bot, in Megabytes.
|
||||
/// </summary>
|
||||
double GetPrivateMemoryMegabytes();
|
||||
|
||||
GuildInfo GetGuildInfo(string name);
|
||||
GuildInfo GetGuildInfo(ulong id);
|
||||
}
|
||||
|
||||
public record struct GuildInfo
|
||||
{
|
||||
public required string Name { get; init; }
|
||||
public required string IconUrl { get; init; }
|
||||
public required string Owner { get; init; }
|
||||
public required ulong OwnerId { get; init; }
|
||||
public required ulong Id { get; init; }
|
||||
public required int TextChannels { get; init; }
|
||||
public required int VoiceChannels { get; init; }
|
||||
public required DateTime CreatedAt { get; init; }
|
||||
public required IReadOnlyList<string> Features { get; init; }
|
||||
public required IReadOnlyList<Emote> Emojis { get; init; }
|
||||
public required IReadOnlyList<IRole> Roles { get; init; }
|
||||
public int MemberCount { get; init; }
|
||||
}
|
@@ -185,4 +185,28 @@ public sealed class StatsService : IStatsService, IReadyExecutor, INService
|
||||
_currentProcess.Refresh();
|
||||
return _currentProcess.PrivateMemorySize64 / 1.Megabytes().Bytes;
|
||||
}
|
||||
|
||||
public GuildInfo GetGuildInfo(string name)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public GuildInfo GetGuildInfo(ulong id)
|
||||
{
|
||||
var g = _client.GetGuild(id);
|
||||
|
||||
return new GuildInfo()
|
||||
{
|
||||
Id = g.Id,
|
||||
IconUrl = g.IconUrl,
|
||||
Name = g.Name,
|
||||
Owner = g.Owner.Username,
|
||||
OwnerId = g.OwnerId,
|
||||
CreatedAt = g.CreatedAt.UtcDateTime,
|
||||
VoiceChannels = g.VoiceChannels.Count,
|
||||
TextChannels = g.TextChannels.Count,
|
||||
Features = g.Features.Value.ToString().Split(","),
|
||||
Emojis = g.Emotes.ToArray(),
|
||||
Roles = g.Roles.OrderByDescending(x => x.Position).ToArray(),
|
||||
MemberCount = g.MemberCount,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user