Merged projects with plugins and modules

This commit is contained in:
2024-07-22 01:18:00 +03:00
parent 1fd065f4c2
commit 8ace51c840
59 changed files with 1669 additions and 73 deletions

View File

@@ -0,0 +1,52 @@
using Discord;
using DiscordBotCore;
using DiscordBotCore.Interfaces;
using DiscordBotCore.Others;
namespace LevelingSystem;
internal class LevelCommand: DBCommand
{
public string Command => "level";
public List<string> Aliases => ["lvl", "rank"];
public string Description => "Display tour current level";
public string Usage => "level";
public bool requireAdmin => false;
public async void ExecuteServer(DbCommandExecutingArguments args)
{
if(Variables.Database is null)
{
Application.CurrentApplication.Logger.Log("Database is not initialized", this, LogType.Warning);
return;
}
object[]? user = await Variables.Database.ReadDataArrayAsync($"SELECT * FROM Levels WHERE UserID=@userId",
new KeyValuePair<string, object>("userId", args.Context.Message.Author.Id));
if (user is null)
{
await args.Context.Channel.SendMessageAsync("You are now unranked !");
return;
}
var level = (int)user[1];
var exp = (int)user[2];
var builder = new EmbedBuilder();
var r = new Random();
builder.WithColor(r.Next(256), r.Next(256), r.Next(256));
builder.AddField("Current Level", level, true)
.AddField("Current EXP", exp, true)
.AddField("Required Exp", (level * 8 + 24).ToString(), true);
builder.WithTimestamp(DateTimeOffset.Now);
builder.WithAuthor(args.Context.Message.Author);
await args.Context.Channel.SendMessageAsync(embed: builder.Build());
}
}