feat: added info command and renamed project
This commit is contained in:
parent
eb7ce93350
commit
e6c1b1396e
14 changed files with 90 additions and 18 deletions
|
@ -1 +0,0 @@
|
|||
CSharpBot
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBot", "CSharpBot\CSharpBot.csproj", "{57AEE340-B119-49C8-9217-D87250628498}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharpy", "Sharpy\Sharpy.csproj", "{57AEE340-B119-49C8-9217-D87250628498}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
62
Sharpy/Commands/Msg/General/Info.cs
Normal file
62
Sharpy/Commands/Msg/General/Info.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using ByteSizeLib;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using Hardware.Info;
|
||||
|
||||
namespace Sharpy.Commands.Msg.General
|
||||
{
|
||||
public class Info : BaseCommandModule
|
||||
{
|
||||
[Command("info"), Description("Get info about the bot"), Cooldown(5, 5, CooldownBucketType.Global)]
|
||||
public async Task InfoCommand(CommandContext ctx)
|
||||
{
|
||||
var clientMember = from member in ctx.Guild.Members
|
||||
where member.Value.Id == ctx.Client.CurrentUser.Id
|
||||
select member.Value;
|
||||
|
||||
var roleColor = clientMember.First().Color;
|
||||
|
||||
var loadingMsg = await ctx.RespondAsync("Loading...");
|
||||
|
||||
var hardwareInfo = new HardwareInfo();
|
||||
hardwareInfo.RefreshCPUList();
|
||||
hardwareInfo.RefreshMemoryStatus();
|
||||
|
||||
var currentRamUsage =
|
||||
Math.Round(
|
||||
Convert.ToDecimal(ByteSize
|
||||
.FromBytes(hardwareInfo.MemoryStatus.TotalPhysical - hardwareInfo.MemoryStatus.AvailablePhysical)
|
||||
.GibiBytes), 2);
|
||||
|
||||
var totalRamUsage =
|
||||
Math.Round(Convert.ToDecimal(ByteSize.FromBytes(hardwareInfo.MemoryStatus.TotalPhysical).GibiBytes), 2);
|
||||
|
||||
var embed = new DiscordEmbedBuilder()
|
||||
.WithAuthor("Sharpy")
|
||||
.WithColor(roleColor)
|
||||
.WithDescription(@$"**Library Version**: DSharpPlus Version {ctx.Client.VersionString}
|
||||
**Bot Version**: {Assembly.GetExecutingAssembly().GetName().Name} Version {Assembly.GetExecutingAssembly().GetName().Version}
|
||||
|
||||
**Bot Stats**
|
||||
**Servers**: {ctx.Client.Guilds.Count}
|
||||
**Shards**: {ctx.Client.ShardCount} (Current Shard: {ctx.Client.ShardId})
|
||||
|
||||
**System Stats**
|
||||
**OS**: {RuntimeInformation.RuntimeIdentifier}
|
||||
**CPU**: {hardwareInfo.CpuList.First().Name} (x{hardwareInfo.CpuList.Count})
|
||||
**Process RAM Usage**: {Math.Round(Convert.ToDecimal(ByteSize.FromBytes(Process.GetCurrentProcess().WorkingSet64).MebiBytes), 2)}MB
|
||||
**Total RAM Usage**: {currentRamUsage}GB/{totalRamUsage}GB ({Math.Round(currentRamUsage / totalRamUsage * 100, 2)}%)")
|
||||
.Build();
|
||||
|
||||
await loadingMsg.DeleteAsync();
|
||||
await ctx.RespondAsync(embed);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,10 +4,6 @@ using System.Threading.Tasks;
|
|||
using DSharpPlus;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.Interactivity.Extensions;
|
||||
using DSharpPlus.Lavalink;
|
||||
using DSharpPlus.SlashCommands;
|
||||
using DSharpPlus.VoiceNext;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -49,12 +45,13 @@ var discord = new DiscordClient(new DiscordConfiguration
|
|||
var services = new ServiceCollection()
|
||||
.BuildServiceProvider();
|
||||
|
||||
/*var slash = discord.UseSlashCommands();
|
||||
/*
|
||||
var lavalink = discord.UseLavalink();
|
||||
var interactivity = discord.UseInteractivity();
|
||||
var voice = discord.UseVoiceNext();*/
|
||||
var voice = discord.UseVoiceNext();
|
||||
*/
|
||||
|
||||
// register commands
|
||||
// Register Msg Commands
|
||||
var commands = discord.UseCommandsNext(new CommandsNextConfiguration
|
||||
{
|
||||
CaseSensitive = false,
|
||||
|
@ -70,5 +67,11 @@ var commands = discord.UseCommandsNext(new CommandsNextConfiguration
|
|||
|
||||
commands.RegisterCommands(Assembly.GetExecutingAssembly());
|
||||
|
||||
/*// Register Slash Commands
|
||||
var slash = discord.UseSlashCommands(new SlashCommandsConfiguration
|
||||
{
|
||||
Services = services
|
||||
});*/
|
||||
|
||||
await discord.ConnectAsync(new DiscordActivity("With DSharpPlus"));
|
||||
await Task.Delay(-1);
|
|
@ -17,26 +17,33 @@
|
|||
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
|
||||
<UseNativeHttpHandler>true</UseNativeHttpHandler>
|
||||
<UseSystemResourceKeys>true</UseSystemResourceKeys>
|
||||
<Company>Relms</Company>
|
||||
<Product>Sharpy</Product>
|
||||
<AssemblyVersion>0.0.1.0</AssemblyVersion>
|
||||
<FileVersion>0.0.1.0</FileVersion>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<DebugType>none</DebugType>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<DebugType>full</DebugType>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ByteSize" Version="2.0.0" />
|
||||
<PackageReference Include="DSharpPlus" Version="4.2.0-nightly-00973" />
|
||||
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0-nightly-00973" />
|
||||
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-00973" />
|
||||
<PackageReference Include="DSharpPlus.Lavalink" Version="4.2.0-nightly-00973" />
|
||||
<PackageReference Include="DSharpPlus.Rest" Version="4.2.0-nightly-00973" />
|
||||
<PackageReference Include="DSharpPlus.VoiceNext" Version="4.2.0-nightly-00973" />
|
||||
<PackageReference Include="Hardware.Info" Version="1.1.1" />
|
||||
<PackageReference Include="IDoEverything.DSharpPlus.SlashCommands" Version="2.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0-preview.7.21377.19" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0-preview.7.21377.19" />
|
||||
|
@ -45,13 +52,14 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Commands" />
|
||||
<Folder Include="Commands\Common" />
|
||||
<Folder Include="Commands\Slash" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Reference in a new issue