chaosbot/ChaosBot/Discord/Modules/PointsCommands.cs
2020-06-04 22:25:53 -04:00

85 lines
2.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ChaosBot.Database.Entity;
using Discord;
using Discord.Commands;
using Microsoft.Extensions.Configuration;
using NLog;
using ChaosBot.Database.Repository;
namespace ChaosBot.Discord.Modules
{
public class PointsCommands : ModuleBase
{
private static Logger _logger = Program._logger;
[Command("points help")]
public async Task PointsCommandInfo()
{
try
{
var sb = new StringBuilder();
var embed = new EmbedBuilder();
string prefix = Program.Cfg.GetValue<string>("Discord:Prefix");
embed.WithColor(new Color(255, 255, 0));
embed.Title = $"Points system";
sb.AppendLine($"{Context.User.Mention} has requested points information.");
sb.AppendLine();
sb.AppendLine($"Usage:");
sb.AppendLine($"{prefix}points status");
sb.AppendLine($"{prefix}points help");
sb.AppendLine();
sb.AppendLine("Moderation commands:");
sb.AppendLine($"{prefix}points add <discord mention> <amount>");
sb.AppendLine($"{prefix}point remove");
/*
* Add the string to the Embed
*/
embed.Description = sb.ToString();
/*
* Reply with the Embed created above
*/
await ReplyAsync(null, false, embed.Build());
}
catch (Exception ex)
{
_logger.Error($"InfoCommands.InfoCommand: Exception [{ex}] thrown, <[{ex.Message}]>.");
}
}
[Command("points")]
[Alias("points info")]
public async Task PointsCommandTotal()
{
int cur = PointsRepository.Total(Context.User.Id.ToString(), Context.Guild.Id.ToString());
await ReplyAsync($"You have {cur} points.", false);
}
/*[Command("points add")]
[RequireUserPermission(GuildPermission.ManageGuild)]
public async Task RaffleCommandAdd(string user, int amount = 1)
{
if (Program.Cfg.GetValue<int>($"Servers:{Context.Guild.Id}:Raffle:Max") >= amount)
// await RaffleCommandHelper("add", user, amount);
else
{
await ReplyAsync(
$"You cannot give more then {Program.Cfg.GetValue<int>($"Servers:{Context.Guild.Id}:Raffle:Max").ToString()} tickets at a time", false);
_logger.Warn($"{Context.User.Username} attempted to give {amount} tickets to {user}!");
}
}
[Command("points remove")]
[RequireUserPermission(GuildPermission.ManageGuild)]
public async Task RaffleCommandClear()
{
await RaffleCommandHelper("clear");
} */
}
}